- Home /
Shadergraph Custom Function undeclared identifier
Hi all!
I am trying to get into the Custom Functions with the Shadergraph and got myself stuck. Whenever I try to make really simple customFunctions (via the string option) my out values throw the error undeclared identifer _CustomFunction_XYZ_outParam_2. When I try to declare it in the body I get the error redefinition of formal parameter 'outParam'.
I really couldn't find any solution to this in the forum. Help would be really appreciated.
Answer by JonPQ · Jul 15, 2020 at 11:36 PM
Solved the Undeclared Identifier issue... if you right click your custom node after you converted it to a sub graph. and select "view generated code" then search for your function name... say its called CustomBlurNode.... when you find it in there.... it will either be called CustomBlurNode_float or CustomBlurNode_half. Unity adds this on the end, it is the precision. Now go back into the Main Shader and you SubShader and check the precision settings... ( its in the top left corner of the screen, you can select Precision float or Half. ..and also in your Node ( click the gear icon ) it also has a precision set to Inherit, float or half. If you match all these up... the error disappears. ! for example, if unity names your function _float but your node is set to inherit. and the parent graph is set to Half. then it won't find the correctly named function. It might be possible to define 2 functions ? cut'n'paste job, one for each precision, but I didn't try that. Matching the precision worked for me.
Answer by weltraumimport · May 01, 2020 at 01:10 PM
I use Unity 2019.3 and have the exact same issue.
same, unity 2019.3. cannot use a file as shader, cannot convert a custom 'string' node to a sub graph without getting. UndeclaredIdentifier errors, that don't make sense. Where are the docs ? (outdated / deprecated) where are the tutorials ? ...none. just need one simple working example... I can't find one anywhere, except the string-type Custom node, and I still can't convert those to a sub graph. sad :( any asset store stuff work better than this ?
Answer by disuperguy · Aug 28, 2020 at 04:39 PM
maybe you need to use a PBR graph??? The bug stopped for me and im in unity 2020 with it in a sub graph