0

I understand how a simple GLSL fog shader works, but how can it be applied? Applying it directly to a terrain mesh does not produce the desired "fog" result. How would one mimic the built-in fog effects of OpenGL with a shader? The only thing that I can think of is applying the shader to a series of encased spheres around the camera, but that seems like a lot of work for just some fog.

Update: Some images to further explain.

This is the shader I have applied to my terrain mesh, and the result is not what I want:

http://puu.sh/31dft.jpg

这是我想要复制的那种效果:

http://mw2.google.com/mw-panoramio/photos/medium/4503932.jpg

4

2 回答 2

1

Semi-realistic atmosphere rendering is an complex problem to which many (ongoing-) research is dedicated. In your reference photo there are essentially three major factors that can contribute to the particular composition: i. fog/haze ii. atmospheric scattering iii. altitude.

Simply put applying fog solely on objects such as terrain, is an inherently flawed concept, because fog occludes/obscures the transmittance of light. This includes the light from the sky. So in order to cover the scenario of fog being applied to the 'sky' another approach is required, involving post-processing. Essentially the position of every pixel needs to be reconstructed in 3d-space, and the fog algorithm needs to run over each of these.

Depending on particular the art-style this might be sufficient for your needs, however it's more complicated. This document, http://developer.amd.com/wordpress/media/2012/10/D3DTutorial_Crytek.pdf gives a nice starting point regarding atmospheric rendering (it includes volumetric fog).

于 2013-12-01T20:19:49.820 回答
0

您必须将雾色和背景色设置为相同。否则效果看起来很奇怪。雾的重点是使远处的物体“淡入背景”。您的图像的问题在于您的背景是明亮的蓝色,就好像您希望它是一个阳光明媚、晴朗的日子。但是场景中的物体正在逐渐变白,就好像有很厚的雾一样。我建议你找到一些折衷方案——两者都使用灰蓝色。

于 2013-12-01T18:20:35.063 回答