Sign in to follow this  
Mokda

Texture sampling outside of a shader

Recommended Posts

Mokda    122
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
MJP    19753
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
Mokda    122
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

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