In a shader I’m making for a simple little side-project, I ended up needing to do this to make the shader be more flexible:
if (useViewMatrix == 1) {
gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.0);
} else {
gl_Position = projectionMatrix * modelMatrix * vec4(position, 1.0);
}
I was wondering, however, if there was a way to simplify this down to 1 line.