Changeset 12091 for data/branches/Shader_HS18
- Timestamp:
- Nov 9, 2018, 1:06:05 PM (6 years ago)
- 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 // Basic3 //------------------------4 5 //---------------------------------------------------6 // This file includes a number of basic GPU programs7 // for use in many materials.8 //---------------------------------------------------9 10 11 // A really basic ambient pass program, support for one texture coordinate set12 vertex_program AmbientOneTextureCg cg13 {14 source Example_Basic.cg15 entry_point ambientOneTexture_vp16 profiles vs_1_1 arbvp117 18 default_params19 {20 param_named_auto worldViewProj worldviewproj_matrix21 param_named_auto ambient ambient_light_colour22 }23 24 }25 26 vertex_program AmbientOneTextureCgSm4 cg27 {28 source Example_Basic_sm4.cg29 entry_point ambientOneTexture_vp30 profiles vs_4_031 32 default_params33 {34 param_named_auto worldViewProj worldviewproj_matrix35 param_named_auto ambient ambient_light_colour36 }37 38 }39 40 // A really basic ambient pass program, support for one texture coordinate set41 vertex_program AmbientOneTextureHLSL hlsl42 {43 source Example_Basic.hlsl44 entry_point ambientOneTexture_vp45 target vs_4_046 47 default_params48 {49 param_named_auto worldViewProj worldviewproj_matrix50 param_named_auto ambient ambient_light_colour51 }52 }53 // A really basic ambient pass program, support for one texture coordinate set54 vertex_program AmbientOneTextureGLSL glsl55 {56 source AmbientOneTexture.glsl57 }58 59 // A really basic ambient pass program, support for one texture coordinate set60 vertex_program AmbientOneTextureGLSL glsl61 {62 source AmbientOneTexture.glsl63 64 65 default_params66 {67 param_named_auto ambient ambient_light_colour68 param_named_auto worldViewProj worldviewproj_matrix69 }70 }71 72 // A really basic ambient pass program, support for one texture coordinate set73 vertex_program AmbientOneTextureGLSLES glsles74 {75 source AmbientOneTexture.glsles76 77 default_params78 {79 param_named_auto worldViewProj worldviewproj_matrix80 param_named_auto ambient ambient_light_colour81 }82 }83 84 vertex_program AmbientOneTextureWithUVGLSLES glsles85 {86 source AmbientOneTextureWithUV.glsles87 88 default_params89 {90 param_named_auto worldViewProj worldviewproj_matrix91 param_named_auto ambient ambient_light_colour92 }93 }94 95 vertex_program AmbientOneTextureWithUVGLSL glsl96 {97 source AmbientOneTextureWithUV.glsl98 99 100 default_params101 {102 param_named_auto worldViewProj worldviewproj_matrix103 param_named_auto ambient ambient_light_colour104 }105 }106 107 vertex_program AmbientOneTextureWithUV unified108 {109 delegate AmbientOneTextureWithUVGLSL110 delegate AmbientOneTextureWithUVGLSLES111 delegate AmbientOneTextureHLSL112 delegate AmbientOneTextureCg113 delegate AmbientOneTextureCgSm4114 }115 116 vertex_program AmbientOneTextureUnified unified117 {118 delegate AmbientOneTextureGLSL119 delegate AmbientOneTextureGLSLES120 delegate AmbientOneTextureHLSL121 delegate AmbientOneTextureCg122 delegate AmbientOneTextureCgSm4123 }124 125 fragment_program DiffuseOneTextureCg cg126 {127 source Example_Basic.cg128 entry_point diffuseOneTexture_fp129 profiles ps_2_0 arbfp1130 }131 132 fragment_program DiffuseOneTextureGLSLES glsles133 {134 source DiffuseOneTexture.glsles135 default_params136 {137 param_named texMap int 0138 }139 }140 141 fragment_program DiffuseOneTextureGLSL glsl142 {143 source DiffuseOneTexture.glsl144 default_params145 {146 param_named texMap int 0147 }148 }149 150 fragment_program DiffuseOneTexture unified151 {152 delegate DiffuseOneTextureGLSL153 delegate DiffuseOneTextureGLSLES154 delegate DiffuseOneTextureCg155 }156 157 // A really basic ambient pass program, support for one texture coordinate set158 fragment_program PassthroughFP unified159 {160 delegate PassthroughFpGLSL161 delegate PassthroughFpGLSLES162 delegate PassthroughFpCgSm4163 delegate PassthroughFpCg164 }165 166 // A really basic ambient pass program, support for one texture coordinate set167 fragment_program PassthroughFpCgSm4 cg168 {169 entry_point main170 source PassthroughFP_sm4.cg171 profiles ps_4_0172 }173 174 fragment_program PassthroughFpCg cg175 {176 entry_point mainCg177 source PassthroughFP.cg178 profiles ps_2_0 arbfp1179 }180 181 // A really basic ambient pass program, support for one texture coordinate set182 fragment_program PassthroughFpCgSm4ForAmbientOneTexture cg183 {184 entry_point mainForAmbientOneTexture185 source PassthroughFP_sm4.cg186 profiles ps_4_0187 }188 189 190 // A really basic ambient pass program, support for one texture coordinate set191 fragment_program PassthroughFpGLSLES glsles192 {193 source PassthroughFP.glsles194 }195 196 fragment_program PassthroughFpGLSL glsl197 {198 source PassthroughFP.glsl199 }200 201 //------------------------202 // Bump mapping section203 //------------------------204 205 // Bump map vertex program, support for this is required206 vertex_program Lava/BumpMapVPCg cg207 {208 source Example_BumpMapping.cg209 entry_point main_vp210 profiles vs_4_0 vs_1_1 arbvp1211 }212 213 vertex_program Lava/BumpMapVPGLSLES glsles214 {215 source Example_BumpMappingVp.glsles216 profiles glsles217 }218 219 vertex_program Lava/BumpMapVPGLSL glsl220 {221 source Example_BumpMappingVp.glsl222 }223 224 vertex_program Lava/BumpMapVP unified225 {226 delegate Lava/BumpMapVPGLSL227 delegate Lava/BumpMapVPGLSLES228 delegate Lava/BumpMapVPCg229 }230 231 // Bump map vertex program, with tangent parity support for this is required232 vertex_program Lava/BumpMapVPTangentParityCg cg233 {234 source Example_BumpMapping.cg235 entry_point main_vp236 profiles vs_1_1 arbvp1237 compile_arguments -DTANGENTS_HAVE_PARITY=1238 }239 240 // Bump map vertex program, with tangent parity support for this is required241 vertex_program Lava/BumpMapVPTangentParityGLSLES glsles242 {243 source BumpMapVPTangentParity.glsles244 }245 246 vertex_program Lava/BumpMapVPTangentParityGLSL glsl247 {248 source BumpMapVPTangentParity.glsl249 default_params250 {251 param_named_auto lightDiffuse light_diffuse_colour 0252 }253 }254 255 vertex_program Lava/BumpMapVPTangentParity unified256 {257 delegate Lava/BumpMapVPTangentParityGLSL258 delegate Lava/BumpMapVPTangentParityGLSLES259 delegate Lava/BumpMapVPTangentParityCg260 }261 262 // Bump map fragment program, support for this is optional263 fragment_program Lava/BumpMapFPCg cg264 {265 source Example_BumpMapping.cg266 entry_point main_fp267 profiles ps_4_0 ps_2_0 arbfp1 fp20268 }269 270 fragment_program Lava/BumpMapFPGLSLES glsles271 {272 source Example_BumpMappingFp.glsles273 profiles glsles274 default_params275 {276 // assign samplers as required by GLSL277 param_named normalMap int 0278 }279 }280 281 fragment_program Lava/BumpMapFPGLSL glsl282 {283 source Example_BumpMappingFp.glsl284 default_params285 {286 // assign samplers as required by GLSL287 param_named normalMap int 0288 }289 }290 291 fragment_program Lava/BumpMapFP unified292 {293 delegate Lava/BumpMapFPGLSL294 delegate Lava/BumpMapFPGLSLES295 delegate Lava/BumpMapFPCg296 }297 298 // Bump map vertex program shadow receiver299 vertex_program Lava/BumpMapVPShadowRcvCg cg300 {301 source Example_BumpMapping.cg302 entry_point main_shadowreceiver_vp303 profiles vs_1_1 arbvp1304 }305 306 // Bump map vertex program shadow receiver307 vertex_program Lava/BumpMapVPShadowRcvGLSLES glsles308 {309 source Example_BumpMappingShadowRcvVp.glsles310 profiles glsles311 }312 313 vertex_program Lava/BumpMapVPShadowRcvGLSL glsl314 {315 source Example_BumpMappingShadowRcvVp.glsl316 317 }318 319 vertex_program Lava/BumpMapVPShadowRcv unified320 {321 delegate Lava/BumpMapVPShadowRcvGLSL322 delegate Lava/BumpMapVPShadowRcvGLSLES323 delegate Lava/BumpMapVPShadowRcvCg324 }325 326 // Bump map fragment program shadow receiver, support for this is optional327 fragment_program Lava/BumpMapFPShadowRcvCg cg328 {329 source Example_BumpMapping.cg330 entry_point main_shadowreceiver_fp331 profiles ps_2_0 arbfp1 fp20332 }333 334 // Bump map fragment program shadow receiver, support for this is optional335 fragment_program Lava/BumpMapFPShadowRcvGLSLES glsles336 {337 source Example_BumpMappingShadowRcvFp.glsles338 profiles glsles339 default_params340 {341 // assign samplers as required by GLSL342 param_named shadowMap int 0343 param_named normalMap int 1344 }345 }346 347 fragment_program Lava/BumpMapFPShadowRcvGLSL glsl348 {349 source Example_BumpMappingShadowRcvFp.glsl350 default_params351 {352 // assign samplers as required by GLSL353 param_named shadowMap int 0354 param_named normalMap int 1355 }356 }357 358 fragment_program Lava/BumpMapFPShadowRcv unified359 {360 delegate Lava/BumpMapFPShadowRcvGLSL361 delegate Lava/BumpMapFPShadowRcvGLSLES362 delegate Lava/BumpMapFPShadowRcvCg363 }364 365 // Bump map with specular vertex program, support for this is required366 vertex_program Lava/BumpMapVPSpecularCg cg367 {368 source Example_BumpMapping.cg369 entry_point specular_vp370 profiles vs_4_0 vs_1_1 arbvp1371 }372 373 // Bump map with specular vertex program, support for this is required374 vertex_program Lava/BumpMapVPSpecularGLSLES glsles375 {376 source Example_BumpMappingSpecularVp.glsles377 profiles glsles378 }379 380 vertex_program Lava/BumpMapVPSpecularGLSL glsl381 {382 source Example_BumpMappingSpecularVp.glsl383 }384 385 vertex_program Lava/BumpMapVPSpecular unified386 {387 delegate Lava/BumpMapVPSpecularGLSL388 delegate Lava/BumpMapVPSpecularGLSLES389 delegate Lava/BumpMapVPSpecularCg390 }391 392 // Bump map fragment program, support for this is optional393 fragment_program Lava/BumpMapFPSpecularCg cg394 {395 source Example_BumpMapping.cg396 entry_point specular_fp397 profiles ps_4_0 ps_2_0 arbfp1 fp20398 }399 400 // Bump map fragment program, support for this is optional401 fragment_program Lava/BumpMapFPSpecularGLSLES glsles402 {403 source Example_BumpMappingSpecularFp.glsles404 profiles glsles405 default_params406 {407 // assign samplers as required by GLSL408 param_named normalMap int 0409 }410 }411 412 fragment_program Lava/BumpMapFPSpecularGLSL glsl413 {414 source Example_BumpMappingSpecularFp.glsl415 default_params416 {417 // assign samplers as required by GLSL418 param_named normalMap int 0419 }420 }421 422 fragment_program Lava/BumpMapFPSpecular unified423 {424 delegate Lava/BumpMapFPSpecularGLSL425 delegate Lava/BumpMapFPSpecularGLSLES426 delegate Lava/BumpMapFPSpecularCg427 }428 429 //------------------------430 // Material431 //------------------------432 433 1 // Any number of lights, diffuse 434 2 material Cube_Lava_Normal 435 3 { 436 437 // This is the preferred technique which uses both vertex and438 // fragment programs, supports coloured lights439 4 technique 440 5 { … … 444 9 // base colours, not needed for rendering, but as information 445 10 // 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 461 12 } 462 13 // Now do the lighting pass … … 464 15 pass perlight 465 16 { 17 // do this for each light 18 iteration once_per_light 19 scene_blend add 20 466 21 // base colours, not needed for rendering, but as information 467 22 // 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 475 24 476 25 // Vertex program reference 477 vertex_program_ref Lava/BumpMapVP26 vertex_program_ref Examples/BumpMapVP 478 27 { 479 28 param_named_auto lightPosition light_position_object_space 0 … … 482 31 483 32 // Fragment program 484 fragment_program_ref Lava/BumpMapFP33 fragment_program_ref Examples/BumpMapFP 485 34 { 486 35 param_named_auto lightDiffuse light_diffuse_colour 0 … … 488 37 489 38 // texture shadow receiver program 490 shadow_receiver_vertex_program_ref Lava/BumpMapVPShadowRcv39 shadow_receiver_vertex_program_ref Examples/BumpMapVPShadowRcv 491 40 { 492 41 param_named_auto lightPosition light_position_object_space 0 … … 496 45 } 497 46 // Additive texture shadow receiver program 498 shadow_receiver_fragment_program_ref Lava/BumpMapFPShadowRcv47 shadow_receiver_fragment_program_ref Examples/BumpMapFPShadowRcv 499 48 { 500 49 param_named_auto lightDiffuse light_diffuse_colour 0 … … 505 54 { 506 55 texture Cube_Lava_NORM.jpg 507 tex_address_mode wrap508 scale 1.0 1.0509 56 colour_op replace 510 57 } 511 512 58 } 513 59 … … 515 61 pass decal 516 62 { 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 519 64 lighting off 520 // Really basic vertex program521 // NB we don't use fixed function here because GL does not like522 // mixing fixed function and vertex programs, depth fighting can523 // be an issue524 vertex_program_ref AmbientOneTextureUnified525 {526 param_named_auto worldViewProj worldviewproj_matrix527 param_named ambient float4 1 1 1 1528 }529 fragment_program_ref PassthroughFP530 {531 }532 533 65 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 576 67 } 577 68 } 578 579 580 69 } -
data/branches/Shader_HS18/materials/ToonShader.material
r7708 r12091 1 1 vertex_program toonvs glsl 2 2 { 3 source ToonShader_vs. vert3 source ToonShader_vs.glsl 4 4 } 5 5 6 6 fragment_program Toonps glsl 7 7 { 8 source ToonShader_ps. frag8 source ToonShader_ps.glsl 9 9 } 10 10 -
data/branches/Shader_HS18/programs/Example/GLSL/DepthShadowmapNormalMapReceiverFp.glsl
r12083 r12091 31 31 vec4 shadowUV = oUv; 32 32 // point on shadowmap 33 shadowUV .xy = shadowUV.xy/ shadowUV.w;33 shadowUV = shadowUV / shadowUV.w; 34 34 float centerdepth = texture2D(shadowMap, shadowUV.xy).x; 35 35 -
data/branches/Shader_HS18/programs/Example/GLSL/DepthShadowmapReceiverFp.glsl
r12083 r12091 15 15 vec4 shadowUV = oUv; 16 16 // point on shadowmap 17 shadowUV .xy = shadowUV.xy/ shadowUV.w;17 shadowUV = shadowUV / shadowUV.w; 18 18 float centerdepth = texture2D(shadowMap, shadowUV.xy).x; 19 19 -
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 3 3 4 uniform vec4 origColo r;5 uniform vec4 cloneColo r;4 uniform vec4 origColour; 5 uniform vec4 cloneColour; 6 6 7 void main(void) 8 { 7 void 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 9 19 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(); 12 28 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(); 40 37 } -
data/branches/Shader_HS18/programs/Example/GLSL150/Blur0_vs.glsl
r12083 r12091 1 1 #version 150 2 2 3 in vec4 vertex; 4 // in vec2 uv0; 3 5 out vec2 texCoord[5]; 4 in vec4 vertex;5 6 6 uniform mat4 worldViewProj; 7 in vec2 uv0; 7 // uniform mat4 worldViewProj; 8 8 9 void main() 9 void main() 10 10 { 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; 20 25 } -
data/branches/Shader_HS18/programs/Example/GLSL150/Blur1_vs.glsl
r12083 r12091 1 1 #version 150 2 2 3 uniform mat4 worldViewProj; 3 in vec4 vertex; 4 // in vec2 uv0; 5 out vec2 texCoord[5]; 4 6 5 out vec2 texCoord[5]; 6 in vec4 vertex; 7 in vec2 uv0; 7 // uniform mat4 worldViewProj; 8 8 9 9 void main() 10 10 { 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; 20 25 } -
data/branches/Shader_HS18/programs/Example/GLSL150/Combine_fp.glsl
r12083 r12091 10 10 void main() 11 11 { 12 vec4 render = texture(RT, oUv0);13 vec4 sum = texture(Sum, oUv0);12 vec4 render = texture(RT, oUv0); 13 vec4 sum = texture(Sum, oUv0); 14 14 15 fragColour = mix(render, sum, blur);15 fragColour = mix(render, sum, blur); 16 16 } -
data/branches/Shader_HS18/programs/Example/GLSL150/DepthShadowObjectFp.glsl
r12083 r12091 1 1 #version 150 2 /* Copyright Torus Knot Software Ltd 2000-201 32 /* Copyright Torus Knot Software Ltd 2000-2014 3 3 4 4 Permission is hereby granted, free of charge, to any person obtaining a copy -
data/branches/Shader_HS18/programs/Example/GLSL150/DepthShadowObjectVp.glsl
r12083 r12091 1 1 #version 150 2 /* Copyright Torus Knot Software Ltd 2000-201 32 /* Copyright Torus Knot Software Ltd 2000-2014 3 3 4 4 Permission is hereby granted, free of charge, to any person obtaining a copy -
data/branches/Shader_HS18/programs/Example/GLSL150/HardwareMorphAnimationVp.glsl
r12083 r12091 6 6 in vec4 uv1; // pos2 7 7 8 out vec2 oUv;8 // out vec2 oUv; 9 9 out vec4 colour; 10 10 … … 16 16 { 17 17 // 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); 19 19 20 20 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); 23 23 } -
data/branches/Shader_HS18/programs/Example/GLSL150/HardwareMorphAnimationWithNormalsVp.glsl
r12083 r12091 7 7 in vec4 uv2; // normal2 8 8 9 out vec2 oUv;10 9 out vec4 colour; 10 // out vec2 oUv; 11 11 12 12 uniform mat4 worldViewProj; … … 18 18 void main() 19 19 { 20 21 20 // interpolate position 21 vec4 posinterp = vec4(vertex.xyz + anim_t.x*(uv1.xyz - vertex.xyz), 1.0); 22 22 23 23 // nlerp normal 24 25 24 vec3 ninterp = normal + anim_t.x*(uv2.xyz - normal); 25 ninterp = normalize(ninterp); 26 26 27 28 27 gl_Position = worldViewProj * posinterp; 28 // oUv = uv0.xy; 29 29 30 31 30 vec3 lightDir = normalize( 31 objSpaceLightPos.xyz - (posinterp.xyz * objSpaceLightPos.w)); 32 32 33 34 35 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); 36 36 } -
data/branches/Shader_HS18/programs/Example/GLSL150/HardwarePoseAnimationVp.glsl
r12083 r12091 16 16 void main() 17 17 { 18 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); 20 20 21 22 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); 24 24 } 25 -
data/branches/Shader_HS18/programs/Example/GLSL150/HardwarePoseAnimationWithNormalsVp.glsl
r12083 r12091 9 9 in vec4 uv4; // pose2norm 10 10 11 out vec2 oUv;11 // out vec2 oUv; 12 12 out vec4 colour; 13 13 … … 20 20 void main() 21 21 { 22 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); 24 24 25 25 // 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; 29 28 30 31 32 33 34 ninterp = ninterp + (normal * remainder);35 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); 36 35 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; 42 38 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); 46 45 } -
data/branches/Shader_HS18/programs/Example/GLSL150/HeatBlurFp.glsl
r12083 r12091 9 9 void main() 10 10 { 11 int i;12 vec4 tmpOutColor;13 float diffuseGlowFactor;14 vec2 offsets[4];15 /*16 17 18 19 20 21 */22 /*23 24 25 26 27 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 /* 30 30 -0.326212, -0.405805, 31 31 -0.840144, -0.073580, 32 32 -0.695914, 0.457137, 33 33 -0.203345, 0.620716 34 */34 */ 35 35 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); 40 40 41 tmpOutColor = texture( Input, uv );// UV coords are in image space41 tmpOutColor = texture( Input, uv ); // UV coords are in image space 42 42 43 // calculate glow amount44 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 )); 45 45 46 // basic blur filter47 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 } 50 50 51 tmpOutColor *= 0.25;51 tmpOutColor *= 0.25; 52 52 53 // TIPS (old-skool strikes again!)54 // Pay attention here! If you use the "out float4 outColor" directly55 // in your steps while creating the output color (like you remove56 // 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, and59 // 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; 61 61 } -
data/branches/Shader_HS18/programs/Example/GLSL150/LightToHeatFp.glsl
r12083 r12091 9 9 uniform sampler2D HeatLookup; 10 10 11 in vec4 diffuse;11 // in vec4 diffuse; 12 12 in vec2 uv; 13 13 out vec4 fragColour; … … 15 15 void main() 16 16 { 17 float depth, heat, interference;17 float depth, heat, interference; 18 18 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; 22 22 23 heat = (depth * heatBiasScale.y);23 heat = (depth * heatBiasScale.y); 24 24 25 //if (depth > 0)26 {27 28 29 30 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 } 32 32 33 // Clamp UVs34 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 ) ); 36 36 } -
data/branches/Shader_HS18/programs/Example/GLSL150/OldTV.glsl
r12083 r12091 20 20 void main() 21 21 { 22 // Define a frame shape23 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); 25 25 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; 28 28 29 // Some signed noise for the distortion effect30 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; 31 31 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 image36 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); 37 37 38 // ... and finally distort39 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); 42 42 43 // Combine frame, distorted image and interference44 fragColour = frame * (interference * rand + image);43 // Combine frame, distorted image and interference 44 fragColour = frame * (interference * rand + image); 45 45 } 46 -
data/branches/Shader_HS18/programs/Example/GLSL150/ParticleGS_DisplayGS.glsl
r12083 r12091 2 2 3 3 in block { 4 vec3pos;5 vec4 color;6 floatradius;7 } Colo redFirework[];4 vec3 pos; 5 vec4 colour; 6 float radius; 7 } ColouredFirework[]; 8 8 9 9 out block { 10 vec4pos;11 vec4 color;12 vec2texcoord;10 vec4 pos; 11 vec4 colour; 12 vec2 texcoord; 13 13 } Firework; 14 14 … … 22 22 void main() 23 23 { 24 24 vec3 g_positions[4] = vec3[4](vec3(-1, 1, 0), vec3(-1, -1, 0), vec3(1, 1, 0), vec3(1, -1, 0)); 25 25 vec2 g_texcoords[4] = vec2[4](vec2(0, 1), vec2(1, 1), vec2(0, 0), vec2(1, 0)); 26 26 … … 28 28 // Emit two new triangles 29 29 // 30 for (int i=0; i<4; i++)30 for (int i = 0; i < 4; i++) 31 31 { 32 vec3 position = -g_positions[i] * ColoredFirework[0].radius;33 position = mat3(inverseView) * position + Colo redFirework[0].pos;32 vec3 position = -g_positions[i] * ColouredFirework[0].radius; 33 position = mat3(inverseView) * position + ColouredFirework[0].pos; 34 34 gl_Position = worldViewProj * vec4(position, 1.0); 35 35 36 36 Firework.pos = gl_Position; 37 Firework.colo r = ColoredFirework[0].color;37 Firework.colour = ColouredFirework[0].colour; 38 38 Firework.texcoord = g_texcoords[i]; 39 39 EmitVertex(); -
data/branches/Shader_HS18/programs/Example/GLSL150/ParticleGS_DisplayVS.glsl
r12083 r12091 4 4 // Explanation of different particle types 5 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 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 11 16 #define P_SHELLLIFE 3.0 12 17 #define P_EMBER1LIFE 2.5 … … 14 19 #define P_EMBER3LIFE 2.0 15 20 16 in vec4 position; 17 uniform float inTimer; 18 uniform float inType; 19 uniform vec3 inVelocity; 21 in vec3 position; 22 // timer 23 in float uv0; 24 // type 25 in float uv1; 26 // velocity 27 in vec3 uv2; 20 28 21 29 out block { 22 vec3pos;23 vec4 color;24 floatradius;25 } Colo redFirework;30 vec3 pos; 31 vec4 colour; 32 float radius; 33 } ColouredFirework; 26 34 27 35 uniform mat4 worldViewProj; … … 30 38 void main() 31 39 { 40 float inTimer = uv0; 41 float inType = uv1; 42 32 43 // 33 44 // Pass the point through 34 45 // 35 Colo redFirework.pos = position.xyz; //Multiply by world matrix?36 Colo redFirework.radius = 1.5;46 ColouredFirework.pos = position; // Multiply by world matrix? 47 ColouredFirework.radius = 1.5; 37 48 38 49 // 39 // calculate the colo r50 // calculate the colour 40 51 // 41 if ( inType == PT_LAUNCHER)52 if (inType == PT_LAUNCHER) 42 53 { 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; 45 57 } 46 else if ( inType == PT_SHELL)58 else if (inType == PT_SHELL) 47 59 { 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; 50 63 } 51 else if ( inType == PT_EMBER1)64 else if (inType == PT_EMBER1) 52 65 { 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); 55 69 } 56 else if ( inType == PT_EMBER2)70 else if (inType == PT_EMBER2) 57 71 { 58 ColoredFirework.color = vec4(1,0.1,1,1); 72 // fuschia 73 ColouredFirework.colour = vec4(1, 0.1, 1, 1); 59 74 } 60 else if ( inType == PT_EMBER3)75 else if (inType == PT_EMBER3) 61 76 { 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); 64 80 } 65 81 } -
data/branches/Shader_HS18/programs/Example/GLSL150/ParticleGS_GenerateGS.glsl
r12083 r12091 2 2 3 3 // 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 11 16 #define P_SHELLLIFE 3.0 12 17 #define P_EMBER1LIFE 2.5 … … 14 19 #define P_EMBER3LIFE 2.0 15 20 16 // These two were originally shader params, but they caused runtime errors21 // These two were originally shader params, but they caused runtime errors. 17 22 #define NUM_EMBER_1S 30 18 23 #define NUM_EMBER_2S 15 19 24 #define NUM_EMBER_3S 10 20 // This one was originally a variant, but this also causes runtime errors25 // This one was originally a variant, but also causes runtime errors. 21 26 //#define MAX_EMBER_2S 15.0 22 27 28 layout(points) in; 29 layout(points, max_vertices = 60) out; 30 23 31 in block { 24 vec4Pos;25 floatTimer;26 float 27 vec3Vel;32 vec3 Pos; 33 float Timer; 34 float Type; 35 vec3 Vel; 28 36 } FireworkData[]; 29 37 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; 44 out vec3 oPos; 45 out float oUv0; // Timer 46 out float oUv1; // Type 47 out vec3 oUv2; // Velocity 48 49 uniform sampler1D randomTexture; 34 50 uniform vec3 frameGravity; 35 51 uniform float globalTime; 36 52 uniform float elapsedTime; 37 53 uniform float secondsPerFirework; 38 out vec4 colour; 54 39 55 // 40 56 // Generic particle motion handler 41 57 // 42 43 58 void 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 { 48 62 Vel += frameGravity; 49 63 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 } 54 73 } 55 74 … … 66 85 // Launcher type particle handler 67 86 // 68 void GSLauncherHandler( vec3 Pos, vec3 Vel, float Timer, float Type, 69 float elapsedTime, 70 float globalTime, 71 72 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 timer88 Timer = secondsPerFirework + vRandom.x *0.4;87 void 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; 89 108 } 90 109 else … … 92 111 Timer -= elapsedTime; 93 112 } 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(); 97 120 } 98 121 99 122 // 100 123 // Shell type particle handler 101 // 124 // 102 125 void 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 { 115 133 vec3 vRandom = vec3(0,0,0); 116 117 // time to emit a series of new Ember1s118 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++) 119 137 { 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; 184 143 EmitVertex(); 185 144 } 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 186 159 } 187 160 else 188 161 { 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 // 169 void 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 // 182 void 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); 190 203 } 191 204 } … … 193 206 void main() 194 207 { 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 1 1 #version 150 2 2 3 in vec4 vertex; 4 uniform float inTimer; 5 uniform float inType; 6 uniform vec3 inVelocity; 3 in vec3 vertex; 4 in float uv0; // Timer 5 in float uv1; // Type 6 in vec3 uv2; // Velocity 7 // in float inTimer; 8 // in float inType; 9 // in vec3 inVelocity; 10 7 11 8 12 out block { 9 vec4Pos;10 floatTimer;11 float 12 vec3Vel;13 vec3 Pos; 14 float Timer; 15 float Type; 16 vec3 Vel; 13 17 } FireworkData; 18 19 // out vec3 Pos; 20 // out float Timer; 21 // out float Type; 22 // out vec3 Vel; 14 23 15 24 //The vertex shader that prepares the fireworks for display 16 25 void main() 17 26 { 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); 22 40 } -
data/branches/Shader_HS18/programs/Example/GLSL150/PosterizeFP.glsl
r12083 r12091 7 7 void main() 8 8 { 9 10 9 float nColors = 8.0; 10 float gamma = 0.6; 11 11 12 13 14 15 16 17 18 tc = pow(tc, vec3(1.0/gamma));19 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); 20 20 } -
data/branches/Shader_HS18/programs/Example/GLSL150/StdQuad_vp.glsl
r12083 r12091 2 2 3 3 in vec4 vertex; 4 in vec2 uv0;4 // in vec2 uv0; 5 5 uniform mat4 worldViewProj; 6 6 7 7 out vec2 oUv0; 8 8 9 void main() 9 void main() 10 10 { 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; 14 18 } 15 -
data/branches/Shader_HS18/programs/Example/GLSL150/SwizzleGP.glsl
r12083 r12091 1 1 #version 150 2 2 3 #extension GL_EXT_geometry_shader4 : enable 3 uniform vec4 origColour; 4 uniform vec4 cloneColour; 4 5 5 uniform vec4 origColor; 6 uniform vec4 cloneColor; 6 out vec4 colour; 7 7 8 void main(void) 9 { 8 layout(triangles) in; 9 layout(line_strip, max_vertices = 6) out; 10 10 11 //increment variable 12 int i; 11 void main() 12 { 13 // Pass-through! 14 for (int i = 0; i < gl_in.length(); i++){ 15 gl_Position = gl_in[i].gl_Position; 16 colour = origColour; 17 EmitVertex(); 18 } 19 EndPrimitive(); 13 20 14 ///////////////////////////////////////////////////////////// 15 //This example has two parts 16 // step a) draw the primitive pushed down the pipeline 17 // there are gl_Vertices # of vertices 18 // put the vertex value into gl_Position 19 // use EmitVertex => 'create' a new vertex 20 // use EndPrimitive to signal that you are done creating a primitive! 21 // step b) create a new piece of geometry (I.E. WHY WE ARE USING A GEOMETRY SHADER!) 22 // I just do the same loop, but swizzle the x and y values 23 // result => the line we want to draw, and the same line, but along the other axis 24 25 //Pass-thru! 26 for(i=0; i< gl_VerticesIn; i++){ 27 gl_Position = gl_PositionIn[i]; 28 gl_FrontColor = origColor; 29 EmitVertex(); 30 } 31 EndPrimitive(); 32 //New piece of geometry! We just swizzle the x and y terms 33 for(i=0; i< gl_VerticesIn; i++){ 34 gl_Position = gl_PositionIn[i]; 35 gl_Position.xy = gl_Position.yx; 36 gl_FrontColor = cloneColor; 37 EmitVertex(); 38 } 39 EndPrimitive(); 40 21 // New piece of geometry! We just swizzle the x and y terms. 22 for (int i = 0; i < gl_in.length(); i++){ 23 gl_Position = gl_in[i].gl_Position; 24 gl_Position.xy = gl_Position.yx; 25 colour = cloneColour; 26 EmitVertex(); 27 } 28 EndPrimitive(); 41 29 } -
data/branches/Shader_HS18/programs/Example/GLSL150/mrttestfp_scene.glsl
r12083 r12091 1 #version 1 501 #version 130 2 2 3 3 // Need to enable the draw buffers extension -
data/branches/Shader_HS18/resources.oxr
r12085 r12091 18 18 19 19 <ResourceLocation path = "programs" /> 20 <ResourceLocation path = "programs/Cg" />21 20 <ResourceLocation path = "programs/GLSL" /> 22 21 <ResourceLocation path = "programs/Example" /> 23 <ResourceLocation path = "programs/Example/Cg" />24 22 <ResourceLocation path = "programs/Example/GLSL" /> 23 <ResourceLocation path = "programs/Example/GLSL120" /> 25 24 <ResourceLocation path = "programs/Example/GLSL150" /> 25 <ResourceLocation path = "programs/Example/GLSL400" /> 26 <ResourceLocation path = "programs/Example/GLSLES" /> 27 26 28 27 29 <ResourceLocation path = "gui/fonts" />
Note: See TracChangeset
for help on using the changeset viewer.