Jump to content
  • Advertisement
Sign in to follow this  

multiple shaders for same scene (link?)

This topic is 3404 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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,

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!