/** * \brief Godrays.cg is a CG (C for Graphics) shader collection to imitate the effects of lightray scattering through post-processing approaches. * * \author Markus Wegmann **/ /* % Description of my shader. % Second line of description for my shader. keywords: material classic date: 20110410 */ void sun_shader( float4 position : POSITION, float4 normal: NORMAL, out float4 oPosition : POSITION, out float4 oColor : COLOR, uniform float4x4 modelViewProj, uniform float4 sunColor) { oPosition = mul(modelViewProj, position); oColor = 2 * normalize(sunColor); } void black_shader( float4 position : POSITION, out float4 oPosition : POSITION, out float4 oColor: COLOR0, uniform float4x4 modelViewProj) { oPosition = mul(modelViewProj, position); oColor = float4 (0, 0, 0, 1); } //// Variables //// ///////////////////////////////////////////////////////////////////////////////////// float4 SunLightColor : Specular < string UIName = "Lamp 0 Color"; string Object = "Pointlight0"; string UIWidget = "Color"; > = {0.3, 0.42, 1, 1}; //// UN-TWEAKABLES - AUTOMATICALLY-TRACKED TRANSFORMS //// float4x4 WorldITXf : WorldInverseTranspose < string UIWidget="None"; >; float4x4 WvpXf : WorldViewProjection < string UIWidget="None"; >; float4x4 VpXf : ViewProjection < string UIWidget="None"; >; float4x4 WorldXf : World < string UIWidget="None"; >; float4x4 ViewIXf : ViewInverse < string UIWidget="None"; >; //// Techniques //// technique SunShader { pass p0 < string Script = "Draw=geometry;"; > { DepthTestEnable = true; DepthMask = true; BlendEnable = true; CullFaceEnable = true; VertexProgram = compile vp30 sun_shader(WvpXf, SunLightColor); } } technique BlackShader { pass p0 < string Script = "Draw=geometry;"; > { DepthTestEnable = true; DepthMask = true; BlendEnable = true; CullFaceEnable = true; VertexProgram = compile vp30 black_shader(WvpXf); } }