Sign in to follow this  
andyhansen

Shadow map Texture format

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
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 [url="http://msdn.microsoft.com/en-us/library/ff471325%28v=VS.85%29.aspx"]HW support for DX11[/url] (the page you mentioned is about DX10 formats, not DX11)

:)

Share this post


Link to post
Share on other sites
[quote name='Adaline' timestamp='1312576195' post='4845203']
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 [url="http://msdn.microsoft.com/en-us/library/ff471325%28v=VS.85%29.aspx"]HW support for DX11[/url] (the page you mentioned is about DX10 formats, not DX11)

:)
[/quote]

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:
[code]
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);
}
[/code]

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this