multiple shaders for same scene (link?)

Started by
1 comment, last by agaudreau 15 years, 2 months ago
hi all, ive built a scene inwhich im using different shader to render all geometry. the thing i there are common things for all geometry that i duplicate for every shader. i have a list of shaders used like this: simple_diffuse_color (render with color, no texture, no lighting) simple_texture (render with texture, no lighting) simple_diffuse_specular_texture (render with color, texture, phong lighting) simple_diffuse_specular_texture_gloss (render with color, texture, phong lighting + gloss (specular map)) what i duplicate is the fog equation for all of the shaders. i do same fog calculations for every shader and for every frame. what id like to know is if there is a better way to do this? maybe work out different code parts and be able to link shaders together so one can use one shader with or without fog or even with or without lighting attenuation for example. kind regards,
Advertisement
Yes, this is a common problem. I solved this problem by using a preprocessor. My shader "source" files are "compiled" by this preprocessor to the final shader files.

Take a look at http://mcpp.sourceforge.net/, its a free preprocessor.

--
Ashaman
You mean you want individual bits and when you render something you want to call the shaders you need for that render call?

I am currently learning dx10 and I think I saw something about shared memory between shaders. With this all you would have to do is program each shader for a hand full of cases to check for where it should get the input and where it should write to.

Input:
1- This shader the first shader?
2- This shader not the first shader?

Output:
1- This shader is not the last shader?
2- this shader is the last shader?

This topic is closed to new replies.

Advertisement