How to Flow Control in Material Custom nodes?

I want a node work like IF-Else.
I was thinking the “Code Expresson” work like C++… but i was wrong…

So… in this case, i want to use the Base Color ‘OR’ the emissive Color (Only one of them)

So, I tried this Code but it is not working like I expected.

return (Bool ? BaseColor=A : Emissive=A);

Any way to do what i want?

Thank you so much!!


UPDATE:


Ok… this way does work!!

But seems to be an unnecessarily complicated way.

How can i do the same in a single custom node?
Thank you so much!!

This works!!

if(BoolValue>0.0f)
{
	BaseColor=A;
	Emissive = float3(0.0f,0.0f, 0.0f);
	return BaseColor;
}
else
{
	BaseColor=float3(0.0f,0.0f,0.0f);
	Emissive=A;
	return Emissive;
}

For some reason the name “Bool” caused the error… must be a internal reservate word. So, i renamed it to “BoolValue” and it does work.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.