+2
Under review

Multiple Shaders from single Node Tree ("Conditional Compilation")

Tomáš Mariančík 10 years ago updated 10 years ago 2
Hello,

I'd like a function which would generate multiple shader variants from a single node tree:

There would be "switch" node with several inputs and one output. It would be essentially compile time only - if I have one switch node with two inputs, it would generate two shaders - one with whatever is connected to the first input and second with whatever is connected to the second input (a bit like conditional compilation, which however generates all variants).

The inputs of the switch nodes would be controlled centrally - like in the "Shader Settings" where you would define the individual shaders you want to create and for each shader it would make an input node for all the switches.

This way, I could easily create multiple variants of a shader (either things that do similar, but different effects or simplified versions for mobile and such) without having to redo all the stuff for each variant that's shared - and have it in one place.

Thank you for consideration
Under review
This is planned, but won't happen anytime soon. The reason is that it makes shader code writing quite complex, at least if it needs to look good, which I'm trying to stick to at all times.

Sort of duplicate of: https://shaderforge.userecho.com/topic/333322-stat...
Oh cool! Sorry, I was searching under "multiple shaders" and "conditional compilation". 

Hmm, I thought that compile-time switch would make it the easiest to implement with existing system - for each shader variant it would essentially act like a relay node with other inputs acting like they're not even connected, so it wouldn't be that big of a change for the shader generating bits. Then again I don't know how is ShaderForge exactly written, anyway looking forward to this! :)