逛奔的蜗牛

我不聪明,但我会很努力

   ::  :: 新随笔 ::  ::  :: 管理 ::
Fog:
The amount of the fog color mixed with the geometry varies with the distance of the geometry from the camera origin
glEnable(GL_FOG);
glFogfv(GL_FOG_COLOR, fogColor);
// GL_FOG_START and GL_FOG_END only for GL_LINEAR.
glFogf(GL_FOG_START, 5.0f);
glFogf(GL_FOG_END, 30.0f);
glFogi(GL_FOG_MODE, GL_LINEAR); // Which fog equation to use.

glHint(GL_FOG_HINT, GL_NICEST); // 计算方式.

// GL_EXP, GL_EXP2: 需要fog density
glFogF(GL_FOG_DENSITY, 0.5f);
d: fog density.
c: (z) the distance in eye coordinates from origin to fragment being fogged.
c: is the distance of the fragment from the eye plane.

Density: 0.5f
The parameter GL_FOG_START specifies how far away from the eye fogging begins to take effect, and GL_FOG_END is the distance from the eye where the fog color completely over- powers the color of the object(如果再远, 物体完全被fog color给遮盖).

Regardless of the fog mode, f is clamped to the range [0,1] after it is computed. Then, if the GL is in RGBA color mode, the fragment's color Cr is replaced by

Fog Coordinates: For example, you want to elevation to play a role, lending to volumetric fog effects.
void glFogCoordf(GLfloat fFogDistance);
glFogi(GL_FOG_COORD_SRC, GL_FOG_COORD);

return to OpenGL-drived fog effects:
glFogi(GL_FOG_COORD_SRC, GL_FRAGMENT_DEPTH);
posted on 2009-05-24 04:28 逛奔的蜗牛 阅读(984) 评论(0)  编辑 收藏 引用 所属分类: OpenGL

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理