Sign in to follow this  

Texture sampling outside of a shader

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

This topic is 3556 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.

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