[8708] | 1 | /** |
---|
| 2 | * \brief Godrays.cg is a CG (C for Graphics) shader collection to imitate the effects of lightray scattering through post-processing approaches. |
---|
| 3 | * |
---|
| 4 | * \author Markus Wegmann |
---|
| 5 | **/ |
---|
| 6 | |
---|
| 7 | /* |
---|
| 8 | |
---|
| 9 | % Description of my shader. |
---|
| 10 | % Second line of description for my shader. |
---|
| 11 | |
---|
| 12 | keywords: material classic |
---|
| 13 | |
---|
| 14 | date: 20110410 |
---|
| 15 | |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | void sun_shader( |
---|
| 19 | float4 position : POSITION, |
---|
| 20 | float4 normal: NORMAL, |
---|
| 21 | |
---|
| 22 | out float4 oPosition : POSITION, |
---|
| 23 | out float4 oColor : COLOR, |
---|
| 24 | |
---|
| 25 | uniform float4x4 modelViewProj, |
---|
| 26 | uniform float4 sunColor) |
---|
| 27 | { |
---|
| 28 | oPosition = mul(modelViewProj, position); |
---|
| 29 | oColor = 2 * normalize(sunColor); |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | void black_shader( |
---|
| 34 | float4 position : POSITION, |
---|
| 35 | |
---|
| 36 | out float4 oPosition : POSITION, |
---|
| 37 | out float4 oColor: COLOR0, |
---|
| 38 | |
---|
| 39 | uniform float4x4 modelViewProj) |
---|
| 40 | { |
---|
| 41 | oPosition = mul(modelViewProj, position); |
---|
| 42 | oColor = float4 (0, 0, 0, 1); |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | //// Variables //// |
---|
| 47 | ///////////////////////////////////////////////////////////////////////////////////// |
---|
| 48 | |
---|
| 49 | float4 SunLightColor : Specular < |
---|
| 50 | string UIName = "Lamp 0 Color"; |
---|
| 51 | string Object = "Pointlight0"; |
---|
| 52 | string UIWidget = "Color"; |
---|
| 53 | > = {0.3, 0.42, 1, 1}; |
---|
| 54 | |
---|
| 55 | //// UN-TWEAKABLES - AUTOMATICALLY-TRACKED TRANSFORMS //// |
---|
| 56 | |
---|
| 57 | float4x4 WorldITXf : WorldInverseTranspose < string UIWidget="None"; >; |
---|
| 58 | float4x4 WvpXf : WorldViewProjection < string UIWidget="None"; >; |
---|
| 59 | float4x4 VpXf : ViewProjection < string UIWidget="None"; >; |
---|
| 60 | float4x4 WorldXf : World < string UIWidget="None"; >; |
---|
| 61 | float4x4 ViewIXf : ViewInverse < string UIWidget="None"; >; |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | //// Techniques //// |
---|
| 65 | technique SunShader |
---|
| 66 | { |
---|
| 67 | pass p0 < |
---|
| 68 | string Script = "Draw=geometry;"; |
---|
| 69 | > { |
---|
| 70 | DepthTestEnable = true; |
---|
| 71 | DepthMask = true; |
---|
| 72 | BlendEnable = true; |
---|
| 73 | CullFaceEnable = true; |
---|
| 74 | |
---|
| 75 | VertexProgram = compile vp30 sun_shader(WvpXf, SunLightColor); |
---|
| 76 | } |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | technique BlackShader |
---|
| 80 | { |
---|
| 81 | pass p0 < |
---|
| 82 | string Script = "Draw=geometry;"; |
---|
| 83 | > { |
---|
| 84 | DepthTestEnable = true; |
---|
| 85 | DepthMask = true; |
---|
| 86 | BlendEnable = true; |
---|
| 87 | CullFaceEnable = true; |
---|
| 88 | |
---|
| 89 | VertexProgram = compile vp30 black_shader(WvpXf); |
---|
| 90 | } |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | |
---|