Barycentric coordinates texture mapping

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 04:33:46

问题


I want to map textures with correct perspective for 3D rendering. I am using barycentric coordinates to locate points on the faces of triangles. Simple affine transformation gave me that standard, weird looking result. This is what I did to correct my perspective, but it seems to have only made the distortion greater:

three triangle vertices v1 v2 v3

vertex coordinates are v_.x v_.y v_.z

texture coordinates are v_.u v_.v

barycentric coordinates corresponding to vertices are b1 b2 b3

I am trying to get the correct texture coordinates U and V

z=b1/v1.z + b2/v2.z + b3/v3.z

U=(b1*v1.u/v1.z + b2*v2.u/v2.z + b3*v3.u/v3.z) / z

V=(b1*v1.v/v1.z + b2*v2.v/v2.z + b3*v3.v/v3.z) / z

This SHOULD work shouldn't it? Why isn't this working?

EDIT: The response on this page looks useful, but I am unsure what the w coordinate is. Maybe somebody could just explain that, which would also likely solve my problem. http://www.gamedev.net/topic/593669-perspective-correct-barycentric-coordinates/

note: My tags were all wrong at first. That is now fixed.


回答1:


Okay, this one I DID manage to solve on my own. I was dividing by the z coordinate in screen space. The solution is to divide by the homogeneous w coordinate instead.

Well, that took a while to figure out.



来源:https://stackoverflow.com/questions/12360023/barycentric-coordinates-texture-mapping

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!