This topic is 4961 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

jus wanna ask wat does "projecting light's planar distance onto eye's view" meant? this is taken from: Slide 16 Shadow Mapping with Today’s OpenGL Hardware SIGGRAPH 2002 Course 31: Interactive Geometric Computations Using Graphics Hardware thx!

Share on other sites
Your shadow map store the depth of each visible pixel, from the light's point of view. I believe that the "light's planar distance" is this depth.
When you have to check if a pixel is shadowed or not, you place yourself in the user's point of view, but the depth you get doesn't correspond to the ones stored in your shadow map, right ? So you have to compute the depthes of the shadow map IN THE EYE's view to be able to compare the 2 depthes.

Hmmm I don't know if I was clear or not, if you didn't understand my explanations, ask me again, i'll try to be a little clearer ^^

Share on other sites
ah ok thx alot!

i jus checked thru the dxsdk which has a shadowmapping sample.

The following line in the sdk helps alot to explain as well:
"Compute the matrix to transform from view space to light projection space. This consists of the inverse of view matrix * view matrix of light * light projection matrix."

now my next qn:
In their sample, they had a vertexshader during the initial render shadowmap pass that passes the .zw components of the calculated clip space coordinates to the pixelshader. The pixel then does the z/w division.

//-----------------------------------------------------------------------------
// Desc: Process vertex for the shadow map
// g_mWorldView is light view matrix
// g_mProj is light projection matrix
//-----------------------------------------------------------------------------
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;
}

//-----------------------------------------------------------------------------
// 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;
}

thx!

[Edited by - edwinnie on May 17, 2005 9:01:29 AM]

Share on other sites
btw i don't want to open a new thread on this so:
Is it possible to save the World coordinates instead of the distance from the light? If i understand shadowmapping right than you render the scene as a depth map from the light's position. Then you project this map onto the scene. when you're doing that the Pixel casting the shadow and The shadowed pixel are projected onto the same spot in 3d. So you just have to calculate the "real" distance from the pixel being processed to the light and compare it to the distance in the depth map from the light... if you do that with worldcoords you wont need to calculate the distance(which needs a square root)...

regards,
m4gnus

Share on other sites
This is a good technique if doing point lights. For instance, if you scale the distance to be in light space ( light pos at the origin, light max range [0..r] scaled to [0..1], you can output the rgb as 8-bit colors.

For spotlights or directional lights, you need planar distance, which is just a dot product, so there is no square root needed.

1. 1
2. 2
Rutin
19
3. 3
4. 4
khawk
15
5. 5
A4L
13

• 13
• 26
• 10
• 11
• 44
• Forum Statistics

• Total Topics
633743
• Total Posts
3013644
×