Jump to content
  • Advertisement
Sign in to follow this  

Working around the new reach profile limitations in XNA4 - Shadow Mapping

This topic is 2941 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

Hey guys,

I'll preface this by saying that my 3D skills are lacking. I have focused the majority of my programming power on creating neat 2D games with interesting technical effects.

I decided I was going to work on a 3D project to get my feet wet and I'm trying to tackle a few tough problems.

My first problem comes in the form of shadow mapping. The Reach profile in the new XNA version (Want to target this, requiring end users have a DX10 card isn't something I'm interested in doing, despite wanting some of the old functionality I used to get without requiring this...)

I've been looking into shadow mapping, and every example (even the official one) uses SurfaceFormat.Single for the shadow texture. I've tried toying with these samples and converting them to a format available to Reach but the results are always really bad, with all sorts of terrible artifacts all over the subject and the casted shadow.

Does anyone have any information on doing basic shadow mapping with a surface format like Color, or anything available to Reach?

Share this post

Link to post
Share on other sites
You can encode a single float value in 3 components of a Color surface using something like this in your shader:

float4 RGBAEncode(float value) {
value = clamp(value, 0.0f, 0.99999f);

const float4 bitMask = float4(0.0f, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);
const float4 bitShift = float4(256.0f * 256.0f * 256.0f, 256.0f * 256.0f, 256.0f, 1.0f);

float4 comp = value * bitShift;
comp = frac(comp);
comp -= comp.xxyz * bitMasl;

return comp;

float RGBADecode(float4 value) {
const float4 bits = float4(1.0 / (256.0 * 256.0 * 256.0),
1.0 / (256.0 * 256.0),
1.0 / 256.0,

return dot(value.xyzw , bits);

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!