Jump to content
  • Advertisement
Sign in to follow this  
Mokda

Texture sampling outside of a shader

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

Hi Devs, I was trying to find a crafty way of sampling a texture outside of a shader so that I could implement some better collision detection. What I need to know is how to access the color information at an exact coordinate in a texture (not in U,V coordinates). So for example, I would like to scan to (450,323) in a 500x500 texture to see if the alpha component is greater than 0.5f. Any ideas or hint code would be much appreciated! Thanks. -Mokda

Share this post


Link to post
Share on other sites
Advertisement
You need to use LockRect if you want to obtain a pointer to texel data for reading. Be aware that doing this can have serious performance penalties if you do this while the GPU access the texture, so make sure you use the appropriate flags (like the READONLY flag) and only do it when it's absolutely necessary.

Share this post


Link to post
Share on other sites
Thanks MJP! That put me on the right track. I'll keep an eye out for performance...and probably be back on these forums if I do run into problems ;)

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!