tex2D和tex2DProj的区别在于tex2D不会处理W,也就是不会将坐标标准化,而tex2Dproj会,
投影纹理Shader代码:

VertexShader:

float4x4 matViewProjection;
float4x4 mat;

struct VS_INPUT
{
   float4 Position : POSITION0;
   float2 Texcoord : TEXCOORD0;
  
};

struct VS_OUTPUT
{
   float4 Position : POSITION0;
   float2 Texcoord : TEXCOORD0;
   float4 Tex      : TEXCOORD1;
  
};

VS_OUTPUT vs_main( VS_INPUT Input )
{
   VS_OUTPUT Output;
   float4x4 m;

   Output.Position = mul( Input.Position, matViewProjection );
   Output.Texcoord = Input.Texcoord;
   m = mul( matViewProjection,mat );
   Output.Tex = mul( Input.Position,m );
   Output.Tex.y = -Output.Tex.y;
   Output.Tex.xyz = Output.Tex.xyz/Output.Tex.w;
   return( Output );
  
}



Piexl Shader:

sampler2D baseMap;
sampler2D Texture1;

struct PS_INPUT
{
   float2 Texcoord : TEXCOORD0;
   float4 Tex      : TEXCOORD1;
  
};

float4 ps_main( PS_INPUT Input ) : COLOR0
{
   float4 c,c1,c2;
 
   if( Input.Tex.w < 0 )
     c2 = 0;
   else
     c2 = tex2D( Texture1,Input.Tex );
   c1 = tex2D( baseMap, Input.Texcoord );
   c = lerp( c1,c2,1 );
   return c;
  
}