How to texture a random convex quad in openGL

后端 未结 2 1566
栀梦
栀梦 2021-01-15 05:08

Alright, so I started looking up tutorials on openGL for the sake of making a minecraft mod. I still don\'t know too much about it because I figured that I really shouldn\'t

2条回答
  •  星月不相逢
    2021-01-15 05:52

    OpenGL will do a perspective correct transform for you. I believe you're simply facing the issue of quad vs triangle interpolation. The difference between affine and perspective-correct transforms are related to the geometry being in 3D, where the interpolation in image space is non-linear. Think of looking down a road: the evenly spaced lines appear more frequent in the distance. Anyway, back to triangles vs quads...

    enter image description here

    Here are some related posts:

    • How to do bilinear interpolation of normals over a quad?

    • Low polygon cone - smooth shading at the tip

    • https://gamedev.stackexchange.com/questions/66312/quads-vs-triangles

    • Applying color to single vertices in a quad in opengl

      An answer to this one provides a possible solution, but it's not simple:

      The usual approach to solve this, is by performing the interpolation "manually" in a fragment shader, that takes into account the target topology, in your case a quad. Or in short you have to perform barycentric interpolation not based on a triangle but on a quad. You might also want to apply perspective correction.

提交回复
热议问题