unity_InstanceID undefined

Hello.

I’m trying to get procedural instancing to work in shader graph. As far as I can tell, I followed this approach:

However, the graph doesn’t compile because I use unity_InstanceID(as given in the referenced answers). It keeps being undefined. (undeclared identifier 'unity_InstanceID' at ...).

I know from the sources that this variable willbe defined ifa couple of conditions are met, having PROCEDURAL_INSTANCING_ON amongst others. It is even described here:

Nevertheless, I did’t succeed in getting it to work.
Can someone point me to more secret documentation, or otherwise help me out?
Thank you!

Solution:
In “Graph Inspector”, I had to remove the leading underscore in field “Reference” from _PROCEDURAL_INSTANCING_ON (which was generated when adding the keyword) to the name of the keyword. Then, I inspected the generated code and saw that, for the very first time, I was on the right track regarding the preprocessor definitions. Subsequently, the compiler error mentioned in the original post was resolved.

EDITED: Moved new issue to new thread.

1 Like