Page 1 of 1

passing variables from includes to shader

PostPosted: Mon Jan 15, 2018 6:29 pm
by cyble
Hi there,

I'm using a .cginc file to do some procedural stuff that's executed by instancing_options procedural:setup.
But now I need to access a variable from my .cginc from within amplify shader editor.

This is where I thought global variables should came in handy.
But all globals are declared after the include and therefore not seen by my include file.
Manually moving the global variable to the top solves the issue but is of course not very efficient doing this after each refresh of the shader :) .

Does someone know if there is another option I can pass data along from my include that I missed ?

Thank you,

Cheers,

Dennis

Re: passing variables from includes to shader

PostPosted: Mon Jan 15, 2018 6:43 pm
by Amplify_Borba
Hello Dennis, thank you for getting in touch and for your support!

Have you added your .cginc file to the "Additional Inclues" in the Main Node properties?

Please refer to our Curved World example in the manual which exemplifies how to setup a .cginc file with ASE, and do let us know if this helps you out.

Looking forward to your reply!

Re: passing variables from includes to shader

PostPosted: Mon Jan 15, 2018 7:25 pm
by cyble
Hi Amplify Borba!

Thank you for your answer. Didn't know about the custom expression node (much like the code node in shader forge which I missed until now) !

Which was exactly what I needed and is a much better solution for my problems in the long run too!

So all is working perfectly now and thanks again for your quick and helpful response!

cheers! :D

Re: passing variables from includes to shader

PostPosted: Tue Jan 16, 2018 9:41 am
by Amplify_Borba
No worries, glad I could help you find a better solution!

Have you had the chance to rate and review Amplify Shader Editor? It would be awesome if you could share your experience with the Unity community, the Unity Asset Store thrives on user interaction and direct feedback. Every bit helps, your feedback is extremely valuable to us.

Feel free to get back in touch if you have further questions, thanks!