ShaderNodes flow

Hello,

I wrote a shader (par of shader nodes) containing a simplex noise function
but I need to work in different manners from one case to another

defines dont seem to be recognized, this dont work

MaterialDef Simple {
    Technique {

        Defines {
            SIMPLEX_GRAY : SIMPLEX_GRAY
        }
....
void main(){

#ifdef SIMPLEX_GRAY
  simplexColor = ...
#else
  simplexColor = ....;
#endif

seems SIMPLEX_GRAY is never considered by the compiler as if it was not defined and so the second code is generated instead of the first one

any idea ?

the alternative would be to use 2 different shader nodes definitions but I need to include the simplex code in both of them …

thanks

MaterialDef Simple {
    Technique {
        Defines {
            SIMPLEX_GRAY : SIMPLEX_GRAY
        }

This implies that you have a SIMPLEX_GRAY material parameter.
Usually you’d have a Boolean SimplexGray material param and the notation should be (in standard material)

MaterialDef Simple {
    Technique {
        Defines {
            SIMPLEX_GRAY : SimplexGray
        }

However with shader nodes, you just have to declare SimplexGrey as a material parameter and then use it in a condition

for example

ShaderNode MyShaderNode{
                Definition: whatever
                Condition : SimplexGray //<- that's the important part.
                InputMapping{
                    ...
                }
                OutputMapping{
                    ...
                }
            }

In the generated shader, all things relative to this shaderNode will be surrounded by a

#ifdef SIMPLEXGRAY" //note the uppercase.

And of course the Define will be defined if the parameter has been set
If you want to reference this define in your code for w/e reason you have to reference it in uppercase.

Note that the type of SimplexGrey can be anything, not necessarily a Boolean.