Sign in to follow this  

Toggle Shadows On/Off

This topic is 1465 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

 

I wanted to know how one should approach toggling various shader effects such as Shadows on/off.

 

Should I have a single shader that checks a global bool and branch depending if shadows are on/off.

Or should I write two shaders, one with shadows on and one with shadows off?

 

Are there any considerations I should be aware of?

 

With multiple passes and many things to turn on and off on the fly, one could end up with dozens of shaders depending on what effects are on and what effects are off.

Share this post


Link to post
Share on other sites

Is this just for debugging purposes?  If so, I'd probably add a float to a cbuffer and multiply the shadow value by that: passing zero would effectively disable the shadows.

 

If it was for something more performance/release oriented, then yeah I'd write the extra non-shadowed-shaders.

Share this post


Link to post
Share on other sites

Add a setting to your rendering pipeline to enable or disable shadows (and whatever other features you want) and upon rendering use the shader appropriate for your render settings.  That means a shader without shadows if shadows are disabled.

 

 

L. Spiro

Share this post


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