Advertisement

Point Light shadow map using a single 2D texture

Started by April 27, 2020 09:18 AM
3 comments, last by JoeJ 4 years, 9 months ago

Hi all,

I'm trying to make shadow maps for point lights and I want to use just a single 2D texture for storing the shadow maps for all of the 6 faces (as I render it with 6 90 deg cameras).
However I need to be able to sample this 2D texture as if it was a CUBE map, just by using a float3 for the sampling direction.

Is there a smart way to layout my shadow maps and a smart computation where I can convert the float3 sampling direction to float2 UV for sampling? My solution has too many branches and I do not like it.

You could do:

pos2dUINT.x + (faceIndex*sizeOfOneFaceInPixels);

or

pos2dFLOAT.x + (float)faceIndex;

But you need to manually check for out of bounds in order to not read from the neighbor cube faces. This is added extra computation. I would just use 6 textures instead.

Advertisement

Reasons to use cubemaps over 6 textures-

https://learnopengl.com/Advanced-OpenGL/Cubemaps

ongamex92 said:
My solution has too many branches and I do not like it.

I think at least GCN (so probably all AMD HW) has no native support for cube map filtering, so your branchy code may be similar to what the compiler creates under the hood anyways. (Not sure about Nvidia, but the loss should not be that bad.)
IIRC, L.Spiro did some posts about it here on the forum. Maybe you can search for it.

This topic is closed to new replies.

Advertisement