Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #version 430
- layout(points) in;
- layout(triangle_strip, max_vertices = 48) out;
- uniform mat4 View;
- uniform mat4 Projection;
- uniform vec3 eye_position;
- uniform float triangle_step;
- layout(location = 0) out vec2 texture_coord;
- vec3 vpos = gl_in[0].gl_Position.xyz;
- vec3 forward = normalize(eye_position - vpos);
- vec3 right = normalize(cross(forward, vec3(0, 1, 0)));
- vec3 up = normalize(cross(forward, right));
- void EmitPoint(vec2 offset)
- {
- vec3 pos = right * offset.x + up * offset.y + vpos;
- gl_Position = Projection * View * vec4(pos, 1.0);
- EmitVertex();
- }
- void EmitPoint2(vec3 offset)
- {
- vec3 pos = vec3(vpos.x + offset.x, vpos.y + offset.y, vpos.z + offset.z);
- gl_Position = Projection * View * vec4(pos, 1);
- EmitVertex();
- }
- void main()
- {
- float ds = triangle_step;
- // Create a quad using triangle strip
- //
- // 3---------2
- // | \ |
- // | \ |
- // | \ |
- // 0---------1
- //
- // Triangles: (0, 1, 3), (1, 2, 3)
- float offset_size = 1.0f;
- //FATA SPATE
- texture_coord = vec2(0.0f);
- EmitPoint2(vec3(-ds, -ds, 0));
- texture_coord = vec2(offset_size, 0.0f);
- EmitPoint2(vec3(ds, -ds, 0));
- texture_coord = vec2(0.0f, offset_size);
- EmitPoint2(vec3(-ds, ds, 0));
- EndPrimitive();
- texture_coord = vec2(0.0f);
- EmitPoint2(vec3(-ds, -ds, -0.5f));
- texture_coord = vec2(0.0f, offset_size);
- EmitPoint2(vec3(-ds, ds, -0.5f));
- texture_coord = vec2(offset_size, 0.0f);
- EmitPoint2(vec3(ds, -ds, -0.5f));
- EndPrimitive();
- //3 - 1
- texture_coord = vec2(offset_size, offset_size);
- EmitPoint2(vec3(-ds, ds, 0));
- texture_coord = vec2(0.0f, offset_size);
- EmitPoint2(vec3(ds, -ds, 0));
- texture_coord = vec2(0.0f, 0.0f);
- EmitPoint2(vec3(ds, -ds, -0.5f));
- EndPrimitive();
- texture_coord = vec2(offset_size, offset_size);
- EmitPoint2(vec3(-ds, ds, 0));
- texture_coord = vec2(0.0f, 0.0f);
- EmitPoint2(vec3(ds, -ds, -0.5f));
- texture_coord = vec2(offset_size, 0.0f);
- EmitPoint2(vec3(-ds, ds, -0.5f));
- EndPrimitive();
- //3 - 0
- texture_coord = vec2(0, offset_size);
- EmitPoint2(vec3(-ds, ds, 0));
- texture_coord = vec2(0.0f, 0.0f);
- EmitPoint2(vec3(-ds, ds, -0.5f));
- texture_coord = vec2(offset_size, 0.0f);
- EmitPoint2(vec3(-ds, -ds, -0.5f));
- EndPrimitive();
- texture_coord = vec2(offset_size, offset_size);
- EmitPoint2(vec3(-ds, -ds, 0));
- texture_coord = vec2(0.0f, offset_size);
- EmitPoint2(vec3(-ds, ds, 0.0f));
- texture_coord = vec2(offset_size, 0.0f);
- EmitPoint2(vec3(-ds, -ds, -0.5f));
- EndPrimitive();
- // 0 - 1
- texture_coord = vec2(offset_size, offset_size);
- EmitPoint2(vec3(ds, -ds, 0));
- texture_coord = vec2(0.0f, offset_size);
- EmitPoint2(vec3(-ds, -ds, 0.0f));
- texture_coord = vec2(0.0f, 0.0f);
- EmitPoint2(vec3(-ds, -ds, -0.5f));
- EndPrimitive();
- texture_coord = vec2(offset_size, offset_size);
- EmitPoint2(vec3(ds, -ds, 0));
- texture_coord = vec2(0.0f, 0.0f);
- EmitPoint2(vec3(-ds, -ds, -0.5f));
- texture_coord = vec2(offset_size, 0.0f);
- EmitPoint2(vec3(ds, -ds, -0.5f));
- EndPrimitive();
- // PRIMUL TRIUNGHI
- //FATA SPATE
- texture_coord = vec2(offset_size, 0.0f);
- EmitPoint2(vec3(ds, -ds, 0));
- texture_coord = vec2(offset_size);
- EmitPoint2(vec3(ds, ds, 0));
- texture_coord = vec2(0.0f, offset_size);
- EmitPoint2(vec3(-ds, ds, 0));
- EndPrimitive();
- texture_coord = vec2(offset_size, 0.0f);
- EmitPoint2(vec3(ds, -ds, -0.5f));
- texture_coord = vec2(0.0f, offset_size);
- EmitPoint2(vec3(-ds, ds, -0.5f));
- texture_coord = vec2(offset_size);
- EmitPoint2(vec3(ds, ds, -0.5f));
- EndPrimitive();
- //3 - 1
- texture_coord = vec2(offset_size, offset_size);
- EmitPoint2(vec3(-ds, ds, 0));
- texture_coord = vec2(0.0f, 0.0f);
- EmitPoint2(vec3(ds, -ds, -0.5f));
- texture_coord = vec2(0.0f, offset_size);
- EmitPoint2(vec3(ds, -ds, 0));
- EndPrimitive();
- texture_coord = vec2(offset_size, offset_size);
- EmitPoint2(vec3(-ds, ds, 0));
- texture_coord = vec2(offset_size, 0.0f);
- EmitPoint2(vec3(-ds, ds, -0.5f));
- texture_coord = vec2(0.0f, 0.0f);
- EmitPoint2(vec3(ds, -ds, -0.5f));
- EndPrimitive();
- //3 - 2
- texture_coord = vec2(0.0f, 0.0f);
- EmitPoint2(vec3(-ds, ds, 0));
- texture_coord = vec2(offset_size, 0.0f);
- EmitPoint2(vec3(ds, ds, 0.0f));
- texture_coord = vec2(offset_size, offset_size);
- EmitPoint2(vec3(ds, ds, -0.5f));
- EndPrimitive();
- texture_coord = vec2(0.0f, 0.0f);
- EmitPoint2(vec3(-ds, ds, 0));
- texture_coord = vec2(offset_size, offset_size);
- EmitPoint2(vec3(ds, ds, -0.5f));
- texture_coord = vec2(0.0f, offset_size);
- EmitPoint2(vec3(-ds, ds, -0.5f));
- EndPrimitive();
- //2 - 1
- texture_coord = vec2(offset_size, offset_size);
- EmitPoint2(vec3(ds, ds, -0.5f));
- texture_coord = vec2(0.0f, offset_size);
- EmitPoint2(vec3(ds, ds, 0.0f));
- texture_coord = vec2(0.0f, 0.0f);
- EmitPoint2(vec3(ds, -ds, 0.0f));
- EndPrimitive();
- texture_coord = vec2(offset_size, offset_size);
- EmitPoint2(vec3(ds, ds, -0.5f));
- texture_coord = vec2(0.0f, 0.0f);
- EmitPoint2(vec3(ds, -ds, 0.0f));
- texture_coord = vec2(offset_size, 0.0f);
- EmitPoint2(vec3(ds, -ds, -0.5f));
- EndPrimitive();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement