The Fog Roles In
Setting up fog is pretty easy. The hardest part is getting it to look the way you want it to. You will probably spend way too much time tweaking with the settings. You only need 7 lines of code to make it work.
- Set the fog's color.
- gl.glFogfv(GL.GL_FOG_COLOR, [r, g, b], 0);
- Parameter 2 is an array of 3 floats for the red, green, and blue values
- Parameter 3 is TODO
- Set the fog's mode.
- gl.glFogi(GL.GL_FOG_MODE, GL.GL_EXP2);
- Your choices here are
-
GL_EXP2
GL_EXP
GL_LINEAR - Set the density of the fog.
- gl.glFogf(GL.GL_FOG_DENSITY, Fog_Density);
- Set the hint.
- gl.glHint(GL.GL_FOG_HINT, GL.GL_DONT_CARE);
- TODO what is hint
- Set the range of the fog.
- gl.glFogf(GL.GL_FOG_START,fogStart )
gl.glFogf(GL.GL_FOG_END, fogEnd); - This is where the effects of the fog start and where the fog is at full density
- Enable fog
- glEnable(GL.GL_FOG);
- Move on to the next step.
