看DX的Shadow Map代码,对Pixel Shader传入的“像素”产生了疑惑?
生成Shadow Map的VS, PS代码中有简单的几句。
//-----------------------------------------// Vertex Shader: VertShadow// Desc: Process vertex for the shadow map//-----------------------------------------void VertShadow( float4 Pos : POSITION, float3 Normal : NORMAL, out float4 oPos : POSITION, out float2 Depth : TEXCOORD0 ){ // // Compute the projected coordinates // oPos = mul( Pos, g_mWorldView ); oPos = mul( oPos, g_mProj ); // // Store z and w in our spare texcoord // Depth.xy = oPos.zw;}//-----------------------------------------// Pixel Shader: PixShadow// Desc: Process pixel for the shadow map//-----------------------------------------void PixShadow( float2 Depth : TEXCOORD0, out float4 Color : COLOR ){ // // Depth is z / w // Color = Depth.x / Depth.y;}