OpenGL port of https://github.com/jeschke/water-wave-packets, presented at SIGGRAPH 2017.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

34 lines
854 B

#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;
vec4 pos = texture(waterPos, Out.texuv);
if (pos.w <= 0.0) { /* No position data -> no water here */
Out.pos = vec3(0);
gl_Position = vec4(0,0,0,-1);
} else {
Out.pos = pos.xyz + texture(waterHeight, Out.texuv).rgb;
gl_Position = matrProj * matrVisu * matrModel * vec4(Out.pos, 1);
}
}