Jump to content
  • Advertisement
Sign in to follow this  
Caesar

OpenGL software texture mapping

This topic is 4970 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

Hi, I got a tri and it's U and V coordiantes, plus I also have the world-space intersection point and what I think is barycentric coordiantes of the of the intersection point. now I'd like to get the U and V for the intersection point. One idea I have is: a triangle ABC, hitpoint H. Construct a line that lies on A and H and calculate it's intersection D with the opposite edge BC. Now I interpolate BC to get U and V for D, then interpolate A and D to get U and V for H Seems to be quite an intuitive solution, but I guess there must be something faster (considering how many times this will be done). I've googled for some solutions, but most sutff points to texturing and rasterizing in D3D or OpenGl. I know a regular engine would interpolate along the edges and then along the scanlines, but I'm writing a raytracer (seems everybody is writing a raytracer lately ;)) and don't think calculating the edge U and V for the scanline I'm doing is a good method since it lacks in flexibility.

Share this post


Link to post
Share on other sites
Advertisement
Check here:
http://www.flipcode.com/articles/article_raytrace07.shtml

Explains a bit about barycentric coordinates, and how to get u/v. Source code included.

Share this post


Link to post
Share on other sites
Hi,
thanks for pointing that out, I missed it somehow in the article.

I was just not very clever. I didn't realise I can use the baricentric coordinates I already have and instead of X and Y just plug in the U and V. I was thinking long about finding the U and V axes from the three U and V pairs. Then I realised I might do it the way I described in my initial post. And now I see I had the solution right before me all the time.


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!