Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/Example/GLSL150/SwizzleGP.glsl @ 12083

Last change on this file since 12083 was 12083, checked in by wiesep, 5 years ago

Reorganised shader programs

File size: 1.6 KB
Line 
1#version 150
2
3#extension GL_EXT_geometry_shader4 : enable                                                                                                     
4
5uniform vec4 origColor;                                                                                                                                         
6uniform vec4 cloneColor;                                                                                                                                       
7
8void main(void)                                                                                                                                                         
9{                                                                                                                                                                                       
10
11        //increment variable                                                                                                                                   
12        int i;                                                                                                                                                                 
13
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
41}
Note: See TracBrowser for help on using the repository browser.