September 29th, 2006

Shadow mapping shader source (preliminary and unoptimized)

Depth Shader

//—– Constants ———

float4×4 world : WORLD;
float4×4 viewProj : VIEWPROJ;

float3 lightPos;

//—– Shaders ———–

struct vsOut {
float4 pos: POSITION;
float depth: TEXCOORD0;
};

//outputs depth value in world space
void VS(in float3 pos: POSITION, out vsOut output) {
//transform vertex to world space
output.pos = mul(float4(pos, 1.0), world);
//save depth
output.depth = length(output.pos.xyz - lightPos.xyz);
//transform to projection space
output.pos = mul(output.pos, viewProj);
}

float4 PS(in float depth: TEXCOORD0) : COLOR {
//output depth and depth squared (for variance shadow mapping)
return float4(depth, depth*depth, 0.0, 1.0);
}

technique main
{
pass p0
{
VertexShader = compile vs_1_1 VS();
PixelShader = compile ps_2_0 PS();
}
}

Read the rest of this entry »

September 26th, 2006

Soft Shadowing Results (techniques 1 and 2)

September 25th, 2006

Soft Shadow Mapping Ideas

September 24th, 2006

Cubic Shadow Mapping - Finally