Tuesday, March 30, 2010

XNA-ShaderNote

GlobleVaule

struct VertexShaderINPUT
{
   float4 Postition : POSITION0;     //Require
}
struct VertexShaderOUTPUT
{
     float4 Postition : POSITION0;   //Require
}

VertexShaderOUT VSBasic(VertexShaderINPUT input)
{
   float4 WorldPostition= mul();
   float4 ViewPosirion= mul();
   return output;
}

float4 PixelShader() : COLOR0
{
   return float4;
}

technique NAME
{
   pass NAME2
   {
    compile Version;
    }
}
----------------------------------------------------------------------------------------------
Shadow

FX:

1.Create PixelShader for technique
2.Define technique
C#:

1.Define Matrix for shadow
                 Matrix.CreateShdow(Light,Plane)
Draw Funtion()
1. Define Matrix[] for shadowBones And get Bones.Length
2. Bones[i]*shadow
3.Draw Model
4.Check RenderState

            GraphicsDevice.Clear(ClearOptions.Stencil, Color.Black, 0, 0);
            GraphicsDevice.RenderState.StencilEnable = true;
            GraphicsDevice.RenderState.ReferenceStencil = 0;
            GraphicsDevice.RenderState.StencilFunction = CompareFunction.Equal;
            GraphicsDevice.RenderState.StencilPass = StencilOperation.Increment;
            GraphicsDevice.RenderState.AlphaBlendEnable = true;
            GraphicsDevice.RenderState.SourceBlend = Blend.SourceAlpha;
            GraphicsDevice.RenderState.DestinationBlend = Blend.InverseSourceAlpha;

No comments:

Post a Comment