Having an array of positions for a desired effect

Node-based Shader Editor

Having an array of positions for a desired effect

Postby Giantswing » Sat May 05, 2018 12:51 pm

Hi everyone! First post here and first shaders with amplify, I was trying to create some sort of shader for a plane where if the player where near the texture changed, and it worked, the nodes where super simple and they looked something like this, I also created a C# script that changed the _PlayerPosition property with the actual player position:

Image

And the result, as expected was this:
Image


But how would I do it if I wanted this effect to apply to multiple objects without having to manually create multiple Vector3's or working dinamically if I created new objects during gameplay?

Thanks in advance! And sorry for my poor english!

EDIT1:Okay quick update:
I have been able to make some progress by using the Global array node and through C# create a MaterialPropertyBlock and settings and array of positions there then setting that property block to the renderer of the Plane

Then if I have 3 different spheres and in the index of the Global Array node set it to 0, the first sphere will have the effect, now the problem is, how do I iterate through an array inside of amplify? Is this possible?

Thanks again!!

EDIT2: Another update on the subject!
I have tried using Custom expression node to inject a for in this fashion:

Image

And connect that to the index of the Global Array input and... It works! Well kinda, not really, the thing is that it works but it always returns a 0 so only the first sphere has the effect, I know the custom node is "working" because if I change it to (int i=1; i<3;i++) it returns a 1 and has a different sphere with an effect, but it doesnt iterate through it anyway.
Last edited by Giantswing on Sat May 05, 2018 1:39 pm, edited 1 time in total.
Giantswing
 
Posts: 11
Joined: Sat May 05, 2018 12:44 pm

Re: Having an array of positions for a desired effect

Postby Giantswing » Sat May 05, 2018 2:10 pm

Dang! No luck so far, this is a head scratcher for me, so far the node setup looks like this:

Image

Result:

Image

C# code:

Image
Giantswing
 
Posts: 11
Joined: Sat May 05, 2018 12:44 pm

Re: Having an array of positions for a desired effect

Postby Amplify_Borba » Mon May 07, 2018 1:15 pm

Hello! The Global Array seems to be the correct node for your intended effect, could you provide us with a simple sample project with what you've built so far in order for us to best help you?

Thanks!
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: Having an array of positions for a desired effect

Postby Giantswing » Mon May 07, 2018 5:08 pm

Yeah sure I'll upload it right away but everything is in the previous post that I made, I just want to have an effect happen to multiple positions at the same time, the global array node works but I can only fetch it one index not the three of them in the example above

As soon as I finish uploading the file I'll post it here
Giantswing
 
Posts: 11
Joined: Sat May 05, 2018 12:44 pm

Re: Having an array of positions for a desired effect

Postby Ricardo Teixeira » Mon May 07, 2018 5:58 pm

Giantswing wrote:Yeah sure I'll upload it right away but everything is in the previous post that I made, I just want to have an effect happen to multiple positions at the same time, the global array node works but I can only fetch it one index not the three of them in the example above

As soon as I finish uploading the file I'll post it here


Thanks, we'll be sure to check it out tomorrow, we just needed to be sure we had all elements.

Until then, be sure to check THIS somewhat similar thread.
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

Re: Having an array of positions for a desired effect

Postby Giantswing » Mon May 07, 2018 6:32 pm

Here is the link for the download, sorry for not using the attach file here in the forum, it kept getting stuck and never finished uploading:

https://drive.google.com/open?id=1DXleFKmP7H2hgrP35RFFb_nLaXs8cwWM

Also I looked over the post you sent me to and seems super interesting and quite similar to what I wanted to do but... it kind of makes you make the whole shader inside of the custom expression node doesnt it? I mean at that point is not that much worth it to not make it entirely inside of code right? I dont mean this in a bad way at all I'm just trying to learn how this works

Again, thanks for your patience
Giantswing
 
Posts: 11
Joined: Sat May 05, 2018 12:44 pm

Re: Having an array of positions for a desired effect

Postby Ricardo Teixeira » Mon May 07, 2018 6:45 pm

Giantswing wrote:Here is the link for the download, sorry for not using the attach file here in the forum, it kept getting stuck and never finished uploading:

https://drive.google.com/open?id=1DXleFKmP7H2hgrP35RFFb_nLaXs8cwWM

Also I looked over the post you sent me to and seems super interesting and quite similar to what I wanted to do but... it kind of makes you make the whole shader inside of the custom expression node doesnt it? I mean at that point is not that much worth it to not make it entirely inside of code right? I dont mean this in a bad way at all I'm just trying to learn how this works

Again, thanks for your patience


Thank you for the file.

I understand what you mean, the tricky part is really how to manage the Array data in this shader context. You could very well simply receive the values and handle them in the shader using nodes but it really depends on what you need to build.

We'll be sure to get back you tomorrow with additional information.
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

Re: Having an array of positions for a desired effect

Postby Giantswing » Mon May 07, 2018 7:12 pm

Okay I got it working! That last post you send me to really made me think of ways of doing it, and I could make it using nodes too, I just did some small calculation in the custom node, thanks thanks thanks!
Image
This opens me a whole array of options :P

The only thing that concerns me now is that from the little experience I have I've heard that for loops aren't very good for shader optimization, would there be a better way of doing this?

But seriously thanks for the help, you guys are awesome!
Giantswing
 
Posts: 11
Joined: Sat May 05, 2018 12:44 pm

Re: Having an array of positions for a desired effect

Postby Ricardo Teixeira » Mon May 07, 2018 7:17 pm

Giantswing wrote:Okay I got it working! That last post you send me to really made me think of ways of doing it, and I could make it using nodes too, I just did some small calculation in the custom node, thanks thanks thanks!
Image
This opens me a whole array of options :P

The only thing that concerns me now is that from the little experience I have I've heard that for loops aren't very good for shader optimization, would there be a better way of doing this?

But seriously thanks for the help, you guys are awesome!


Awesome, that was pretty fast!

Can you share a sample? We would be happy to check it out as soon as we're back at the office.

Indeed, loops are not ideal. I was actually going to ask you if you have a dynamic object limit in mind; passing a fixed set of positions could likely help reduce processing costs.

Thanks!
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

Re: Having an array of positions for a desired effect

Postby Giantswing » Mon May 07, 2018 8:25 pm

Sure! Here it is: https://drive.google.com/open?id=1X6fOiq4VXz62EwBMnjxoz8F1l1kgsgbr

The nodes are super messy I'm sorry about that, I was just trying stuff out

About the for loop yeah I thought about a dynamic system because this effect was meant for some enemies in a FPS and I wouldnt know from the get go how many of them there would be in a given moment, also if they die the array should update so maybe a for loop is just a necessary evil in this case
Giantswing
 
Posts: 11
Joined: Sat May 05, 2018 12:44 pm

Next

Return to Amplify Shader Editor

Who is online

Users browsing this forum: Google [Bot] and 7 guests