ripple/displayMicroMesh.vert

35 lines
854 B
GLSL
Raw Permalink Normal View History

2017-11-28 17:35:49 +00:00
#version 410
#define SCENE_EXTENT 100.0f
uniform mat4 matrModel;
uniform mat4 matrVisu;
uniform mat4 matrProj;
uniform sampler2D terrain;
uniform sampler2D waterPos;
uniform sampler2D waterHeight;
/////////////////////////////////////////////////////////////////
layout(location=0) in vec2 Vertex;
out Attribs {
vec3 pos;
vec2 texuv;
} Out;
// takes a simple 2D vertex on the ground plane, offsets it along y by the land or water offset and projects it on screen
void main(void)
{
Out.texuv = Vertex;
2017-12-11 22:20:40 +00:00
vec4 pos = texture(waterPos, Out.texuv);
2017-11-28 17:35:49 +00:00
if (pos.w <= 0.0) { /* No position data -> no water here */
Out.pos = vec3(0);
gl_Position = vec4(0,0,0,-1);
} else {
2017-12-11 22:20:40 +00:00
Out.pos = pos.xyz + texture(waterHeight, Out.texuv).rgb;
2017-11-28 17:35:49 +00:00
gl_Position = matrProj * matrVisu * matrModel * vec4(Out.pos, 1);
}
}