rwe
rwe copied to clipboard
Fix 3DO texture distortion
We triangulate 3do meshes before display. This causes texture distortion on quads that are trapezium shaped.
Some options:
- render GL_QUADS (deprecated) and hope they interpolate as expected
- subdivide the mesh
- consider if we can do some maths to compute the texture coordinate correctly
Maybe wait for #4 to give us more flexibility.
#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.
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.
The following article improves upon Nathan Reed's solution for bilinear interpolation by also considering perspective correction:
http://www.unchainedgeometry.com/blog-1.html