source: GTP/trunk/App/Demos/Illum/SoftShadowMap/Shaders/technique_00.fx @ 1637

Revision 1637, 3.1 KB checked in by szirmay, 18 years ago (diff)
Line 
1// Hardware ShadowMap
2// tex2Dproj with NO linear filtering
3
4// SHADOWMAP generation
5
6//-----------------------------------------------------------------------------
7// Vertex Shader: RenderShadowMap_00_VS
8// Desc: Process vertex for the shadow map
9//-----------------------------------------------------------------------------
10void RenderShadowMap_00_VS(
11                in float4 Position   : POSITION,  // input position in modeling space
12           out float4 ldPosition : POSITION ) // output position in light's device space
13{
14        ldPosition = mul( Position, WorldLightProj );
15}
16
17//-----------------------------------------------------------------------------
18// Pixel Shader: RenderShadowMap_00_PS
19// Desc: Process pixel for the shadow map
20//-----------------------------------------------------------------------------
21float4 RenderShadowMap_00_PS(void) : COLOR
22{
23        return float4(0, 0, 0, 1);              // just return any color, only the z is used
24}
25
26
27// SCENE RENDERING
28
29//-----------------------------------------------------------------------------
30// Vertex Shader: RenderSceneWithTechnique_00_VS
31// Desc: Process vertex for scene
32//-----------------------------------------------------------------------------
33VS_OUTPUT RenderSceneWithTechnique_00_VS( VS_INPUT IN )
34{
35        VS_OUTPUT OUT = (VS_OUTPUT)0;
36        OUT.Color = IN.Color;
37        OUT.Tex = IN.Tex;
38
39        // transform model-space vertex position to light's normalized device space:
40        OUT.ldPosition = mul(mul(IN.Position, WorldLightProj), TexScaleBias);
41       
42        // transform model-space vertex position to normalized screen space:
43        OUT.hPosition = mul(IN.Position, WorldViewProj);
44        return OUT;
45}
46
47
48//-----------------------------------------------------------------------------
49// Pixel Shader: RenderSceneWithTechnique_00_PS
50// Desc: Hardware shadow map with NO linear filtering and 1 sample
51//-----------------------------------------------------------------------------
52float4 RenderSceneWithTechnique_00_PS( VS_OUTPUT IN ) : COLOR
53{
54        float visibility = tex2Dproj( g_ShadowMapZSampler_Point, IN.ldPosition ).x;
55        float4 retColor = float4(0,0,0,1);
56        if( g_bRenderBaseTexture ){
57                retColor.xyz = tex2D( g_samScene, IN.Tex ).xyz * g_vMaterial;
58        } else{
59                visibility = ( visibility - 1 ) * g_fIntensity * g_fRealSamples;
60                retColor = float4( visibility, visibility, visibility, 1 );
61        }
62        return retColor;
63}
64
65
66// TECHNIQUE
67
68//-----------------------------------------------------------------------------
69// Techniques: RenderShadowMap
70// Desc: Render the shadow map
71//-----------------------------------------------------------------------------
72
73technique RenderShadowMap_0
74{
75    pass p0
76    {
77        VertexShader = compile vs_2_0 RenderShadowMap_00_VS();
78        PixelShader  = compile ps_2_0 RenderShadowMap_00_PS();
79
80                ZEnable = True;
81                Lighting = False;
82                ColorWriteEnable = 0; // no need to render to color, we only need z
83    }
84}
85
86technique RenderSceneWithTechnique_0
87{
88    pass p0
89    {
90        VertexShader = compile vs_2_0 RenderSceneWithTechnique_00_VS();
91        PixelShader  = compile ps_2_0 RenderSceneWithTechnique_00_PS();
92    }
93}
Note: See TracBrowser for help on using the repository browser.