diff options
Diffstat (limited to 'data/shaders/terrain-normalmap.frag')
-rw-r--r-- | data/shaders/terrain-normalmap.frag | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/data/shaders/terrain-normalmap.frag b/data/shaders/terrain-normalmap.frag new file mode 100644 index 0000000..74529ae --- /dev/null +++ b/data/shaders/terrain-normalmap.frag @@ -0,0 +1,15 @@ +uniform float height; +uniform vec2 resolution; +uniform sampler2D heightMap; + +varying vec2 vUv; + +void main() +{ + float val = texture2D( heightMap, vUv ).x; + + float valU = texture2D( heightMap, vUv + vec2( 1.0 / resolution.x, 0.0 ) ).x; + float valV = texture2D( heightMap, vUv + vec2( 0.0, 1.0 / resolution.y ) ).x; + + gl_FragColor = vec4( ( 0.5 * normalize( vec3( val - valU, val - valV, height ) ) + 0.5 ), 1.0 ); +} |