Varyings

As described earlier, varyings allow for the vertex shader to pass information to the fragment shader. For example, if we want to carry the vertex color from the vertex shader to the fragment shader, we would first update our vertex shader:

#version 300 es

out vec4 vVertexColor;

void main(void) {
vVertexColor = vec4(1.0, 1.0, 1.0, 1.0);
}

And we would reference that varying inside of our fragment shader as follows:

in vec4 vVertexColor;

Keep in the mind that the Storage Qualifier, the declaration of varyings, needs to match between the vertex and fragment shaders.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.207.129