www.pudn.com > Samples-latest.zip > BasicSH.fx
//-----------------------------------------------------------------------------
// File: BasicSH.fx
//
// Desc: The effect file for the BasicSH sample.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Global variables
//-----------------------------------------------------------------------------
texture g_MeshTexture; // Color texture for mesh
float g_fTime; // App's time in seconds
float4x4 g_mWorld; // World matrix for object
float4x4 g_mWorldViewProjection; // World * View * Projection matrix
float4 g_LightDir;
//-----------------------------------------------------------------------------
// Texture samplers
//-----------------------------------------------------------------------------
sampler MeshTextureSampler =
sampler_state
{
Texture = ;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};
//-----------------------------------------------------------------------------
// Vertex shader output structure
//-----------------------------------------------------------------------------
struct VS_OUTPUT
{
float4 Position : POSITION; // vertex position
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,
float vDiffuse : BLENDWEIGHT )
{
VS_OUTPUT Output;
float3 vNormalWorldSpace;
// Transform the position from object space to homogeneous projection space
Output.Position = mul(vPos , g_mWorldViewProjection);
Output.Diffuse = vDiffuse * ( saturate( dot( g_LightDir, vNormal ) ) + 0.3f );
return Output;
}
//-----------------------------------------------------------------------------
// Pixel shader output structure
//-----------------------------------------------------------------------------
struct PS_OUTPUT
{
float4 RGBColor : COLOR0; // Pixel color
};
//-----------------------------------------------------------------------------
// Name: RenderScenePS
// Type: Pixel shader
// Desc: This shader outputs the pixel's color by modulating the texture's
// color with diffuse material color
//-----------------------------------------------------------------------------
PS_OUTPUT RenderScenePS( VS_OUTPUT In )
{
PS_OUTPUT Output;
Output.RGBColor = In.Diffuse;
return Output;
}
//-----------------------------------------------------------------------------
// Name: RenderScene
// Type: Technique
// Desc: Renders scene to render target
//-----------------------------------------------------------------------------
technique RenderScene
{
pass P0
{
VertexShader = compile vs_1_1 RenderSceneVS();
//PixelShader = compile ps_1_1 RenderScenePS();
ColorArg1[0] = DIFFUSE;
ColorOp[0] = SELECTARG1;
}
}