PDA

View Full Version : calculating uv coordinate inside triangle


rouncer
04-18-2009, 12:51 PM
http://c3.ac-images.myspacecdn.com/images02/79/l_0b09d8da80f94a5fbf2adc3a5633263a.png

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?

Reedbeta
04-18-2009, 01:31 PM
Google for "barycentric coordinates", that should do the job.

geon
04-19-2009, 08:47 AM
Don't forget to do perspective correction.

Mihail121
04-19-2009, 08:49 AM
Don't forget to do perspective correction.

It's a 2D triangle...