calculating uv coordinate inside triangle

Fd80f81596aa1cf809ceb1c2077e190b
0
rouncer 104 Apr 18, 2009 at 19:51

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?

3 Replies

Please log in or register to post a reply.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Apr 18, 2009 at 20:31

Google for “barycentric coordinates”, that should do the job.

820ce9018b365a6aeba6e23847f17eda
0
geon 101 Apr 19, 2009 at 15:47

Don’t forget to do perspective correction.

2b97deded6213469bcd87b65cce5d014
0
Mihail121 102 Apr 19, 2009 at 15:49

@geon

Don’t forget to do perspective correction.

It’s a 2D triangle…