www.pudn.com > Samples-latest.zip > EnvSphere.fx


//-----------------------------------------------------------------------------
// File: EnvSphere.fx
//
// Desc: The effect file for the rendering of a hermisphere to a cube map.
//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
// Global variables
//-----------------------------------------------------------------------------

float4x4	g_mWorld;					// World matrix for object
float4x4	g_mWorldViewProjection;		// World * View * Projection matrix

float4		g_MeshVertexNormal;

//-----------------------------------------------------------------------------
// Vertex shader output structure
//-----------------------------------------------------------------------------
struct VS_OUTPUT
{
    float4 Position   : POSITION;   // vertex position 
    float3 Normal	  : TEXCOORD;
    float4 Diffuse    : COLOR0;     // vertex diffuse color
};


//-----------------------------------------------------------------------------
// Name: RenderSceneVS
// Type: Vertex shader                                      
// Desc: This shader computes standard transform and lighting
//-----------------------------------------------------------------------------
VS_OUTPUT RenderSceneVS( float4 vPos : POSITION,
                         float3 vNormal : NORMAL )
{
    VS_OUTPUT Output;
    float3 vNormalWorldSpace;

    // Transform the position from object space to homogeneous projection space
    Output.Position = mul(vPos , g_mWorldViewProjection);

    Output.Normal = vNormal;

    Output.Diffuse = saturate( dot( g_MeshVertexNormal, vNormal ) );

    return Output;
}


//-----------------------------------------------------------------------------
// Name: RenderScenePS                                        
// Type: Pixel shader
// Desc: This shader outputs the pixel's color by modulating the texture's
//		 color with diffuse material color
//-----------------------------------------------------------------------------
float4 RenderScenePS( VS_OUTPUT In ) : COLOR0
{ 
    float4 Output;

    Output = dot( g_MeshVertexNormal, normalize( In.Normal ) );

    return Output;
}



//-----------------------------------------------------------------------------
// Name: RenderScene
// Type: Technique                                     
// Desc: Renders scene to render target
//-----------------------------------------------------------------------------
technique RenderScene
{
    pass P0
    {
		Cullmode = CW;
    
        VertexShader = compile vs_1_1 RenderSceneVS();
        //PixelShader  = compile ps_2_0 RenderScenePS();

        ColorArg1[0] = DIFFUSE;
        ColorOp[0] = SELECTARG1;
    }
}