medfall

A super great game engine
Log | Files | Refs

commit b1e080d86e7cd3320d18a2d4877eb924fe4ff790
parent 8e382e55126529c867720b3c5f080717bbdf2561
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Wed,  1 Nov 2017 23:49:45 +0200

Fix shaky clipmap terrain

Diffstat:
shaders/clipmap.glsl | 5+++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/shaders/clipmap.glsl b/shaders/clipmap.glsl @@ -31,12 +31,13 @@ out VSOut v2f; void main() { vec2 xy = offset + position.xy * scale + camera_pos.xy; - vec2 uv = floor( xy / scale ) * scale / textureSize( heightmap, 0 ) + 0.5; + vec2 snapped_xy = floor( xy / scale ) * scale; + vec2 uv = snapped_xy / textureSize( heightmap, 0 ) + 0.5; float z = 255.0 * texture( heightmap, uv ).r + texture( heightmap, uv ).g; v2f.pos = vec3( xy, z ); v2f.uv = uv; - gl_Position = P * V * vec4( floor( xy ), z, 1.0 ); + gl_Position = P * V * vec4( snapped_xy, z, 1.0 ); } #else