- Timestamp:
- Nov 9, 2018, 1:06:05 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
data/branches/Shader_HS18/programs/Example/GLSL150/SwizzleGP.glsl
r12083 r12091 1 1 #version 150 2 2 3 #extension GL_EXT_geometry_shader4 : enable 3 uniform vec4 origColour; 4 uniform vec4 cloneColour; 4 5 5 uniform vec4 origColor; 6 uniform vec4 cloneColor; 6 out vec4 colour; 7 7 8 void main(void) 9 { 8 layout(triangles) in; 9 layout(line_strip, max_vertices = 6) out; 10 10 11 //increment variable 12 int i; 11 void main() 12 { 13 // Pass-through! 14 for (int i = 0; i < gl_in.length(); i++){ 15 gl_Position = gl_in[i].gl_Position; 16 colour = origColour; 17 EmitVertex(); 18 } 19 EndPrimitive(); 13 20 14 ///////////////////////////////////////////////////////////// 15 //This example has two parts 16 // step a) draw the primitive pushed down the pipeline 17 // there are gl_Vertices # of vertices 18 // put the vertex value into gl_Position 19 // use EmitVertex => 'create' a new vertex 20 // use EndPrimitive to signal that you are done creating a primitive! 21 // step b) create a new piece of geometry (I.E. WHY WE ARE USING A GEOMETRY SHADER!) 22 // I just do the same loop, but swizzle the x and y values 23 // result => the line we want to draw, and the same line, but along the other axis 24 25 //Pass-thru! 26 for(i=0; i< gl_VerticesIn; i++){ 27 gl_Position = gl_PositionIn[i]; 28 gl_FrontColor = origColor; 29 EmitVertex(); 30 } 31 EndPrimitive(); 32 //New piece of geometry! We just swizzle the x and y terms 33 for(i=0; i< gl_VerticesIn; i++){ 34 gl_Position = gl_PositionIn[i]; 35 gl_Position.xy = gl_Position.yx; 36 gl_FrontColor = cloneColor; 37 EmitVertex(); 38 } 39 EndPrimitive(); 40 21 // New piece of geometry! We just swizzle the x and y terms. 22 for (int i = 0; i < gl_in.length(); i++){ 23 gl_Position = gl_in[i].gl_Position; 24 gl_Position.xy = gl_Position.yx; 25 colour = cloneColour; 26 EmitVertex(); 27 } 28 EndPrimitive(); 41 29 }
Note: See TracChangeset
for help on using the changeset viewer.