In GLSL, you have both if statements and the ternary operator in order to be able to evaluate which of two expressions should be used. This can be achieved using the select function which works like a ternary operator.

const aboveZero: BooleanNode = attributes.position.y().gt(float(0))
const displacement: FloatNode = select(
    // condition
    // if it is true
    pow(attributes.position.y(), 2), 
    // if it is false

The condition must be of type BooleanNode and the values need to be of the same type.

Last updated