# How To Calculate The World Area For The Texel Of A Shadow Map

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

## Recommended Posts

Is there anybody knows how to calculate the area of world coordinates for one texel in a shadow map (for dir-light or spot-light)? I just remember some paper has given some MAGIC formula to calculate this, such as:

float calculateSurfelAreaLight(vec3 lightPos)
{
return (4.0 * lightPos.z * lightPos.z * f_tanFovXHalf * f_tanFovYHalf) / (i_RSMsize * i_RSMsize);
}

But i can't find the full induction process about its formula. How can I get this induced formula? What is the relationship between the area and the light-fov? Any suggestions or paper-references about this would be greatly appreciated!

Edited by neoragex

##### Share on other sites

The process is to figure out the size of the projection window in world space (the part of your projection matrix's projection plane which makes up your shadow map) and then divide by texel count in x and y direction.

You can do this analytically (draw diagrams and do the math) or you can get the four intersection points (although you only need the 'upper left' and 'lower right' ones) of the projection plane with the lines of the view frustum running through it and transform them with the inverse of your viewProjection matrix which the lights use, and figure out width/height from those.

##### Share on other sites

The process is to figure out the size of the projection window in world space (the part of your projection matrix's projection plane which makes up your shadow map) and then divide by texel count in x and y direction.

You can do this analytically (draw diagrams and do the math) or you can get the four intersection points (although you only need the 'upper left' and 'lower right' ones) of the projection plane with the lines of the view frustum running through it and transform them with the inverse of your viewProjection matrix which the lights use, and figure out width/height from those.

I do think that the world area relative to a single texel in a shadow-map may not be constant, considering the perspective projection. It depends on the linear depth (in the light's coordination system) for every single texel in the shadow map. So the 'lightPos.z' in above code does not stand for the distance between the light and a FIXED PROJECTION WINDOW. It is the linear depth (in the light's coordination system) for its corresponding texel in the shadow map.

What do you think? :)

Edited by neoragex

1. 1
2. 2
3. 3
Rutin
23
4. 4
5. 5
khawk
14

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633653
• Total Posts
3013164
×