VISTAS-IVES / pyvistas

VISualization of Terrestrial-Aquatic Systems
BSD 3-Clause "New" or "Revised" License
0 stars 2 forks source link

Add default fragment shader to selection shaders #63

Closed TaylorMutch closed 7 years ago

TaylorMutch commented 7 years ago

Since we are actually drawing colors per object we want to test against (rather than just perform depth tests), we need to add a fragment shader.

nikmolnar commented 7 years ago

Why did this work previously?

TaylorMutch commented 7 years ago

This previously worked because in the vertex shader, we specified a single output color per vertex:

// vertex.glsl
uniform vec4 color;
out vec4 finalColor;
void main() {
    finalColor = color;
}

Technically this is correct, but we're telling the shader program that each vertex needs to be assigned a color during vertex assembly. This way, with specifying the color as a uniform color in the fragment shader, there is no need to add an additional input variable to the fragment shader. We just assign gl_FragColor (or technically, the single out vec4 from the fragment shader) to be the uniform we want for the whole shape.