Is it mandatory to have a value for "gl_Position" in Vertex Shader

While Writing a vertex shader- Is is mandatory to have a gl_Position value for each vetex of Geometry? Or we can use “if” Statement as follows:

if( pos_current.z < depth + L0)
gl_Position = position_ES;

to give gl_Position value for only certain vertex of Geometry.

I am Trying to implement Random Subset Algorithm for transparency in which I divide geometry in three subsets(In vertex shader) And then render them deferred And blend them to get final result.

According to the following post, gl_Position always needs to be written by the final vertex processing stage. In WebGL that is the vertex shader.

BTW: The usage of the GLSL operataion discard only works in the fragment shader.

1 Like