How do I connect game obj translates to shader property?

Node-based Shader Editor

How do I connect game obj translates to shader property?

Postby joedanimation » Tue Jul 24, 2018 6:29 am

Hello, I have a shader with properties that I would like to drive by the translates of an empty game object in my scene. Is there a way to draw that data into my shader?

I'm essentially recreating this shader I made in Maya (view at 23 sec into the video):
https://vimeo.com/220420802

Any help would be much appreciated :D
joedanimation
 
Posts: 2
Joined: Tue Jul 24, 2018 6:17 am

Re: How do I connect game obj translates to shader property?

Postby Amplify_Borba » Tue Jul 24, 2018 10:32 am

Hello, thank you for getting in touch!

Although it's possible to achieve this through ASE, you'll require some additional scripting in order to pass property values to the shader.

We do provide some samples which involve scripting, such as the Smear and the ForceShield, that you can examine for reference. In the Smear sample, the Smear.cs script passes the current and previous position through two global variables in the shader, while in the ForceShield sample the ForceShieldImpactDetection.cs passes the Hit Position data for the shader to know where to produce the hit effect, and the Hit Time to control when the effect starts.

Also, in the shader you can get the position for the object to which the shader is being applied to through Vertex / World Position, but if you want information from other objects, you'll need to pass it as a property.
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: How do I connect game obj translates to shader property?

Postby joedanimation » Tue Jul 24, 2018 7:04 pm

Thanks so much for the fast reply. That helped get me going in the right direction, and I was able to get it working just like I wanted.

Would it be possible to have Get/Set Global variable nodes in ASE?
joedanimation
 
Posts: 2
Joined: Tue Jul 24, 2018 6:17 am

Re: How do I connect game obj translates to shader property?

Postby Ricardo Teixeira » Wed Jul 25, 2018 2:09 pm

joedanimation wrote:Thanks so much for the fast reply. That helped get me going in the right direction, and I was able to get it working just like I wanted.
Would it be possible to have Get/Set Global variable nodes in ASE?


Awesome, happy to hear it!

What exactly do you have in mind?

You can set your variables to Global and have them be controlled via script; this defines a static variable that is shared between all shaders that use it, it's useful when you need to change a value globally.

Global Variables can be set to:
-Create: Property and/or global variable is created in the shader
-Fetch: No variable nor property is registered on shader, useful when you need to use global variables declared in a included cginc

Let me know, I would be happy to elaborate.
Sales & Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Ricardo Teixeira
 
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 0 guests

cron