Jump to content
  • Advertisement
Sign in to follow this  
KaiserJohan

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

This topic is 583 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!