1
$\begingroup$

I've been reading up on a vulkan tutorial online, here: https://vulkan-tutorial.com. This question should apply to any 3D rendering API however.

In this lesson https://vulkan-tutorial.com/Vertex_buffers/Index_buffer, the tutorial had just covered using indexed rendering in order to reuse vertices when drawing the following simple two-triangle quad:

Text

The four vertices were assigned red, green, blue and white colours as vertex attributes and the fragment shader had those colours interpolated across the triangles as expected. This leads to the ugly visual artefact on the diagonal where the two triangles meet. As I understand it, the interpolation will only be happening across each triangle, and so where the two triangles meet the interpolation doesn't cross the boundary.

How could you, generally in any rendering api, have the colours smoothly interpolated over all four corners for a nice colour wheel affect without having this hard line?

$\endgroup$
4
  • 1
    $\begingroup$ By not using linear interpolation. What you are seeing is the discontinuity in the first derivative. Try bilinear interpolation over quads, it will fix it. For polygons with more vertices read up on generalized barycentric coordinates. $\endgroup$
    – lightxbulb
    Aug 7, 2020 at 17:01
  • $\begingroup$ @lightxbulb thank you for responding - I have had a week of radio silence on stack overflow! $\endgroup$
    – FShrike
    Aug 7, 2020 at 17:03
  • $\begingroup$ I did bilinear interpolation for UV coordinates on quads here: reedbeta.com/blog/quadrilateral-interpolation-part-2 I just used those UVs to sample a texture, but they could also be used to interpolate color values, or any other attribute values. $\endgroup$ Aug 7, 2020 at 20:46
  • $\begingroup$ @NathanReed Thank you that looks like a very thorough response! $\endgroup$
    – FShrike
    Aug 7, 2020 at 20:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.