Having an array of positions for a desired effect

Node-based Shader Editor

Re: Having an array of positions for a desired effect

Postby Ricardo Teixeira » Tue May 08, 2018 10:42 am

Giantswing wrote: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


Fantastic, glad to know you were able to find a viable solution!

Sounds like a tricky situation, I hope the loop is not detrimental to your game performance down the road.

Be sure to let us know if you ever run into any additional issues.
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 Jar » Fri Feb 15, 2019 12:55 pm

Hey ho,

i tried a simple grass shader where multiple players and enemies can react with.

When i use

Code: Select all
// for loop above
Shader.SetGlobalVectorArray("positionsArray", vectorPositions);


nothing seems to work correctly.

But if i tried Ricardo Teixeira approach, i can manipulate the "Global Array" from my c# script.
Code: Select all
// for loop above
materialProperty.SetVectorArray("positionsArray", vectorPositions);
myRenderer.SetPropertyBlock(materialProperty);


Is it possible to use SetGlobalVectorArray?
I just want one simple script which send the vectorPositions to all grass materials instead of caching and extending a list of meshRenderers to use SetVectorArray()


Image

Btw. how should this generated code work?^^
Code: Select all
      float ForLoop345(  )
      {
          for(int i=0; i<positionsArray.Length; i++){
         return i;
         }
      }


Maybe my real question is, how can i iterate through an global array.
If i edit the generated code, i can simple insert a for loop, but i can't edit my shader after that :(

I revived this thread because its the number one hit if i google this topic.

Best regards,
Jar
Jar
 
Posts: 2
Joined: Fri Feb 15, 2019 12:44 pm

Re: Having an array of positions for a desired effect

Postby Amplify_Borba » Fri Feb 15, 2019 4:49 pm

Hello, thank you for getting in touch and for your support!

We've shared a sample on how to iterate through an array using a Custom Expression node in this topic, which was also referenced in this thread.

This post is also a good source of information regarding what you intend to do.
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 Jar » Fri Feb 15, 2019 5:02 pm

Thank you for the fast replay. I'll will take a look. The second link is totally new for me :D
Jar
 
Posts: 2
Joined: Fri Feb 15, 2019 12:44 pm

Previous

Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 9 guests

cron