Skip to main content
2 of 2
added 45 characters in body
user avatar
user avatar

How should shader be structured? (GLSL)

I've been writing, deleting and rewriting OpenGL programs in C++ but usage of shaders confuse me. I don't know how it should be structured.

Scenario A: (In a world we have a sun, the sun should shine upon everything in the world and on a lake or there would be fog which should only be visible from outside the building but not inside)

So far, I am thinking that I would write a global sun structure in C++ then pass its value to all shaders, then in all used shaders I would write the same lighting functions over and over again.

So I would be repeating codes... How would you construct your shader program in such scenario? And Should I write a shader for each model?

user133668