Skip to main content
gamedev.net
🔒 Locked

software texture mapping

Started by Caesar 1 reply 800+ views
Original Post
Caesar
Caesar
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.
phantomus
phantomus
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.
Caesar
Caesar
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.


Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.