Reputation: 1088
I have a vertex shader and fragment shader using the flat
qualifier, and for complicated hacky reasons explained near the end of https://www.youtube.com/watch?v=l6PEfzQVpvM, I want to change the WebGL flat shading provoking vertex, which is the vertex number that WebGL will use when passing varying colors. (my shader is like this):
// ...
flat out vec3 pass_vertexColor;
// ...
and I know in OpenGL you can change the provoking vertex like this:
glProvokingVertex(1 /* 2, 3 */); // i think
But I don't think there is an equivalent in WebGL yet. So my question is:
What is the default WebGL Provoking Vertex?
Upvotes: 0
Views: 1361
Reputation: 1968
WebGL 1.0 does not support flat shading. See this answer for a workaround.
WebGL 2.0 has flat shading. It has the same default as regular OpenGL - the provoking vertex is the last vertex of the triangle. It appears this cannot be changed in WebGL 2.0 as ProvokingVertex()
is not exposed through the WebGL 2.0 API.
Note that even in desktop OpenGL, the provoking vertex can either be the first or last vertex of the triangle (with last being the default). It cannot be the middle vertex.
Upvotes: 4