Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 12091


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

Location:
data/branches/Shader_HS18
Files:
187 added
26 edited

Legend:

Unmodified
Added
Removed
  • data/branches/Shader_HS18/materials/Cube_Lava_Normal.material

    r12088 r12091  
    1 //------------------------
    2 // Basic
    3 //------------------------
    4 
    5 //---------------------------------------------------
    6 // This file includes a number of basic GPU programs
    7 // for use in many materials.
    8 //---------------------------------------------------
    9 
    10 
    11 // A really basic ambient pass program, support for one texture coordinate set
    12 vertex_program AmbientOneTextureCg cg
    13 {
    14     source Example_Basic.cg
    15     entry_point ambientOneTexture_vp
    16     profiles vs_1_1 arbvp1
    17 
    18     default_params
    19     {
    20         param_named_auto worldViewProj worldviewproj_matrix
    21         param_named_auto ambient ambient_light_colour
    22     }
    23 
    24 }
    25 
    26 vertex_program AmbientOneTextureCgSm4 cg
    27 {
    28     source Example_Basic_sm4.cg
    29     entry_point ambientOneTexture_vp
    30     profiles vs_4_0
    31 
    32     default_params
    33     {
    34         param_named_auto worldViewProj worldviewproj_matrix
    35         param_named_auto ambient ambient_light_colour
    36     }
    37 
    38 }
    39 
    40 // A really basic ambient pass program, support for one texture coordinate set
    41 vertex_program AmbientOneTextureHLSL hlsl
    42 {
    43     source Example_Basic.hlsl
    44     entry_point ambientOneTexture_vp
    45     target vs_4_0
    46 
    47     default_params
    48     {
    49         param_named_auto worldViewProj worldviewproj_matrix
    50         param_named_auto ambient ambient_light_colour
    51     }
    52 }
    53 // A really basic ambient pass program, support for one texture coordinate set
    54 vertex_program AmbientOneTextureGLSL glsl
    55 {
    56     source AmbientOneTexture.glsl
    57 }
    58 
    59 // A really basic ambient pass program, support for one texture coordinate set
    60 vertex_program AmbientOneTextureGLSL glsl
    61 {
    62     source AmbientOneTexture.glsl
    63    
    64 
    65     default_params
    66     {
    67         param_named_auto ambient ambient_light_colour
    68         param_named_auto worldViewProj worldviewproj_matrix
    69     }
    70 }
    71 
    72 // A really basic ambient pass program, support for one texture coordinate set
    73 vertex_program AmbientOneTextureGLSLES glsles
    74 {
    75     source AmbientOneTexture.glsles
    76 
    77     default_params
    78     {
    79         param_named_auto worldViewProj worldviewproj_matrix
    80         param_named_auto ambient ambient_light_colour
    81     }
    82 }
    83 
    84 vertex_program AmbientOneTextureWithUVGLSLES glsles
    85 {
    86     source AmbientOneTextureWithUV.glsles
    87 
    88     default_params
    89     {
    90         param_named_auto worldViewProj worldviewproj_matrix
    91         param_named_auto ambient ambient_light_colour
    92     }
    93 }
    94 
    95 vertex_program AmbientOneTextureWithUVGLSL glsl
    96 {
    97     source AmbientOneTextureWithUV.glsl
    98    
    99 
    100     default_params
    101     {
    102         param_named_auto worldViewProj worldviewproj_matrix
    103         param_named_auto ambient ambient_light_colour
    104     }
    105 }
    106 
    107 vertex_program AmbientOneTextureWithUV unified
    108 {
    109     delegate AmbientOneTextureWithUVGLSL
    110     delegate AmbientOneTextureWithUVGLSLES
    111     delegate AmbientOneTextureHLSL
    112     delegate AmbientOneTextureCg
    113     delegate AmbientOneTextureCgSm4
    114 }
    115 
    116 vertex_program AmbientOneTextureUnified unified
    117 {
    118     delegate AmbientOneTextureGLSL
    119     delegate AmbientOneTextureGLSLES
    120     delegate AmbientOneTextureHLSL
    121     delegate AmbientOneTextureCg
    122     delegate AmbientOneTextureCgSm4
    123 }
    124 
    125 fragment_program DiffuseOneTextureCg cg
    126 {
    127     source Example_Basic.cg
    128     entry_point diffuseOneTexture_fp
    129     profiles ps_2_0 arbfp1
    130 }
    131 
    132 fragment_program DiffuseOneTextureGLSLES glsles
    133 {
    134     source DiffuseOneTexture.glsles
    135     default_params
    136     {
    137         param_named texMap int 0
    138     }
    139 }
    140 
    141 fragment_program DiffuseOneTextureGLSL glsl
    142 {
    143     source DiffuseOneTexture.glsl
    144     default_params
    145     {
    146         param_named texMap int 0
    147     }
    148 }
    149 
    150 fragment_program DiffuseOneTexture unified
    151 {
    152     delegate DiffuseOneTextureGLSL
    153     delegate DiffuseOneTextureGLSLES
    154     delegate DiffuseOneTextureCg
    155 }
    156 
    157 // A really basic ambient pass program, support for one texture coordinate set
    158 fragment_program PassthroughFP unified
    159 {
    160     delegate PassthroughFpGLSL
    161     delegate PassthroughFpGLSLES
    162     delegate PassthroughFpCgSm4
    163     delegate PassthroughFpCg
    164 }
    165 
    166 // A really basic ambient pass program, support for one texture coordinate set
    167 fragment_program PassthroughFpCgSm4 cg
    168 {
    169     entry_point main
    170     source PassthroughFP_sm4.cg
    171     profiles ps_4_0
    172 }
    173 
    174 fragment_program PassthroughFpCg cg
    175 {
    176     entry_point mainCg
    177     source PassthroughFP.cg
    178     profiles ps_2_0 arbfp1
    179 }
    180 
    181 // A really basic ambient pass program, support for one texture coordinate set
    182 fragment_program PassthroughFpCgSm4ForAmbientOneTexture cg
    183 {
    184     entry_point mainForAmbientOneTexture
    185     source PassthroughFP_sm4.cg
    186     profiles ps_4_0
    187 }
    188 
    189 
    190 // A really basic ambient pass program, support for one texture coordinate set
    191 fragment_program PassthroughFpGLSLES glsles
    192 {
    193     source PassthroughFP.glsles
    194 }
    195 
    196 fragment_program PassthroughFpGLSL glsl
    197 {
    198     source PassthroughFP.glsl
    199 }
    200 
    201 //------------------------
    202 // Bump mapping section
    203 //------------------------
    204 
    205 // Bump map vertex program, support for this is required
    206 vertex_program Lava/BumpMapVPCg cg
    207 {
    208     source Example_BumpMapping.cg
    209     entry_point main_vp
    210     profiles vs_4_0 vs_1_1 arbvp1
    211 }
    212 
    213 vertex_program Lava/BumpMapVPGLSLES glsles
    214 {
    215     source Example_BumpMappingVp.glsles
    216     profiles glsles
    217 }
    218 
    219 vertex_program Lava/BumpMapVPGLSL glsl
    220 {
    221     source Example_BumpMappingVp.glsl
    222 }
    223 
    224 vertex_program Lava/BumpMapVP unified
    225 {
    226     delegate Lava/BumpMapVPGLSL
    227     delegate Lava/BumpMapVPGLSLES
    228     delegate Lava/BumpMapVPCg
    229 }
    230 
    231 // Bump map vertex program, with tangent parity support for this is required
    232 vertex_program Lava/BumpMapVPTangentParityCg cg
    233 {
    234     source Example_BumpMapping.cg
    235     entry_point main_vp
    236     profiles vs_1_1 arbvp1
    237     compile_arguments -DTANGENTS_HAVE_PARITY=1
    238 }
    239 
    240 // Bump map vertex program, with tangent parity support for this is required
    241 vertex_program Lava/BumpMapVPTangentParityGLSLES glsles
    242 {
    243     source BumpMapVPTangentParity.glsles
    244 }
    245 
    246 vertex_program Lava/BumpMapVPTangentParityGLSL glsl
    247 {
    248     source BumpMapVPTangentParity.glsl
    249     default_params
    250     {
    251         param_named_auto lightDiffuse light_diffuse_colour 0
    252     }
    253 }
    254 
    255 vertex_program Lava/BumpMapVPTangentParity unified
    256 {
    257     delegate Lava/BumpMapVPTangentParityGLSL
    258     delegate Lava/BumpMapVPTangentParityGLSLES
    259     delegate Lava/BumpMapVPTangentParityCg
    260 }
    261 
    262 // Bump map fragment program, support for this is optional
    263 fragment_program Lava/BumpMapFPCg cg
    264 {
    265     source Example_BumpMapping.cg
    266     entry_point main_fp
    267     profiles ps_4_0 ps_2_0 arbfp1 fp20
    268 }
    269 
    270 fragment_program Lava/BumpMapFPGLSLES glsles
    271 {
    272     source Example_BumpMappingFp.glsles
    273     profiles glsles
    274     default_params
    275     {
    276         // assign samplers as required by GLSL
    277         param_named normalMap int 0
    278     }
    279 }
    280 
    281 fragment_program Lava/BumpMapFPGLSL glsl
    282 {
    283     source Example_BumpMappingFp.glsl
    284     default_params
    285     {
    286         // assign samplers as required by GLSL
    287         param_named normalMap int 0
    288     }
    289 }
    290 
    291 fragment_program Lava/BumpMapFP unified
    292 {
    293     delegate Lava/BumpMapFPGLSL
    294     delegate Lava/BumpMapFPGLSLES
    295     delegate Lava/BumpMapFPCg
    296 }
    297 
    298 // Bump map vertex program shadow receiver
    299 vertex_program Lava/BumpMapVPShadowRcvCg cg
    300 {
    301     source Example_BumpMapping.cg
    302     entry_point main_shadowreceiver_vp
    303     profiles vs_1_1 arbvp1
    304 }
    305 
    306 // Bump map vertex program shadow receiver
    307 vertex_program Lava/BumpMapVPShadowRcvGLSLES glsles
    308 {
    309     source Example_BumpMappingShadowRcvVp.glsles
    310     profiles glsles
    311 }
    312 
    313 vertex_program Lava/BumpMapVPShadowRcvGLSL glsl
    314 {
    315     source Example_BumpMappingShadowRcvVp.glsl
    316 
    317 }
    318 
    319 vertex_program Lava/BumpMapVPShadowRcv unified
    320 {
    321     delegate Lava/BumpMapVPShadowRcvGLSL
    322     delegate Lava/BumpMapVPShadowRcvGLSLES
    323     delegate Lava/BumpMapVPShadowRcvCg
    324 }
    325 
    326 // Bump map fragment program shadow receiver, support for this is optional
    327 fragment_program Lava/BumpMapFPShadowRcvCg cg
    328 {
    329     source Example_BumpMapping.cg
    330     entry_point main_shadowreceiver_fp
    331     profiles ps_2_0 arbfp1 fp20
    332 }
    333 
    334 // Bump map fragment program shadow receiver, support for this is optional
    335 fragment_program Lava/BumpMapFPShadowRcvGLSLES glsles
    336 {
    337     source Example_BumpMappingShadowRcvFp.glsles
    338     profiles glsles
    339     default_params
    340     {
    341         // assign samplers as required by GLSL
    342         param_named shadowMap int 0
    343         param_named normalMap int 1
    344     }
    345 }
    346 
    347 fragment_program Lava/BumpMapFPShadowRcvGLSL glsl
    348 {
    349     source Example_BumpMappingShadowRcvFp.glsl
    350     default_params
    351     {
    352         // assign samplers as required by GLSL
    353         param_named shadowMap int 0
    354         param_named normalMap int 1
    355     }
    356 }
    357 
    358 fragment_program Lava/BumpMapFPShadowRcv unified
    359 {
    360     delegate Lava/BumpMapFPShadowRcvGLSL
    361     delegate Lava/BumpMapFPShadowRcvGLSLES
    362     delegate Lava/BumpMapFPShadowRcvCg
    363 }
    364 
    365 // Bump map with specular vertex program, support for this is required
    366 vertex_program Lava/BumpMapVPSpecularCg cg
    367 {
    368     source Example_BumpMapping.cg
    369     entry_point specular_vp
    370     profiles vs_4_0 vs_1_1 arbvp1
    371 }
    372 
    373 // Bump map with specular vertex program, support for this is required
    374 vertex_program Lava/BumpMapVPSpecularGLSLES glsles
    375 {
    376     source Example_BumpMappingSpecularVp.glsles
    377     profiles glsles
    378 }
    379 
    380 vertex_program Lava/BumpMapVPSpecularGLSL glsl
    381 {
    382     source Example_BumpMappingSpecularVp.glsl
    383 }
    384 
    385 vertex_program Lava/BumpMapVPSpecular unified
    386 {
    387     delegate Lava/BumpMapVPSpecularGLSL
    388     delegate Lava/BumpMapVPSpecularGLSLES
    389     delegate Lava/BumpMapVPSpecularCg
    390 }
    391 
    392 // Bump map fragment program, support for this is optional
    393 fragment_program Lava/BumpMapFPSpecularCg cg
    394 {
    395     source Example_BumpMapping.cg
    396     entry_point specular_fp
    397     profiles ps_4_0 ps_2_0 arbfp1 fp20
    398 }
    399 
    400 // Bump map fragment program, support for this is optional
    401 fragment_program Lava/BumpMapFPSpecularGLSLES glsles
    402 {
    403     source Example_BumpMappingSpecularFp.glsles
    404     profiles glsles
    405     default_params
    406     {
    407         // assign samplers as required by GLSL
    408         param_named normalMap int 0
    409     }
    410 }
    411 
    412 fragment_program Lava/BumpMapFPSpecularGLSL glsl
    413 {
    414     source Example_BumpMappingSpecularFp.glsl
    415     default_params
    416     {
    417         // assign samplers as required by GLSL
    418         param_named normalMap int 0
    419     }
    420 }
    421 
    422 fragment_program Lava/BumpMapFPSpecular unified
    423 {
    424     delegate Lava/BumpMapFPSpecularGLSL
    425     delegate Lava/BumpMapFPSpecularGLSLES
    426     delegate Lava/BumpMapFPSpecularCg
    427 }
    428 
    429 //------------------------
    430 // Material
    431 //------------------------
    432 
    4331// Any number of lights, diffuse
    4342material Cube_Lava_Normal
    4353{
    436 
    437     // This is the preferred technique which uses both vertex and
    438     // fragment programs, supports coloured lights
    4394    technique
    4405    {
     
    4449            // base colours, not needed for rendering, but as information
    44510            // to lighting pass categorisation routine
    446             ambient 1 1 1
    447             diffuse 0 0 0
    448             specular 0 0 0 0
    449             // Really basic vertex program
    450             // NB we don't use fixed function here because GL does not like
    451             // mixing fixed function and vertex programs, depth fighting can
    452             // be an issue
    453             vertex_program_ref AmbientOneTextureUnified
    454             {
    455                 param_named_auto ambient ambient_light_colour
    456             }
    457             fragment_program_ref PassthroughFP
    458             {
    459             }
    460            
     11            diffuse 0 0 0
    46112        }
    46213        // Now do the lighting pass
     
    46415        pass perlight
    46516        {
     17            // do this for each light
     18            iteration once_per_light
     19            scene_blend add
     20
    46621            // base colours, not needed for rendering, but as information
    46722            // to lighting pass categorisation routine
    468             ambient 0 0 0
    469            
    470             // do this for each light
    471             iteration once_per_light
    472 
    473        
    474             scene_blend add
     23            ambient 0 0 0
    47524
    47625            // Vertex program reference
    477             vertex_program_ref Lava/BumpMapVP
     26            vertex_program_ref Examples/BumpMapVP
    47827            {
    47928                param_named_auto lightPosition light_position_object_space 0
     
    48231
    48332            // Fragment program
    484             fragment_program_ref Lava/BumpMapFP
     33            fragment_program_ref Examples/BumpMapFP
    48534            {
    48635                param_named_auto lightDiffuse light_diffuse_colour 0
     
    48837
    48938            // texture shadow receiver program
    490             shadow_receiver_vertex_program_ref Lava/BumpMapVPShadowRcv
     39            shadow_receiver_vertex_program_ref Examples/BumpMapVPShadowRcv
    49140            {
    49241                param_named_auto lightPosition light_position_object_space 0
     
    49645            }
    49746            // Additive texture shadow receiver program
    498             shadow_receiver_fragment_program_ref Lava/BumpMapFPShadowRcv
     47            shadow_receiver_fragment_program_ref Examples/BumpMapFPShadowRcv
    49948            {
    50049                param_named_auto lightDiffuse light_diffuse_colour 0
     
    50554            {
    50655                texture Cube_Lava_NORM.jpg
    507                 tex_address_mode wrap
    508                 scale 1.0 1.0
    50956                colour_op replace
    51057            }
    511 
    51258        }
    51359       
     
    51561        pass decal
    51662        {
    517             // base colours, not needed for rendering, but as information
    518             // to lighting pass categorisation routine
     63            // hint to pass categorisation routine, that this is decal only
    51964            lighting off
    520             // Really basic vertex program
    521             // NB we don't use fixed function here because GL does not like
    522             // mixing fixed function and vertex programs, depth fighting can
    523             // be an issue
    524             vertex_program_ref AmbientOneTextureUnified
    525             {
    526                 param_named_auto worldViewProj worldviewproj_matrix
    527                 param_named ambient float4 1 1 1 1
    528             }
    529             fragment_program_ref PassthroughFP
    530             {
    531             }
    532 
    53365            scene_blend dest_colour zero
    534             texture_unit
    535             {
    536                 texture Cube_Lava_NORM.jpg
    537                 tex_address_mode wrap
    538                 scale 1.0 1.0
    539                 colour_op modulate
    540             }
    541 
    542            
    543         }
    544 
    545       pass Cube_Lava
    546         {
    547             ambient 0.800000011920929 0.800000011920929 0.800000011920929 1.0
    548             diffuse 0.6400000190734865 0.6400000190734865 0.6400000190734865 1.0
    549             specular 0.5 0.5 0.5 1.0 12.5
    550             emissive 0.0 0.0 0.0 1.0
    551 
    552             alpha_to_coverage off
    553             colour_write on
    554             cull_hardware clockwise
    555             depth_check on
    556             depth_func less_equal
    557             depth_write on
    558             illumination_stage
    559             light_clip_planes off
    560             light_scissor off
    561             lighting on
    562             normalise_normals off
    563             polygon_mode solid
    564             scene_blend one zero
    565             scene_blend_op add
    566             shading gouraud
    567             transparent_sorting on
    568 
    569             texture_unit
    570             {
    571                 texture Cube_Lava_COLOR.jpg
    572                 tex_address_mode wrap
    573                 scale 1.0 1.0
    574                 colour_op modulate
    575             }
     66            ambient 0.5 0.5 0.5 1
    57667        }
    57768    }
    578 
    579 
    58069}
  • data/branches/Shader_HS18/materials/ToonShader.material

    r7708 r12091  
    11vertex_program toonvs glsl
    22{
    3         source ToonShader_vs.vert
     3        source ToonShader_vs.glsl
    44}
    55
    66fragment_program Toonps glsl
    77{
    8         source ToonShader_ps.frag
     8        source ToonShader_ps.glsl
    99}
    1010
  • data/branches/Shader_HS18/programs/Example/GLSL/DepthShadowmapNormalMapReceiverFp.glsl

    r12083 r12091  
    3131        vec4 shadowUV = oUv;
    3232        // point on shadowmap
    33         shadowUV.xy = shadowUV.xy / shadowUV.w;
     33        shadowUV = shadowUV / shadowUV.w;
    3434        float centerdepth = texture2D(shadowMap, shadowUV.xy).x;
    3535   
  • data/branches/Shader_HS18/programs/Example/GLSL/DepthShadowmapReceiverFp.glsl

    r12083 r12091  
    1515        vec4 shadowUV = oUv;
    1616        // point on shadowmap
    17         shadowUV.xy = shadowUV.xy / shadowUV.w;
     17        shadowUV = shadowUV / shadowUV.w;
    1818        float centerdepth = texture2D(shadowMap, shadowUV.xy).x;
    1919   
  • 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}
  • data/branches/Shader_HS18/programs/Example/GLSL150/Blur0_vs.glsl

    r12083 r12091  
    11#version 150
    22
     3in vec4 vertex;
     4// in vec2 uv0;
    35out vec2 texCoord[5];
    4 in vec4 vertex;
    56
    6 uniform mat4 worldViewProj;
    7 in vec2 uv0;
     7// uniform mat4 worldViewProj;
    88
    9 void main()                   
     9void main()
    1010{
    11         gl_Position = worldViewProj * vertex;
    12        
    13         texCoord[0]  = uv0;
    14        
    15         const float size = 0.01;
    16         texCoord[1] = texCoord[0] + vec2(1.0, 0.0)*size;
    17         texCoord[2] = texCoord[0] + vec2(2.0, 0.0)*size;
    18         texCoord[3] = texCoord[0] + vec2(-1.0, 0.0)*size;
    19         texCoord[4] = texCoord[0] + vec2(-2.0, 0.0)*size;
     11    // gl_Position = worldViewProj * vertex;
     12
     13    // texCoord[0]  = uv0;
     14
     15    vec2 inPos = sign(vertex.xy);
     16    gl_Position = vec4(inPos.xy, 0.0, 1.0);
     17
     18    texCoord[0]  = (vec2(inPos.x, -inPos.y) + 1.0)/2.0;
     19
     20    const float size = 0.01;
     21    texCoord[1] = texCoord[0] + vec2(1.0, 0.0) * size;
     22    texCoord[2] = texCoord[0] + vec2(2.0, 0.0) * size;
     23    texCoord[3] = texCoord[0] + vec2(-1.0, 0.0) * size;
     24    texCoord[4] = texCoord[0] + vec2(-2.0, 0.0) * size;
    2025}
  • data/branches/Shader_HS18/programs/Example/GLSL150/Blur1_vs.glsl

    r12083 r12091  
    11#version 150
    22
    3 uniform mat4 worldViewProj;
     3in vec4 vertex;
     4// in vec2 uv0;
     5out vec2 texCoord[5];
    46
    5 out vec2 texCoord[5];
    6 in vec4 vertex;
    7 in vec2 uv0;
     7// uniform mat4 worldViewProj;
    88
    99void main()
    1010{
    11         gl_Position = worldViewProj * vertex;
    12        
    13         texCoord[0]  = uv0;
    14        
    15         const float size = 0.01;
    16         texCoord[1] = texCoord[0] + vec2(0.0, 1.0)*size;
    17         texCoord[2] = texCoord[0] + vec2(0.0, 2.0)*size;
    18         texCoord[3] = texCoord[0] + vec2(0.0, -1.0)*size;
    19         texCoord[4] = texCoord[0] + vec2(0.0, -2.0)*size;
     11    // gl_Position = worldViewProj * vertex;
     12
     13    // texCoord[0]  = uv0;
     14
     15    vec2 inPos = sign(vertex.xy);
     16    gl_Position = vec4(inPos.xy, 0.0, 1.0);
     17
     18    texCoord[0]  = (vec2(inPos.x, -inPos.y) + 1.0)/2.0;
     19
     20    const float size = 0.01;
     21    texCoord[1] = texCoord[0] + vec2(0.0, 1.0) * size;
     22    texCoord[2] = texCoord[0] + vec2(0.0, 2.0) * size;
     23    texCoord[3] = texCoord[0] + vec2(0.0, -1.0) * size;
     24    texCoord[4] = texCoord[0] + vec2(0.0, -2.0) * size;
    2025}
  • data/branches/Shader_HS18/programs/Example/GLSL150/Combine_fp.glsl

    r12083 r12091  
    1010void main()
    1111{
    12    vec4 render = texture(RT, oUv0);
    13    vec4 sum = texture(Sum, oUv0);
     12    vec4 render = texture(RT, oUv0);
     13    vec4 sum = texture(Sum, oUv0);
    1414
    15    fragColour = mix(render, sum, blur);
     15    fragColour = mix(render, sum, blur);
    1616}
  • data/branches/Shader_HS18/programs/Example/GLSL150/DepthShadowObjectFp.glsl

    r12083 r12091  
    11#version 150
    2 /* Copyright Torus Knot Software Ltd 2000-2013
     2/* Copyright Torus Knot Software Ltd 2000-2014
    33
    44Permission is hereby granted, free of charge, to any person obtaining a copy
  • data/branches/Shader_HS18/programs/Example/GLSL150/DepthShadowObjectVp.glsl

    r12083 r12091  
    11#version 150
    2 /* Copyright Torus Knot Software Ltd 2000-2013
     2/* Copyright Torus Knot Software Ltd 2000-2014
    33
    44Permission is hereby granted, free of charge, to any person obtaining a copy
  • data/branches/Shader_HS18/programs/Example/GLSL150/HardwareMorphAnimationVp.glsl

    r12083 r12091  
    66in vec4 uv1; // pos2
    77
    8 out vec2 oUv;
     8// out vec2 oUv;
    99out vec4 colour;
    1010
     
    1616{
    1717        // interpolate
    18         vec4 interp = vec4(vertex.xyz + anim_t.x*(uv1.xyz - vertex.xyz), 1.0);
     18        vec4 interp = vec4(vertex.xyz + anim_t.x * (uv1.xyz - vertex.xyz), 1.0);
    1919       
    2020        gl_Position = worldViewProj * interp;
    21         oUv = uv0.xy;
    22         colour = vec4(1.0,0.0,0.0,1.0);
     21        // oUv = uv0.xy;
     22        colour = vec4(1.0, 0.0, 0.0, 1.0);
    2323}
  • data/branches/Shader_HS18/programs/Example/GLSL150/HardwareMorphAnimationWithNormalsVp.glsl

    r12083 r12091  
    77in vec4 uv2; // normal2
    88
    9 out vec2 oUv;
    109out vec4 colour;
     10// out vec2 oUv;
    1111
    1212uniform mat4 worldViewProj;
     
    1818void main()
    1919{
    20         // interpolate position
    21         vec4 posinterp = vec4(vertex.xyz + anim_t.x*(uv1.xyz - vertex.xyz), 1.0);
     20    // interpolate position
     21    vec4 posinterp = vec4(vertex.xyz + anim_t.x*(uv1.xyz - vertex.xyz), 1.0);
    2222
    2323    // nlerp normal
    24         vec3 ninterp = normal + anim_t.x*(uv2.xyz - normal);
    25         ninterp = normalize(ninterp);
     24    vec3 ninterp = normal + anim_t.x*(uv2.xyz - normal);
     25    ninterp = normalize(ninterp);
    2626
    27         gl_Position = worldViewProj * posinterp;
    28         oUv = uv0.xy;
     27    gl_Position = worldViewProj * posinterp;
     28    // oUv = uv0.xy;
    2929
    30         vec3 lightDir = normalize(
    31                 objSpaceLightPos.xyz - (posinterp.xyz * objSpaceLightPos.w));
     30    vec3 lightDir = normalize(
     31        objSpaceLightPos.xyz - (posinterp.xyz * objSpaceLightPos.w));
    3232
    33         // Colour it red to make it easy to identify
    34         float lit = clamp(dot(lightDir, ninterp), 0.0, 1.0);
    35         colour = vec4((ambient.rgb + vec3(lit,lit,lit)) * vec3(1.0,0.0,0.0), 1.0);
     33    // Colour it red to make it easy to identify
     34    float lit = clamp(dot(lightDir, ninterp), 0.0, 1.0);
     35    colour = vec4((ambient.rgb + vec3(lit,lit,lit)) * vec3(1.0,0.0,0.0), 1.0);
    3636}
  • data/branches/Shader_HS18/programs/Example/GLSL150/HardwarePoseAnimationVp.glsl

    r12083 r12091  
    1616void main()
    1717{
    18         // interpolate
    19     vec4 interp = vec4(vertex + anim_t.x*uv1.xyz + anim_t.y*uv2.xyz, 1.0);
     18    // interpolate
     19    vec4 interp = vec4(vertex.xyz + anim_t.x * uv1.xyz + anim_t.y * uv2.xyz, 1.0);
    2020
    21         gl_Position = worldViewProj * interp;
    22         oUv = uv0.xy;
    23         colour = vec4(1.0,0.0,0.0,1.0);
     21    gl_Position = worldViewProj * interp;
     22    oUv = uv0.xy;
     23    colour = vec4(1.0, 0.0, 0.0, 1.0);
    2424}
    25 
  • data/branches/Shader_HS18/programs/Example/GLSL150/HardwarePoseAnimationWithNormalsVp.glsl

    r12083 r12091  
    99in vec4 uv4; // pose2norm
    1010
    11 out vec2 oUv;
     11// out vec2 oUv;
    1212out vec4 colour;
    1313
     
    2020void main()
    2121{
    22         // interpolate position
    23         vec4 posinterp = vec4(pos + anim_t.x*uv1.xyz + anim_t.y*uv3.xyz, 1.0);
     22    // interpolate position
     23    vec4 posinterp = vec4(vertex.xyz + anim_t.x * uv1.xyz + anim_t.y * uv3.xyz, 1.0);
    2424
    2525    // nlerp normal
    26         // nlerp normal
    27         // First apply the pose normals (these are actual normals, not offsets)
    28         vec3 ninterp = anim_t.x*uv2.xyz + anim_t.y*uv4.xyz;
     26    // First apply the pose normals (these are actual normals, not offsets)
     27    vec3 ninterp = anim_t.x * uv2.xyz + anim_t.y * uv4.xyz;
    2928
    30         // Now add back any influence of the original normal
    31         // This depends on what the cumulative weighting left the normal at, if it's lacking or cancelled out
    32         //float remainder = 1.0 - min(anim_t.x + anim_t.y, 1.0);
    33         float remainder = 1.0 - min(length(ninterp), 1.0);
    34         ninterp = ninterp + (normal * remainder);
    35         ninterp = normalize(ninterp);
     29    // Now add back any influence of the original normal
     30    // This depends on what the cumulative weighting left the normal at, if it's lacking or cancelled out
     31    //float remainder = 1.0 - min(anim_t.x + anim_t.y, 1.0);
     32    float remainder = 1.0 - min(length(ninterp), 1.0);
     33    ninterp = ninterp + (remainder * normal.xyz);
     34    ninterp = normalize(ninterp);
    3635
    37         gl_Position = worldViewProj * posinterp;
    38         oUv = uv0.xy;
    39        
    40         vec3 lightDir = normalize(
    41                 objSpaceLightPos.xyz - (posinterp.xyz * objSpaceLightPos.w));
     36    gl_Position = worldViewProj * posinterp;
     37    // oUv = uv0.xy;
    4238
    43         // Colour it red to make it easy to identify
    44         float lit = clamp(dot(lightDir, ninterp), 0.0, 1.0);
    45         colour = vec4((ambient.rgb + vec3(lit,lit,lit)) * vec3(1.0,0.0,0.0), 1.0);
     39    vec3 lightDir = normalize(
     40        objSpaceLightPos.xyz - (posinterp.xyz * objSpaceLightPos.w));
     41
     42    // Colour it red to make it easy to identify
     43    float lit = clamp(dot(lightDir, ninterp), 0.0, 1.0);
     44    colour = vec4((ambient.rgb + vec3(lit, lit, lit)) * vec3(1.0, 0.0, 0.0), 1.0);
    4645}
  • data/branches/Shader_HS18/programs/Example/GLSL150/HeatBlurFp.glsl

    r12083 r12091  
    99void main()
    1010{
    11    int i;
    12    vec4 tmpOutColor;
    13    float  diffuseGlowFactor;
    14    vec2 offsets[4];
    15 /*
    16                 // hazy blur
    17                 -1.8, -1.8,
    18                 -1.8, 1.8,
    19                 1.8, -1.8,
    20                 1.8, 1.8
    21 */
    22 /*
    23                 // less-hazy blur
    24           -1.0,  2.0,
    25           -1.0, -1.0,
    26            1.0, -1.0,
    27            1.0,  1.0
    28 */
    29 /*
     11    int i;
     12    vec4 tmpOutColor;
     13    float  diffuseGlowFactor;
     14    vec2 offsets[4];
     15    /*
     16    // hazy blur
     17    -1.8, -1.8,
     18    -1.8, 1.8,
     19    1.8, -1.8,
     20    1.8, 1.8
     21    */
     22    /*
     23    // less-hazy blur
     24    -1.0,  2.0,
     25    -1.0, -1.0,
     26    1.0, -1.0,
     27    1.0,  1.0
     28    */
     29    /*
    3030      -0.326212, -0.405805,
    3131      -0.840144, -0.073580,
    3232      -0.695914,  0.457137,
    3333      -0.203345,  0.620716
    34 */
     34    */
    3535
    36    offsets[0] = vec2(-0.3,  0.4);
    37    offsets[1] = vec2(-0.3,  -0.4);
    38    offsets[2] = vec2(0.3,  -0.4);
    39    offsets[3] = vec2(0.3,  0.4);
     36    offsets[0] = vec2(-0.3,  0.4);
     37    offsets[1] = vec2(-0.3,  -0.4);
     38    offsets[2] = vec2(0.3,  -0.4);
     39    offsets[3] = vec2(0.3,  0.4);
    4040
    41    tmpOutColor = texture( Input, uv );  // UV coords are in image space
     41    tmpOutColor = texture( Input, uv ); // UV coords are in image space
    4242
    43    // calculate glow amount
    44    diffuseGlowFactor = 0.0113 * (2.0 - max( tmpOutColor.r, tmpOutColor.g ));
     43    // calculate glow amount
     44    diffuseGlowFactor = 0.0113 * (2.0 - max( tmpOutColor.r, tmpOutColor.g ));
    4545
    46    // basic blur filter
    47    for (i = 0; i < 4; i++) {
    48       tmpOutColor += texture( Input, uv + blurAmount.x * diffuseGlowFactor * offsets[i] );
    49    }
     46    // basic blur filter
     47    for (i = 0; i < 4; i++) {
     48        tmpOutColor += texture( Input, uv + blurAmount.x * diffuseGlowFactor * offsets[i] );
     49    }
    5050
    51    tmpOutColor *= 0.25;
     51    tmpOutColor *= 0.25;
    5252
    53    // TIPS (old-skool strikes again!)
    54    // Pay attention here! If you use the "out float4 outColor" directly
    55    // in your steps while creating the output color (like you remove
    56    // the "tmpOutColor" var and just use the "outColor" directly)
    57    // your pixel-color output IS CHANGING EACH TIME YOU DO AN ASSIGNMENT TOO!
    58    // A temporary variable, instead, acts like a per-pixel double buffer, and
    59    // best of all, lead to better performance.
    60    fragColour = tmpOutColor;
     53    // TIPS (old-skool strikes again!)
     54    // Pay attention here! If you use the "out float4 outColor" directly
     55    // in your steps while creating the output color (like you remove
     56    // the "tmpOutColor" var and just use the "outColor" directly)
     57    // your pixel-color output IS CHANGING EACH TIME YOU DO AN ASSIGNMENT TOO!
     58    // A temporary variable, instead, acts like a per-pixel double buffer, and
     59    // best of all, lead to better performance.
     60    fragColour = tmpOutColor;
    6161}
  • data/branches/Shader_HS18/programs/Example/GLSL150/LightToHeatFp.glsl

    r12083 r12091  
    99uniform sampler2D HeatLookup;
    1010
    11 in vec4 diffuse;
     11// in vec4 diffuse;
    1212in vec2 uv;
    1313out vec4 fragColour;
     
    1515void main()
    1616{
    17    float depth, heat, interference;
     17    float depth, heat, interference;
    1818
    19    //  Output constant color:
    20    depth = texture( Input, uv ).x;
    21    depth *= (depth * depth_modulator).x;
     19    //  Output constant color:
     20    depth = texture( Input, uv ).x;
     21    depth *= (depth * depth_modulator).x;
    2222
    23    heat = (depth * heatBiasScale.y);
     23    heat = (depth * heatBiasScale.y);
    2424
    25 //  if (depth > 0)
    26    {
    27                 interference = -0.5 + texture( NoiseMap, uv + vec2( random_fractions.x, random_fractions.y ) ).x;
    28                 interference *= interference;
    29                 interference *= 1.0 - heat;
    30                 heat += interference;//+ heatBiasScale.x;
    31    }
     25    // if (depth > 0)
     26    {
     27        interference = -0.5 + texture( NoiseMap, uv + vec2( random_fractions.x, random_fractions.y ) ).x;
     28        interference *= interference;
     29        interference *= 1.0 - heat;
     30        heat += interference;//+ heatBiasScale.x;
     31    }
    3232
    33    // Clamp UVs
    34    heat  = max( 0.005, min( 0.995, heat ) );
    35    fragColour = texture( HeatLookup, vec2( heat, 0.0 ) );
     33    // Clamp UVs
     34    heat  = max( 0.005, min( 0.995, heat ) );
     35    fragColour = texture( HeatLookup, vec2( heat, 0.0 ) );
    3636}
  • data/branches/Shader_HS18/programs/Example/GLSL150/OldTV.glsl

    r12083 r12091  
    2020void main()
    2121{
    22    // Define a frame shape
    23    float f = (1 - pos.x * pos.x) * (1 - pos.y * pos.y);
    24    float frame = clamp(frameSharpness * (pow(f, frameShape) - frameLimit), 0.0, 1.0);
     22    // Define a frame shape
     23    float f = (1 - pos.x * pos.x) * (1 - pos.y * pos.y);
     24    float frame = clamp(frameSharpness * (pow(f, frameShape) - frameLimit), 0.0, 1.0);
    2525
    26    // Interference ... just a texture filled with rand()
    27    float rand = texture(Rand, vec3(1.5 * pos.x, 1.5 * pos.y, time_0_X)).x - 0.2;
     26    // Interference ... just a texture filled with rand()
     27    float rand = texture(Rand, vec3(1.5 * pos.x, 1.5 * pos.y, time_0_X)).x - 0.2;
    2828
    29    // Some signed noise for the distortion effect
    30    float noisy = texture(Noise, vec3(0, 0.5 * pos.y, 0.1 * time_0_X)).x - 0.5;
     29    // Some signed noise for the distortion effect
     30    float noisy = texture(Noise, vec3(0, 0.5 * pos.y, 0.1 * time_0_X)).x - 0.5;
    3131
    32    // Repeat a 1 - x^2 (0 < x < 1) curve and roll it with sinus.
    33    float dst = fract(pos.y * distortionFreq + distortionRoll * sin_time_0_X);
    34    dst *= (1 - dst);
    35    // Make sure distortion is highest in the center of the image
    36    dst /= 1 + distortionScale * abs(pos.y);
     32    // Repeat a 1 - x^2 (0 < x < 1) curve and roll it with sinus.
     33    float dst = fract(pos.y * distortionFreq + distortionRoll * sin_time_0_X);
     34    dst *= (1 - dst);
     35    // Make sure distortion is highest in the center of the image
     36    dst /= 1 + distortionScale * abs(pos.y);
    3737
    38    // ... and finally distort
    39    vec2 inUv = oUv0;
    40    inUv.x += distortionScale * noisy * dst;
    41    vec4 image = texture(Image, inUv);
     38    // ... and finally distort
     39    vec2 inUv = oUv0;
     40    inUv.x += distortionScale * noisy * dst;
     41    vec4 image = texture(Image, inUv);
    4242
    43    // Combine frame, distorted image and interference
    44    fragColour = frame * (interference * rand + image);
     43    // Combine frame, distorted image and interference
     44    fragColour = frame * (interference * rand + image);
    4545}
    46 
  • data/branches/Shader_HS18/programs/Example/GLSL150/ParticleGS_DisplayGS.glsl

    r12083 r12091  
    22
    33in block {
    4         vec3    pos;
    5     vec4        color;
    6         float   radius;
    7 } ColoredFirework[];
     4    vec3 pos;
     5    vec4 colour;
     6    float radius;
     7} ColouredFirework[];
    88
    99out block {
    10         vec4    pos;
    11     vec4        color;
    12         vec2    texcoord;
     10    vec4 pos;
     11    vec4 colour;
     12    vec2 texcoord;
    1313} Firework;
    1414
     
    2222void main()
    2323{
    24         vec3 g_positions[4] = vec3[4](vec3(-1, 1, 0), vec3(-1, -1, 0), vec3(1, 1, 0), vec3(1, -1, 0));
     24    vec3 g_positions[4] = vec3[4](vec3(-1, 1, 0), vec3(-1, -1, 0), vec3(1, 1, 0), vec3(1, -1, 0));
    2525    vec2 g_texcoords[4] = vec2[4](vec2(0, 1), vec2(1, 1), vec2(0, 0), vec2(1, 0));
    2626
     
    2828    // Emit two new triangles
    2929    //
    30     for(int i=0; i<4; i++)
     30    for (int i = 0; i < 4; i++)
    3131    {
    32                 vec3 position = -g_positions[i] * ColoredFirework[0].radius;
    33         position = mat3(inverseView) * position + ColoredFirework[0].pos;
     32        vec3 position = -g_positions[i] * ColouredFirework[0].radius;
     33        position = mat3(inverseView) * position + ColouredFirework[0].pos;
    3434        gl_Position = worldViewProj * vec4(position, 1.0);
    3535
    3636        Firework.pos = gl_Position;
    37         Firework.color = ColoredFirework[0].color;
     37        Firework.colour = ColouredFirework[0].colour;
    3838        Firework.texcoord = g_texcoords[i];
    3939        EmitVertex();
  • data/branches/Shader_HS18/programs/Example/GLSL150/ParticleGS_DisplayVS.glsl

    r12083 r12091  
    44// Explanation of different particle types
    55//
    6 #define PT_LAUNCHER 0 //Firework Launcher - launches a PT_SHELL every so many seconds
    7 #define PT_SHELL    1 //Unexploded shell - flies from the origin and explodes into many PT_EMBERXs
    8 #define PT_EMBER1   2 //basic particle - after it's emitted from the shell, it dies
    9 #define PT_EMBER2   3 //after it's emitted, it explodes again into many PT_EMBER1s
    10 #define PT_EMBER3   4 //just a differently colored ember1
     6// Firework Launcher - launches a PT_SHELL every so many seconds.
     7#define PT_LAUNCHER 0
     8// Unexploded shell - flies from the origin and explodes into many PT_EMBERX's.
     9#define PT_SHELL    1
     10// Basic particle - after it's emitted from the shell, it dies.
     11#define PT_EMBER1   2
     12// After it's emitted, it explodes again into many PT_EMBER1's.
     13#define PT_EMBER2   3
     14// Just a differently colored ember1.
     15#define PT_EMBER3   4
    1116#define P_SHELLLIFE 3.0
    1217#define P_EMBER1LIFE 2.5
     
    1419#define P_EMBER3LIFE 2.0
    1520
    16 in vec4 position;
    17 uniform float inTimer;
    18 uniform float inType;
    19 uniform vec3 inVelocity;
     21in vec3 position;
     22// timer
     23in float uv0;
     24// type
     25in float uv1;
     26// velocity
     27in vec3 uv2;
    2028
    2129out block {
    22         vec3    pos;
    23     vec4        color;
    24         float   radius;
    25 } ColoredFirework;
     30    vec3 pos;
     31    vec4 colour;
     32    float radius;
     33} ColouredFirework;
    2634
    2735uniform mat4 worldViewProj;
     
    3038void main()
    3139{
     40    float inTimer = uv0;
     41    float inType = uv1;
     42   
    3243    //
    3344    // Pass the point through
    3445    //
    35     ColoredFirework.pos = position.xyz; //Multiply by world matrix?
    36     ColoredFirework.radius = 1.5;
     46    ColouredFirework.pos = position; // Multiply by world matrix?
     47    ColouredFirework.radius = 1.5;
    3748   
    3849    // 
    39     // calculate the color
     50    // calculate the colour
    4051    //
    41     if( inType == PT_LAUNCHER )
     52    if (inType == PT_LAUNCHER)
    4253    {
    43         ColoredFirework.color = vec4(1,0.1,0.1,1);
    44         ColoredFirework.radius = 1.0;
     54        // red
     55        ColouredFirework.colour = vec4(1, 0.1, 0.1, 1);
     56        ColouredFirework.radius = 1.0;
    4557    }
    46     else if( inType == PT_SHELL )
     58    else if (inType == PT_SHELL)
    4759    {
    48         ColoredFirework.color = vec4(0.1,1,1,1);
    49         ColoredFirework.radius = 1.0;
     60        // cyan
     61        ColouredFirework.colour = vec4(0.1, 1, 1, 1);
     62        ColouredFirework.radius = 1.0;
    5063    }
    51     else if( inType == PT_EMBER1 )
     64    else if (inType == PT_EMBER1)
    5265    {
    53         ColoredFirework.color = vec4(1,1,0.1,1);
    54         ColoredFirework.color *= (inTimer / P_EMBER1LIFE );
     66        // yellow
     67        ColouredFirework.colour = vec4(1, 1, 0.1, 1);
     68        ColouredFirework.colour *= (inTimer / P_EMBER1LIFE);
    5569    }
    56     else if( inType == PT_EMBER2 )
     70    else if (inType == PT_EMBER2)
    5771    {
    58         ColoredFirework.color = vec4(1,0.1,1,1);
     72        // fuschia
     73        ColouredFirework.colour = vec4(1, 0.1, 1, 1);
    5974    }
    60     else if( inType == PT_EMBER3 )
     75    else if (inType == PT_EMBER3)
    6176    {
    62         ColoredFirework.color = vec4(1,0.1,0.1,1);
    63         ColoredFirework.color *= (inTimer / P_EMBER3LIFE );
     77        // red
     78        ColouredFirework.colour = vec4(1, 0.1, 0.1, 1);
     79        ColouredFirework.colour *= (inTimer / P_EMBER3LIFE);
    6480    }
    6581}
  • data/branches/Shader_HS18/programs/Example/GLSL150/ParticleGS_GenerateGS.glsl

    r12083 r12091  
    22
    33//
    4 // Explanation of different particle types
    5 //
    6 #define PT_LAUNCHER 0 //Firework Launcher - launches a PT_SHELL every so many seconds
    7 #define PT_SHELL    1 //Unexploded shell - flies from the origin and explodes into many PT_EMBERXs
    8 #define PT_EMBER1   2 //basic particle - after it's emitted from the shell, it dies
    9 #define PT_EMBER2   3 //after it's emitted, it explodes again into many PT_EMBER1s
    10 #define PT_EMBER3   4 //just a differently colored ember1
     4// Explanation of different particle types.
     5//
     6// Firework Launcher - launches a PT_SHELL every so many seconds.
     7#define PT_LAUNCHER 0
     8// Unexploded shell - flies from the origin and explodes into many PT_EMBERX's.
     9#define PT_SHELL    1
     10// Basic particle - after it's emitted from the shell, it dies.
     11#define PT_EMBER1   2
     12// After it's emitted, it explodes again into many PT_EMBER1's.
     13#define PT_EMBER2   3
     14// Just a different colored ember1.
     15#define PT_EMBER3   4
    1116#define P_SHELLLIFE 3.0
    1217#define P_EMBER1LIFE 2.5
     
    1419#define P_EMBER3LIFE 2.0
    1520
    16 //These two were originally shader params, but they caused runtime errors
     21// These two were originally shader params, but they caused runtime errors.
    1722#define NUM_EMBER_1S 30
    1823#define NUM_EMBER_2S 15
    1924#define NUM_EMBER_3S 10
    20 //This one was originally a variant, but this also causes runtime errors
     25// This one was originally a variant, but also causes runtime errors.
    2126//#define MAX_EMBER_2S 15.0
    2227
     28layout(points) in;
     29layout(points, max_vertices = 60) out;
     30
    2331in block {
    24         vec4    Pos;
    25         float   Timer;
    26     float       Type;
    27         vec3    Vel;
     32    vec3 Pos;
     33    float Timer;
     34    float Type;
     35    vec3 Vel;
    2836} FireworkData[];
    2937
    30 layout(points) in;
    31 layout(points, max_vertices = 1) out;
    32 
    33 uniform sampler1D randomTex;
     38// out vec3 outputPos;
     39// out float outputTimer;
     40// out float outputType;
     41// out vec3 outputVel;
     42
     43// out vec3 gl_Position;
     44out vec3 oPos;
     45out float oUv0; // Timer
     46out float oUv1; // Type
     47out vec3 oUv2;  // Velocity
     48
     49uniform sampler1D randomTexture;
    3450uniform vec3 frameGravity;
    3551uniform float globalTime;
    3652uniform float elapsedTime;
    3753uniform float secondsPerFirework;
    38 out vec4 colour;
     54
    3955//
    4056// Generic particle motion handler
    4157//
    42 
    4358void GSGenericHandler( vec3 Pos, vec3 Vel, float Timer, float Type,
    44                                                 float elapsedTime,
    45                                                 vec3 frameGravity)
    46 {
    47     gl_Position.xyz = Pos + (Vel * elapsedTime);
     59                       float elapsedTime,
     60                       vec3 frameGravity)
     61{
    4862    Vel += frameGravity;
    4963    Timer -= elapsedTime;
    50         if (Pos.y > -100)
    51         {
    52                 EmitVertex();//Pos : POSITION, Vel : TEXCOORD2, Timer : TEXCOORD0, Type : TEXCOORD1);
    53         }
     64
     65    if (Pos.y > -100)
     66    {
     67        oPos = Pos + (Vel * elapsedTime);
     68        oUv0 = Timer;
     69        oUv1 = Type;
     70        oUv2 = Vel;
     71        EmitVertex();
     72    }
    5473}
    5574
     
    6685// Launcher type particle handler
    6786//
    68 void GSLauncherHandler( vec3 Pos, vec3 Vel, float Timer, float Type, 
    69                                                 float elapsedTime,
    70                                                 float globalTime,
    71                                                 sampler1D randomTex,
    72                                                 float secondsPerFirework)
    73 {
    74     if(Timer <= 0)
    75     {
    76         vec3 vRandom = normalize( RandomDir( Type, globalTime, randomTex) );
    77                 //Give it more of an up bias
    78         vRandom = normalize(vRandom + vec3(0,2.5,0));
    79                
    80                 //time to emit a new SHELL
    81         gl_Position.xyz = Pos + Vel*elapsedTime;
    82         vec3 outputVel = Vel + vRandom*35.0;
    83         float  outputTimer = P_SHELLLIFE + vRandom.y*0.5;
    84         float outputType = PT_SHELL;
    85         EmitVertex();//(outputPos : POSITION, outputVel : TEXCOORD2, outputTimer : TEXCOORD0, outputType : TEXCOORD1);
    86        
    87         //reset our timer
    88         Timer = secondsPerFirework + vRandom.x*0.4;
     87void GSLauncherHandler( vec3 Pos, vec3 Vel, float Timer, float Type,
     88                        float elapsedTime,
     89                        float globalTime,
     90                        sampler1D randomTex,
     91                        float secondsPerFirework)
     92{
     93    if (Timer <= 0)
     94    {
     95        vec3 vRandom = normalize(RandomDir(Type, globalTime, randomTex));
     96        // Give it more of an up bias.
     97        vRandom = normalize(vRandom + vec3(0, 2.5, 0));
     98
     99        // Time to emit a new SHELL.
     100        oPos = Pos + Vel * elapsedTime;
     101        oUv2 = Vel + vRandom * 35.0;
     102        oUv0 = P_SHELLLIFE + vRandom.y * 0.5;
     103        oUv1 = PT_SHELL;
     104        EmitVertex();
     105
     106        // Reset our timer.
     107        Timer = secondsPerFirework + vRandom.x * 0.4;
    89108    }
    90109    else
     
    92111        Timer -= elapsedTime;
    93112    }
    94    
    95     //emit ourselves to keep us alive
    96     EmitVertex();//( Pos : POSITION, Vel : TEXCOORD2, Timer : TEXCOORD0, Type : TEXCOORD1);
     113
     114    // Emit ourselves to keep us alive.
     115    oPos = Pos;
     116    oUv2 = Vel;
     117    oUv0 = Timer;
     118    oUv1 = Type;
     119    EmitVertex();
    97120}
    98121
    99122//
    100123// Shell type particle handler
    101 //     
     124//
    102125void GSShellHandler( vec3 Pos, vec3 Vel, float Timer, float Type,
    103                                         float elapsedTime,
    104                                         float globalTime,
    105                                         sampler1D randomTex,
    106                                         vec3 frameGravity)
    107 {
    108     if(Timer <= 0)
    109     {
    110         vec3 outputPos;
    111                 vec3 outputVel;
    112                 float outputTimer;
    113                 float outputType;
    114                
     126                     float elapsedTime,
     127                     float globalTime,
     128                     sampler1D randomTex,
     129                     vec3 frameGravity)
     130{
     131    if (Timer <= 0)
     132    {
    115133        vec3 vRandom = vec3(0,0,0);
    116        
    117         //time to emit a series of new Ember1s 
    118         for(int i=0; i<NUM_EMBER_1S; i++)
     134
     135        // Time to emit a series of new Ember1s.
     136        for (int i = 0; i < NUM_EMBER_1S; i++)
    119137        {
    120             vRandom = normalize( RandomDir( Type+i, globalTime, randomTex ) );
    121             gl_Position.xyz = Pos + Vel*elapsedTime;
    122             outputVel = Vel + vRandom*15.0;
    123             outputTimer = P_EMBER1LIFE;
    124             outputType = PT_EMBER1;
    125             EmitVertex();//(outputPos : POSITION, outputTimer : TEXCOORD0, outputType : TEXCOORD1, outputVel : TEXCOORD2);
    126         }
    127        
    128         //find out how many Ember2s to emit
    129                 //Not doing this because it causes a runtime error
    130                 //int numEmber2s = abs(vRandom.x)*MAX_EMBER_2S;
    131         for(int i=0; i<NUM_EMBER_2S; i++)
    132         {
    133             vRandom = normalize( RandomDir( Type, globalTime, randomTex) );
    134             gl_Position.xyz = Pos + Vel*elapsedTime;
    135             outputVel = Vel + vRandom*10.0;
    136             outputTimer = P_EMBER2LIFE + 0.4*vRandom.x;
    137             outputType = PT_EMBER2;
    138             EmitVertex();//(outputPos : POSITION, outputVel : TEXCOORD2, outputTimer : TEXCOORD0, outputType : TEXCOORD1);
    139         }
    140        
    141     }
    142     else
    143     {
    144         GSGenericHandler(Pos, Vel, Timer, Type, elapsedTime, frameGravity );
    145     }
    146 }
    147 
    148 //
    149 // Ember1 and Ember3 type particle handler
    150 //
    151 void GSEmber1Handler( vec3 Pos, vec3 Vel, float Timer, float Type,
    152                                                 float elapsedTime,
    153                                                 vec3 frameGravity)
    154 {
    155     if(Timer > 0)
    156     {
    157         GSGenericHandler(Pos, Vel, Timer, Type, elapsedTime, frameGravity );
    158     }
    159 }
    160 
    161 //
    162 // Ember2 type particle handler
    163 //
    164 void GSEmber2Handler( vec3 Pos, vec3 Vel, float Timer, float Type,
    165                                                 float elapsedTime,
    166                                                 float globalTime,
    167                                                 sampler1D randomTex,
    168                                                 vec3 frameGravity)
    169 {
    170     if(Timer <= 0)
    171     {
    172                 vec3 outputPos;
    173                 vec3 outputVel;
    174                 float outputTimer;
    175                 float outputType;
    176    
    177         //time to emit a series of new Ember3s 
    178         for(int i=0; i<NUM_EMBER_3S; i++)
    179         {
    180             gl_Position.xyz = Pos + Vel*elapsedTime;
    181             outputVel = Vel + normalize( RandomDir( Type + i, globalTime, randomTex ) )*10.0;
    182             outputTimer = P_EMBER3LIFE;
    183             outputType = PT_EMBER3;
     138            vRandom = normalize(RandomDir(Type + i, globalTime, randomTex));
     139            oPos = Pos + Vel * elapsedTime;
     140            oUv2 = Vel + vRandom * 15.0;
     141            oUv0 = P_EMBER1LIFE;
     142            oUv1 = PT_EMBER1;
    184143            EmitVertex();
    185144        }
     145
     146        // Find out how many Ember2s to emit.
     147        // Not doing this because it causes a runtime error.
     148        //int numEmber2s = abs(vRandom.x)*MAX_EMBER_2S;
     149        for (int i = 0; i < NUM_EMBER_2S; i++)
     150        {
     151            vRandom = normalize(RandomDir(Type, globalTime, randomTex));
     152            oPos = Pos + Vel * elapsedTime;
     153            oUv2 = Vel + vRandom * 10.0;
     154            oUv0 = P_EMBER2LIFE + 0.4 * vRandom.x;
     155            oUv1 = PT_EMBER2;
     156            EmitVertex();
     157        }
     158
    186159    }
    187160    else
    188161    {
    189          GSGenericHandler(Pos, Vel, Timer, Type, elapsedTime, frameGravity );
     162        GSGenericHandler(Pos, Vel, Timer, Type, elapsedTime, frameGravity);
     163    }
     164}
     165
     166//
     167// Ember1 and Ember3 type particle handler.
     168//
     169void GSEmber1Handler( vec3 Pos, vec3 Vel, float Timer, float Type,
     170                      float elapsedTime,
     171                      vec3 frameGravity)
     172{
     173    if (Timer > 0)
     174    {
     175        GSGenericHandler(Pos, Vel, Timer, Type, elapsedTime, frameGravity);
     176    }
     177}
     178
     179//
     180// Ember2 type particle handler.
     181//
     182void GSEmber2Handler( vec3 Pos, vec3 Vel, float Timer, float Type,
     183                      float elapsedTime,
     184                      float globalTime,
     185                      sampler1D randomTex,
     186                      vec3 frameGravity)
     187{
     188    if (Timer <= 0)
     189    {
     190        // Time to emit a series of new Ember3's.
     191        for (int i = 0; i < NUM_EMBER_3S; i++)
     192        {
     193            oPos = Pos + Vel * elapsedTime;
     194            oUv2 = Vel + normalize(RandomDir(Type + i, globalTime, randomTex)) * 10.0;
     195            oUv0 = P_EMBER3LIFE;
     196            oUv1 = PT_EMBER3;
     197            EmitVertex();
     198        }
     199    }
     200    else
     201    {
     202        GSGenericHandler(Pos, Vel, Timer, Type, elapsedTime, frameGravity);
    190203    }
    191204}
     
    193206void main()
    194207{
    195         if( FireworkData[0].Type == PT_LAUNCHER )
    196         GSLauncherHandler( FireworkData[0].Pos.xyz, FireworkData[0].Vel, FireworkData[0].Timer, FireworkData[0].Type,
    197                                                         elapsedTime, globalTime, randomTex, secondsPerFirework);
    198         else if ( FireworkData[0].Type == PT_SHELL )
    199         GSShellHandler( FireworkData[0].Pos.xyz, FireworkData[0].Vel, FireworkData[0].Timer, FireworkData[0].Type,
    200                                                         elapsedTime, globalTime, randomTex, frameGravity);
    201         else if ( FireworkData[0].Type == PT_EMBER1 ||
    202               FireworkData[0].Type == PT_EMBER3 )
    203         GSEmber1Handler( FireworkData[0].Pos.xyz, FireworkData[0].Vel, FireworkData[0].Timer, FireworkData[0].Type,
    204                                                         elapsedTime, frameGravity);
    205     else if( FireworkData[0].Type == PT_EMBER2 )
    206         GSEmber2Handler( FireworkData[0].Pos.xyz, FireworkData[0].Vel, FireworkData[0].Timer, FireworkData[0].Type,
    207                                                         elapsedTime, globalTime, randomTex, frameGravity);
    208     colour = vec4(1.0,1.0,0.0,1.0);
    209         EndPrimitive();
    210 }
     208    if (FireworkData[0].Type == PT_LAUNCHER)
     209        GSLauncherHandler(FireworkData[0].Pos.xyz, FireworkData[0].Vel, FireworkData[0].Timer, FireworkData[0].Type,
     210                           elapsedTime, globalTime, randomTexture, secondsPerFirework);
     211    else if (FireworkData[0].Type == PT_SHELL)
     212        GSShellHandler(FireworkData[0].Pos.xyz, FireworkData[0].Vel, FireworkData[0].Timer, FireworkData[0].Type,
     213                        elapsedTime, globalTime, randomTexture, frameGravity);
     214    else if (FireworkData[0].Type == PT_EMBER1 ||
     215             FireworkData[0].Type == PT_EMBER3)
     216        GSEmber1Handler(FireworkData[0].Pos.xyz, FireworkData[0].Vel, FireworkData[0].Timer, FireworkData[0].Type,
     217                         elapsedTime, frameGravity);
     218    else if (FireworkData[0].Type == PT_EMBER2)
     219        GSEmber2Handler(FireworkData[0].Pos.xyz, FireworkData[0].Vel, FireworkData[0].Timer, FireworkData[0].Type,
     220                         elapsedTime, globalTime, randomTexture, frameGravity);
     221    EndPrimitive();
     222
     223    // // gl_Position.xyz = FireworkData[0].Pos;// + FireworkData[0].Vel * elapsedTime;
     224    // // gl_Position.w = 1;
     225    // gl_Position = FireworkData[0].Pos + 1;// + FireworkData[0].Vel * elapsedTime;
     226    // // gl_Position = Pos[0];// + FireworkData[0].Vel * elapsedTime;
     227    // //gl_Position = vec4(10, 10, 10, 1);
     228    // // oUv0 = P_SHELLLIFE + 0.5;
     229    // oUv0 = FireworkData[0].Timer;
     230    // // oUv0 = Timer[0];
     231    // oUv1 = FireworkData[0].Type;
     232    // // oUv1 = Type[0];
     233    // oUv2 = FireworkData[0].Vel;
     234    // // oUv2 = Vel[0];
     235    // //oUv2 = vec3(4, 5, 35.0);
     236    // EmitVertex();
     237    // EndPrimitive();
     238    // // // gl_Position = vec4(10, 20, 30, 1);
     239    // gl_Position = vec3(10, 20, 30);
     240    // oUv0 = P_EMBER3LIFE;
     241    // oUv1 = PT_SHELL;
     242    // oUv2 = vec3(40, 50, 60);
     243    // EmitVertex();
     244    // EndPrimitive();
     245}
  • data/branches/Shader_HS18/programs/Example/GLSL150/ParticleGS_GenerateVS.glsl

    r12083 r12091  
    11#version 150
    22
    3 in vec4 vertex;
    4 uniform float inTimer;
    5 uniform float inType;
    6 uniform vec3 inVelocity;
     3in vec3 vertex;
     4in float uv0; // Timer
     5in float uv1; // Type
     6in vec3 uv2;  // Velocity
     7// in float inTimer;
     8// in float inType;
     9// in vec3 inVelocity;
     10
    711
    812out block {
    9         vec4    Pos;
    10         float   Timer;
    11     float       Type;
    12         vec3    Vel;
     13    vec3 Pos;
     14    float Timer;
     15    float Type;
     16    vec3 Vel;
    1317} FireworkData;
     18
     19// out vec3 Pos;
     20// out float Timer;
     21// out float Type;
     22// out vec3 Vel;
    1423
    1524//The vertex shader that prepares the fireworks for display
    1625void main()
    1726{
    18         FireworkData.Pos = vertex;
    19         FireworkData.Timer = inTimer;
    20         FireworkData.Type = inType;
    21         FireworkData.Vel = inVelocity;
     27    FireworkData.Pos  = vertex;
     28    FireworkData.Timer = uv0;
     29    FireworkData.Type = uv1;
     30    FireworkData.Vel = uv2;
     31    // Pos  = vertex;
     32    // Timer = uv0;
     33    // Type = uv1;
     34    // Vel = uv2;
     35
     36    // FireworkData.Pos = vertex;
     37    // FireworkData.Timer = 1;
     38    // FireworkData.Type = 8;
     39    // FireworkData.Vel = vec3(3, 3, 3);
    2240}
  • data/branches/Shader_HS18/programs/Example/GLSL150/PosterizeFP.glsl

    r12083 r12091  
    77void main()
    88{
    9         float nColors = 8.0;
    10         float gamma = 0.6;
     9    float nColors = 8.0;
     10    float gamma = 0.6;
    1111
    12         vec4 texCol = vec4(texture(RT, oUv0));
    13         vec3 tc = texCol.xyz;
    14         tc = pow(tc, vec3(gamma));
    15         tc = tc * nColors;
    16         tc = floor(tc);
    17         tc = tc / nColors;
    18         tc = pow(tc, vec3(1.0/gamma));
    19         fragColour = vec4(tc, texCol.w);
     12    vec4 texCol = vec4(texture(RT, oUv0));
     13    vec3 tc = texCol.xyz;
     14    tc = pow(tc, vec3(gamma));
     15    tc = tc * nColors;
     16    tc = floor(tc);
     17    tc = tc / nColors;
     18    tc = pow(tc, vec3(1.0 / gamma));
     19    fragColour = vec4(tc, texCol.w);
    2020}
  • data/branches/Shader_HS18/programs/Example/GLSL150/StdQuad_vp.glsl

    r12083 r12091  
    22
    33in vec4 vertex;
    4 in vec2 uv0;
     4// in vec2 uv0;
    55uniform mat4 worldViewProj;
    66
    77out vec2 oUv0;
    88
    9 void main()                   
     9void main()
    1010{
    11         gl_Position = worldViewProj * vertex;
    12                
    13         oUv0 = uv0;
     11    gl_Position = worldViewProj * vertex;
     12
     13    // oUv0 = uv0;
     14
     15    vec2 inPos = sign(vertex.xy);
     16
     17    oUv0 = (vec2(inPos.x, -inPos.y) + 1.0) * 0.5;
    1418}
    15 
  • 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}
  • data/branches/Shader_HS18/programs/Example/GLSL150/mrttestfp_scene.glsl

    r12083 r12091  
    1 #version 150
     1#version 130
    22
    33// Need to enable the draw buffers extension
  • data/branches/Shader_HS18/resources.oxr

    r12085 r12091  
    1818   
    1919    <ResourceLocation path = "programs"         />
    20     <ResourceLocation path = "programs/Cg"      />
    2120    <ResourceLocation path = "programs/GLSL"    />
    2221    <ResourceLocation path = "programs/Example" />
    23     <ResourceLocation path = "programs/Example/Cg"      />
    2422    <ResourceLocation path = "programs/Example/GLSL"    />
     23    <ResourceLocation path = "programs/Example/GLSL120" />
    2524    <ResourceLocation path = "programs/Example/GLSL150" />
     25    <ResourceLocation path = "programs/Example/GLSL400" />
     26    <ResourceLocation path = "programs/Example/GLSLES" />
     27
    2628
    2729    <ResourceLocation path = "gui/fonts"        />
Note: See TracChangeset for help on using the changeset viewer.