rwe icon indicating copy to clipboard operation
rwe copied to clipboard

Fix 3DO texture distortion

Open MHeasell opened this issue 7 years ago • 4 comments

We triangulate 3do meshes before display. This causes texture distortion on quads that are trapezium shaped.

Some options:

  1. render GL_QUADS (deprecated) and hope they interpolate as expected
  2. subdivide the mesh
  3. consider if we can do some maths to compute the texture coordinate correctly

MHeasell avatar Oct 15 '17 14:10 MHeasell

Maybe wait for #4 to give us more flexibility.

MHeasell avatar Oct 16 '17 20:10 MHeasell

#4 has made enough progress that it no longer blocks this. We can do this in shaders with appropriate inputs from the outside.

Some useful reading:

http://web.cs.ucdavis.edu/~amenta/s12/perspectiveCorrect.pdf http://www.reedbeta.com/blog/quadrilateral-interpolation-part-1/ http://www.reedbeta.com/blog/quadrilateral-interpolation-part-2/ https://stackoverflow.com/questions/14971282/applying-color-to-single-vertices-in-a-quad-in-opengl

In particular, the third and fourth links describe implementing bilinear interpolation across a quad (not projective interpolation), I think something like this would be most appropriate here.

MHeasell avatar Oct 22 '17 21:10 MHeasell

I should note that implementation of the above is a bit more involved than I had hoped so this will likely be de-prioritised until the engine has more features.

MHeasell avatar Oct 22 '17 21:10 MHeasell

The following article improves upon Nathan Reed's solution for bilinear interpolation by also considering perspective correction:

http://www.unchainedgeometry.com/blog-1.html

MHeasell avatar Jun 12 '21 23:06 MHeasell