What I am asking is not related to how vertex and fragment shaders work, as I already understand them at a basic level. What I am asking is how to reuse them.
I recently had a problem where all of my objects were using an orthographic projection by default. I understand now that I have to apply projection matrix, and that it is recommended that I do this via matrix multiplication in a vertex shader, rather than using the fixed pipeline.
My problems is getting the projection working with multiple kinds of shader programs. As it stands, I know I have to make a vertex shader which applies vertex transformations and sends vertex attributes to the fragment shader. While I can apply the same kinds of transformations by simply rewriting the transformation code for each vertex shader, it seems like it would be a better idea to make a vertex shader specifically designed for transforming, make another vertex shader for passing UV coords in the event that I want to use a texture, etc and etc…
The tutorials that I’ve been looking at seem to hint at the possibility of attaching more than two shaders to a shader program.
Texture Shader Program UVVertexShader -> ProjectionVertexShader -> FragmentShader ->
If this kind of concatenation possible? I guess my main problem is code modularity when using shaders. I can’t think of a way to divide the work among them, and I certainly don’t want to make a mega-shader program that can do everything, but only has certain features available when a uniform value is toggled. I’m new to GLSL, so I understand if this is a newbie question.