Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 9, 2018, 1:06:05 PM (5 years ago)
Author:
wiesep
Message:

Updated programs and adjusted Material to work with GLSL>150

File:
1 edited

Legend:

Unmodified
Added
Removed
  • data/branches/Shader_HS18/programs/Example/GLSL150/SwizzleGP.glsl

    r12083 r12091  
    11#version 150
    22
    3 #extension GL_EXT_geometry_shader4 : enable                                                                                                     
     3uniform vec4 origColour;
     4uniform vec4 cloneColour;
    45
    5 uniform vec4 origColor;                                                                                                                                         
    6 uniform vec4 cloneColor;                                                                                                                                       
     6out vec4 colour;
    77
    8 void main(void)                                                                                                                                                         
    9 {                                                                                                                                                                                       
     8layout(triangles) in;
     9layout(line_strip, max_vertices = 6) out;
    1010
    11         //increment variable                                                                                                                                   
    12         int i;                                                                                                                                                                 
     11void 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();
    1320
    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();
    4129}
Note: See TracChangeset for help on using the changeset viewer.