I decided to do a CustomFunction node “hello world” in order to get familiar with it, but I’ve run into a weird issue.
I’m trying to start with a function that gets the direction of the main light in the LWRP. I do this by returning GetMainLight(), which is a function in LWRP’s “Lighting.hlsl”. So I created this HLSL file:
As you may notice, it gives me an error saying “undeclared identifier “GetMainLight””. I get that same error in the console too. However… the weird thing is that it seems to work perfectly well even if there’s an error:
Now I have many questions:
Why does it work and/or why is there an error?
Why does it want my function to be named “GetMainLightDir_float” even though I said I wanted it to be named just “GetMainLightDir”?
If I modify my .hlsl file with this include (where the GetMainLight() function is) in order to try to solve the error:
I haven’t tried this yet, but it may work to put your Custom Function node into a Sub Graph, then use that in your main graph instead.
Edit: Doesn’t work. Looks like every Custom Function needs to use a separate HLSL file until this is fixed, or use the string type and paste the function.