Picking out and modifying a texel on a texture on a rendered mesh

Started by
0 comments, last by Hodgman 7 years, 2 months ago

As the title says :)

Using my mouse, I want to pick out a texel on a mesh I have rendered and modify that texel.

I start by picking a screen coordinate using my mouse. I then convert this screen coordinate to a world coordinate (using depth value at that pixel + inverse wvp matrix). This world coordinate is on the mesh at the pixel of the texture I want to modify. The question is how do I then go from world coordinate to texture coordinate on that specific texture?

Advertisement

You've got to find which triangle is at that world coordinate (e.g. ray-trace along a ray from the eye to that world coordinate against all the triangles), and then convert from world coordinates to barycentric coordinates, and use those to interpolate the texture-coordinates from the three vertices, then convert the texel coordinates into a pixel address.

This topic is closed to new replies.

Advertisement