Texture sampling outside of a shader

Started by
1 comment, last by Mokda 16 years, 1 month ago
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
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.
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 ;)

This topic is closed to new replies.

Advertisement