View Full Version : When do we alter shader?

09-20-2010, 02:01 PM
I'm in the first steps of learning OpenGL and while I've gone further into shaders, I've not yet understood when it's the ideal time to change a particular shader with something else.

For example, right now I noticed that to render a font I just needed a single color. At that time I could load another fragment shader and just do a copy of the color to output directly.

Or, I could do an 'if'check in the single fragment shader for the existence of the color and use it [without altering the shader file].

What is the ideal?

09-20-2010, 03:16 PM
There's no right or wrong only what works for you.
I have some shaders for font rendering for example which use a couple of ifs to allow the same shader to perform slightly different tasks. You'll find as your needs change your shaders become more specialised and so you'll switch shaders as you switch objects for rendering.

09-21-2010, 07:12 AM
There's no right or wrong
ok, I suspected that and it's convenient; only it's a bit peculiar that I reached a point of having a shading model loading several meshes and still don't see the major need to alter program; only now for the font.

I guess it needs to advance to the point of being a higher level app (e.g. visual effects for a particular new element in a game) to make more sense.