Waterflow
Visualize water in terrain
src/shaders/simplevoxels.geom
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 #version 150 
00007 
00008 layout(points) in; 
00009 layout(triangle_strip, max_vertices = 4) out; 
00010 
00011 out vec2 texValue; 
00012 out vec3 exNormal; 
00013 out vec4 outPosition; 
00014 
00015 uniform mat4 VTPMatrix; 
00016 
00017 void main()
00018 {
00019     // Create the initial positions
00020     vec3 toEmit = gl_in[0].gl_Position.xyz;
00021     vec3 toView = vec3(0,0,1);
00022     vec3 left = normalize(cross(toView, vec3(0,1,0)));
00023     vec3 top = normalize(cross(left,toView));
00024     vec4 tempPos;
00025     float radius = 0.5f;
00026 
00027     // Create the bottom left corner
00028     toEmit += radius * (left - top);
00029     tempPos = vec4(toEmit, 1.0f);
00030     gl_Position = VTPMatrix * tempPos;
00031     outPosition = tempPos;
00032     texValue = vec2(0.0f, 0.0f);
00033     exNormal = toView - top + left;
00034     EmitVertex();
00035     
00036     // Create the bottom right corner
00037     toEmit -= 2 * radius * left;
00038     tempPos = vec4(toEmit, 1.0f);
00039     gl_Position = VTPMatrix * tempPos;
00040     outPosition = tempPos;
00041     texValue = vec2(1.0f, 0.0f);
00042     exNormal = toView - top - left;
00043     EmitVertex();
00044     
00045     // Create the top left corner
00046     toEmit += 2 * radius * (top + left);
00047     tempPos = vec4(toEmit, 1.0f);
00048     gl_Position = VTPMatrix * tempPos;
00049     outPosition = tempPos;
00050     texValue = vec2(0.0f, 1.0f);
00051     exNormal = toView + top + left;
00052     EmitVertex();
00053         
00054     // Create the top right corner
00055     toEmit -= 2 * radius * left;
00056     tempPos = vec4(toEmit, 1.0f);
00057     gl_Position = VTPMatrix * tempPos;
00058     outPosition = tempPos;
00059     texValue = vec2(1.0f, 1.0f);
00060     exNormal = toView + top - left;
00061     EmitVertex();
00062     
00063     EndPrimitive();
00064 }
00065 
 All Classes Files Functions Variables Enumerations