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.
Point Light shadow map using a single 2D texture
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.
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
Popular Topics
Advertisement
Recommended Tutorials
Advertisement