Jump to content


- - - - -

calculating uv coordinate inside triangle


3 replies to this topic

#1 rouncer

    Senior Member

  • Members
  • PipPipPipPip
  • 2722 posts

Posted 18 April 2009 - 07:51 PM

Posted Image

I have a 2d triangle with uv coordinates, i have a point d and I wish to calculate the uv coordinates for this point.

It has to fit in a geometry shader, can someone help me out?

#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 5308 posts
  • LocationSanta Clara, CA

Posted 18 April 2009 - 08:31 PM

Google for "barycentric coordinates", that should do the job.
reedbeta.com - developer blog, OpenGL demos, and other projects

#3 geon

    Senior Member

  • Members
  • PipPipPipPip
  • 939 posts

Posted 19 April 2009 - 03:47 PM

Don't forget to do perspective correction.

#4 Mihail121

    Senior Member

  • Members
  • PipPipPipPip
  • 1059 posts

Posted 19 April 2009 - 03:49 PM

geon said:

Don't forget to do perspective correction.

It's a 2D triangle...





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users