Download

Material 'If' Node Misbehaving?

This is an odd one, I’m getting a compiler error with this material even though I know I’m certainly giving it the correct parameters…

The error I’m being given is that Input A must be of Type ‘Float’ - which it definitely is, since I’m masking it right beforehand!

The If Node:
21737545e3f04a915121367576ece4d5650093db.jpeg

The Ray Intersect Function:
0446caf62da7e7dd5babbf49ef0254eead2bce7f.jpeg

This is part of my ongoing attempt to bring in a seamless Ground > Space Rayleigh and Mie Scattering Shader, but I’m hitting hundreds of brick walls along the way, mainly with loops and suchlike.

What about using the “SplitComponents” material function?

And btw, your blue marble project looks absolutely amazing :smiley:

I would also use the BreakComponents function instead of the mask.
However I would put it into the function. Maybe as a second output, if you use the whole output value elsewhere.
If not just make the function output only the R channel…

If the output only goes to the mask node, it can be refactord into the function… :slight_smile:

Break Components doesn’t do anything differently to what I’m doing, it’s just three different mask nodes.

@bogieman - thanks :slight_smile:

Hey -

A quick thought have you made sure that your Function Inputs in the Material Function are set to use default values? If not that can throw an error on the IF as some vector conversion is not occurring in the function.

Hey Eric, yeah everything other than the Radius uses a default value (which is plugged in in the above pic).

I can upload the material graph tomorrow if it’s any help!

If you write out the If function in a custom node, does it compile?

Oddly enough, yeah it does. Will post the whole mat graph later with and without, perhaps it’ll show what’s occurring.

Panic over, figured it out.

My own fault, I’m trying to take the Sqrt of a Vector, then Append onto that and return it via the If. The If doesn’t know if it should be returning a Float2 or a Float4 (It can’t be one or the other at any given time, for obvious reasons). There’s nothing wrong with input A. Long story short, I create the nodes wrong but the error message wasn’t very indicative of where the error was.