Having an array of positions for a desired effect
Posted: 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:
And the result, as expected was this:
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:
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.
And the result, as expected was this:
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:
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.