by cmovq · 1y ago · 0 comments
Using 2 tris for this isn’t ideal because you will get duplicate fragment invocations along the horizontal seam where the triangles meet. It is slightly more efficient to use one larger triangle extending outside the viewport, the offscreen parts will be clipped and not generate any additional fragments.
[1]: https://wallisc.github.io/rendering/2021/04/18/Fullscreen-Pa...
A bit of an older article but still very relevant.
I've found with webGL2 you can also skip the whole upload/binding of the buffer and just emit the vertexes/coordinates from the vertex shader as well.
Less of an impact than cutting it down, but if you're just trying to get a a fragment going, why not use the least amount of data and CPU-> GPU upload possible.
ivec2 vert = ivec2(gl_VertexID & 1, gl_VertexID >> 1);
out_uv = 2.0 * vec2(vert);
gl_Position = vec4(out_uv * 2.0 - 1.0, 0.0, 1.0);