Jump to content
  • Advertisement
Sign in to follow this  
andyhansen

Shadow map Texture format

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm currently working on implementing shadow mapping. I'm using DirectX 11 at feature level 9.1 since that is what my laptop supports. It seems the texture formats supported as render targets at this feature level is pretty limited.

The table here shows what is supported.
http://msdn.microsoft.com/en-us/library/ff471324%28v=vs.85%29.aspx

R8G8B8A8_UNORM
R8G8B8A8_UNORM_SRGB

These seem to be the only supported render target formats. This means that I can only store 8 bits of depth precision, rather than using the full 32. What would be ideal is if I could use R32_FLOAT.
Is there a way I can somehow use R8G8B8A8_UNORM or R8G8B8A8_UNORM_SRGB, but use all 32 bits to store a single value, rather than only 8 bits?

Share this post


Link to post
Share on other sites
Advertisement
Hello

Did you effectively try to create your map with R32_FLOAT format ?
It seems odd that you can't use this format with DX11 : I use this format for my shadow map with DX10

Here's the HW support for DX11 (the page you mentioned is about DX10 formats, not DX11)

:)

Share this post


Link to post
Share on other sites

Hello

Did you effectively try to create your map with R32_FLOAT format ?
It seems odd that you can't use this format with DX11 : I use this format for my shadow map with DX10

Here's the HW support for DX11 (the page you mentioned is about DX10 formats, not DX11)

:)


I wasn't able to create a texture with R32_FLOAT, it would give me an error saying that that format was only supported for data buffers at feature level 9_1.

Share this post


Link to post
Share on other sites
He's using FEATURE_LEVEL_9_1, which is a very limited subset of DX9 functionality.

Anway, it is possible to pack a single float value into multiple components of an R8G8B8A8 texture. Something like this should work for you:

float3 PackFloat(in float f)
{
float3 packed;
f *= 256.0f;
packed.x = floor(f);
f = (f - packed.x) * 256.0f;
packed.y = floor(f);
packed.z = f - packed.y;
packed.xy *= 1.0f/ 256.0f
return packed;
}

float UnpackFloat(float3 packed)
{
const float3 conversion = float3(1.0f, 1.0f / 256.0f, 1.0f / (256.0f * 256.0f));
return dot(packed, conversion);
}

Share this post


Link to post
Share on other sites
Thanks for the quick replies guys! That's exactly the type of thing I was looking for. I was just wondering, would I not want to pack it into a float4, rather than a float3?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!