Skip to main content
GameDev.net gamedev.net
🔒 Locked

Point Light shadow map using a single 2D texture

Started by ongamex92 Apr 27, 2020 at 9:18 AM 3 replies 3.3k views
Original Post
ongamex92
ongamex92

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.

NikiTo
NikiTo

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.

JoeJ
JoeJ

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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.