Could someone explain in detail what the "If Else" shader node does?

IceEmpressIceEmpress Posts: 639
edited December 1969 in The Commons

I've seen it described, but I still don't understand it. I also need multiple examples of how it would be used.

Comments

  • Richard HaseltineRichard Haseltine Posts: 100,784
    edited January 2014

    Feed a test into the If input, for example from a Compare brick, the value you want when the test iss true into the Value input and the value you want if the test is false into the false input. This simple network makes the surface black if it is on the right of the UV map (s greater than 0.5) and white otherwise.

    ShaderMixerIfBrickEx.JPG
    1748 x 827 - 84K
    Post edited by Richard Haseltine on
  • Lissa_xyzLissa_xyz Posts: 6,116
    edited January 2014

    Is it safe to assume the if/else brick works just like an if/else statement in coding?

    Post edited by Lissa_xyz on
  • mjc1016mjc1016 Posts: 15,001
    edited December 1969

    Vaskania said:
    Is it safe to assume the if/else brick works just like an if/else statement in coding?

    Ummm...yeah.

    Basiclly RSL IS coding...and ShaderMixer bricks are 'libraries' or code snippets you connect to get your final code to compile.

  • IceEmpressIceEmpress Posts: 639
    edited December 1969

    what does "true" and "false" mean in this context?

  • Herald of FireHerald of Fire Posts: 3,504
    edited January 2014

    opal42987 said:
    what does "true" and "false" mean in this context?
    As in programming, True/False is basically a simple yes/no. In the case of a 'yes' the value is 1, in the case of a 'no' the value is 0.

    As an example, you have a black and white opacity map. White represents 'True' in this instance, and black represents 'False' (in actuality, any value over 0.5 is usually considered 'True', so do bear this in mind if using grey). You could use this to, for example, apply 'holes' in an object and, using the If Else brick, fill those empty holes with a metallic surface. This would allow you to place a metallic overlay onto an object using simple alpha maps.

    In code, the If Else statement works like this

    If statement_is_true
     Do_this()
    Else
     Do_something_else()
    EndIf
    In the case of the shader brick, the "Value" labelled result is the one returned when the statement is true, and the "Else" result is returned when the statement is false. Hopefully that simplifies rather than overcomplicates it.
    Post edited by Herald of Fire on
  • IceEmpressIceEmpress Posts: 639
    edited February 2014

    SO how would it work/what could it do when plugged into say-- a specular or gloss node?

    (This is still very difficult for me to understand... How would a simple yes/no true/false pure black/pure white function allow for a LIE/layered image?)

    Post edited by IceEmpress on
  • mjc1016mjc1016 Posts: 15,001
    edited December 1969

    More often used on input variables or things like shadows...set on/off conditions, test vectors directions and stuff like that.

Sign In or Register to comment.