How do i get the texture coordinates of the texture at a spacific point on the screen
I need to retrieve this information so i can paint onto a bitmap that is the texture of the model
I am currently rendering am offscreen image useing the texture coords as vertex colors, then using readpixels, to read the information, however if the texture is over 256*256 there isnt enough detail to reach every pixel (if the texture is 512 i get ever second pixel)
how can i get the the texture coords
Off the top of my head, I can think of 3 possibilities:
use a geometric solution instead. i.e. do a ray to triangle intersection, yielding barycentric coordinates. Then use the barycentric coordinates and the texture coordinates of the triangle to get the texture coordinate youâre painting at. The good thing is, this will work on any hardware (because itâs in software )
use a more precise format, maybe something like G16R16F (or whatever it is in OGL, sorry Iâm still thinking in D3D at the moment!). Drawback: it requires a Radeon9500/GeForceFX or better.
use an ARGB8 surface, but double up components to get more precision, i.e. AR represents the U coordinate and GB represents the V coordinate. Youâre going to need a PS.1.4 part or higher for this I think (Radeon8500+)
Iâve not thought this through properly, hopefully those suggestions will spark a thought in your head (or someone else on the board)
[edit: attempted, and possibly failed, to fix my lame grammar]
yeah ive done it before with the first mrthod smutmonkey mentioned, not to difficult to do.
iirc in the math.algorithms newsgroup faq, theres a bit about barycentric coordinates that i used