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

Shadow map Texture format

Started by andyhansen Aug 5, 2011 at 7:52 PM 4 replies 3.6k views
Original Post
andyhansen
andyhansen
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?
Adaline
Adaline
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)

andyhansen
andyhansen

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.
MJP
MJP
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);
}
Bummel
Bummel
@MJP: But shouldn´t it be 255.f instead of 256.f?
andyhansen
andyhansen
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?

Topic Locked

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

Sign in to reply to this topic.