polyadvent

A game engine from scratch in C
git clone git://jb55.com/polyadvent
Log | Files | Refs | README

terrain.g.glsl (989B)


      1 #include profile
      2 
      3 layout (triangles) in;
      4 layout (triangle_strip, max_vertices = 3) out;
      5 
      6 in shader_data {
      7 #include shadervars.glsl
      8 } vertices[];
      9 
     10 out shader_data {
     11 #include shadervars.glsl
     12 } vertex;
     13 
     14 #include uniforms.glsl
     15 
     16 void main() {
     17     int i;
     18 
     19     for(i = 0;i < gl_in.length();i++)// gl_in.length() = 1 though!
     20     {
     21         vec4 v4_pos = vec4(vertices[i].position, 1.0);
     22         vertex.position = vertices[i].position;
     23         vertex.color = vertices[i].color;
     24         vertex.color_smooth = vertices[i].color_smooth;
     25         vertex.normal = vertices[i].normal;
     26         // vertex.shadow_coord = depth_mvp * v4_pos;
     27         vertex.world_pos = (world * v4_pos).xyz;
     28         vertex.shadow_coord = vertices[i].shadow_coord;
     29         // vertex.frag_pos = vertices[i].frag_pos;
     30 
     31         // gl_Position = mvp * vec4(400.0 + i * 50.0, 300.0 + i * 50.0, 200.0 + i * 50.0, 1.0);
     32         gl_Position = mvp * vec4(vertices[i].position, 1.0);
     33 
     34         EmitVertex();
     35     }
     36 
     37     EndPrimitive();
     38 
     39 
     40 }