getting Texture Coordinates from view

:confused: 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 :confused:

Off the top of my head, I can think of 3 possibilities:

  1. 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 :slight_smile: )

  2. 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.

  3. 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

can you give me a url, for these calculations

Google is your friend (I just plugged in “barycentric triangle ray intersection” and got a whole load of stuff)

if you’re feeling lazy then here’s a direct link to the 2nd Google result; plenty to chew on here:

CFXWeb - Ray Triangle Intersection

Thanks, now i know what to search for,
I tryed rendering a seprate u map and a v map, however they keep getting erased when i change contexts