Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 9, 2018, 1:06:05 PM (6 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/GLSL/SwizzleGP.glsl

    r12083 r12091  
    1 #version 120                                                                                                                                                           
    2 #extension GL_EXT_geometry_shader4 : enable                                                                                                     
     1#version 120
     2#extension GL_EXT_geometry_shader4 : enable
    33
    4 uniform vec4 origColor;                                                                                                                                         
    5 uniform vec4 cloneColor;                                                                                                                                       
     4uniform vec4 origColour;
     5uniform vec4 cloneColour;
    66
    7 void main(void)                                                                                                                                                         
    8 {                                                                                                                                                                                       
     7void main(void)
     8{
     9    /////////////////////////////////////////////////////////////
     10    //This example has two parts
     11    //  step a) draw the primitive pushed down the pipeline
     12    //           there are gl_Vertices # of vertices
     13    //           put the vertex value into gl_Position
     14    //           use EmitVertex => 'create' a new vertex
     15    //          use EndPrimitive to signal that you are done creating a primitive!
     16    //  step b) create a new piece of geometry (I.E. WHY WE ARE USING A GEOMETRY SHADER!)
     17    //          I just do the same loop, but swizzle the x and y values
     18    //  result => the line we want to draw, and the same line, but along the other axis
    919
    10         //increment variable                                                                                                                                   
    11         int i;                                                                                                                                                                 
     20    //Pass-thru!
     21    int i;
     22    for (i = 0; i < gl_VerticesIn; i++) {
     23        gl_Position = gl_PositionIn[i];
     24        gl_FrontColor = origColour;
     25        EmitVertex();
     26    }
     27    EndPrimitive();
    1228
    13         /////////////////////////////////////////////////////////////                                                   
    14         //This example has two parts                                                                                                                   
    15         //      step a) draw the primitive pushed down the pipeline                                                                     
    16         //               there are gl_Vertices # of vertices                                                                                   
    17         //               put the vertex value into gl_Position                                                                                 
    18         //               use EmitVertex => 'create' a new vertex                                                                               
    19         //              use EndPrimitive to signal that you are done creating a primitive!                             
    20         //      step b) create a new piece of geometry (I.E. WHY WE ARE USING A GEOMETRY SHADER!)       
    21         //              I just do the same loop, but swizzle the x and y values                                                 
    22         //      result => the line we want to draw, and the same line, but along the other axis         
    23 
    24         //Pass-thru!                                                                                                                                                   
    25         for(i=0; i< gl_VerticesIn; i++){                                                                                                               
    26                 gl_Position = gl_PositionIn[i];                                                                                                         
    27                 gl_FrontColor = origColor;                                                                                                                     
    28                 EmitVertex();                                                                                                                                           
    29         }                                                                                                                                                                               
    30         EndPrimitive();                                                                                                                                                 
    31         //New piece of geometry!  We just swizzle the x and y terms                                                             
    32         for(i=0; i< gl_VerticesIn; i++){                                                                                                               
    33                 gl_Position = gl_PositionIn[i];                                                                                                         
    34                 gl_Position.xy = gl_Position.yx;                                                                                                       
    35                 gl_FrontColor = cloneColor;                                                                                                                     
    36                 EmitVertex();                                                                                                                                           
    37         }                                                                                                                                                                               
    38         EndPrimitive();                                                                                                                                                 
    39 
     29    //New piece of geometry!  We just swizzle the x and y terms
     30    for (i = 0; i < gl_VerticesIn; i++){
     31        gl_Position = gl_PositionIn[i];
     32        gl_Position.xy = gl_Position.yx;
     33        gl_FrontColor = cloneColour;
     34        EmitVertex();
     35    }
     36    EndPrimitive();
    4037}
Note: See TracChangeset for help on using the changeset viewer.