Skip to content

Commit

Permalink
Make fog density a uniform
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Jan 9, 2012
1 parent 48b1242 commit faa2207
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion assets/shaders/block.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "fog.glsl"
uniform vec3 uSunDirection;
uniform vec4 uFogColor;
uniform float uFogDensity;
uniform vec4 uSunColor;
varying vec3 vNormal;
varying vec2 vTextureCoord;
Expand All @@ -18,7 +19,7 @@ void main(void)
vSunDirection = uSunDirection;
vNormal = uNormalMatrix * aVertexNormal;
vHalfVec = normalize(aVertexPosition + vSunDirection);
vFogFactor = getFogFactor(0.005);
vFogFactor = getFogFactor(uFogDensity);
}
#endif

Expand Down
2 changes: 2 additions & 0 deletions src/world.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class World
@sunColor = webglmc.floatColorFromHex '#F2F3DC'
@sunDirection = vec3.create [0.7, 0.8, 1.0]
@fogColor = webglmc.floatColorFromHex '#CEEBC0'
@fogDensity = 0.01

@displays =
chunkStats: webglmc.debugPanel.addDisplay 'Chunk stats'
Expand Down Expand Up @@ -373,6 +374,7 @@ class World
@shader.uniform4fv "uSunColor", @sunColor
@shader.uniform3fv "uSunDirection", @sunDirection
@shader.uniform4fv "uFogColor", @fogColor
@shader.uniform1f "uFogDensity", @fogDensity
this.iterVisibleVBOs (vbo) =>
vbo.draw()

Expand Down

0 comments on commit faa2207

Please sign in to comment.