Jump to content
  • Advertisement
Sign in to follow this  
Pthalicus

Rendering negative colour values

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

Hello there,
I'm not usually one for asking for help, I usually work out the problems myself...but if anyone would like to help, I'd be very grateful. :)

After outputting the normals to a D3DFMT_A8R8G8B8 format surface, I noticed that they weren't right, something, ever so slight was missing. After a long time trying to figure out what, I realised the format was unsigned, and the normal needs to be signed.

So I switched to the D3DFMT_Q8W8V8U8 format, as this allows for signage, only to find that I couldn't create a texture using this format whilst specifying D3DUSAGE_RENDERTARGET as usage.

So, how can I store the sign for each x,y,z of the normal vector in a non-signed RGB value?


I've had an idea, but I'm not sure if it'll work, I'll try it after this post...

Idea: If instead of outputting the values from -1.0f to 1.0f, they are output from 0.0f to 1.0f ( with 0.5f being 0.0f ), then when accessing the surface later, I ensure that the values get transformed back to -1.0f to 1.0f, it should be ok right? I think I'll need to normalize after the retransform.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Pthalicus
Idea: If instead of outputting the values from -1.0f to 1.0f, they are output from 0.0f to 1.0f ( with 0.5f being 0.0f ), then when accessing the surface later, I ensure that the values get transformed back to -1.0f to 1.0f, it should be ok right?
That's the usual approach.

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!