Amplifying your potential.

Texture Animation Offset based on world position Issue

Your feedback is very important to us. We are listening.
6 posts • Page 1 of 1

Texture Animation Offset based on world position Issue

Postby sjuskadur » Tue Aug 07, 2018 5:09 pm

Hey!

Im having an issue. I am playing an animation on a texture on multiple objects in view, and I want to offset the animations so I cant see the tiling.

I have been using: Time (t/20) -> Object to world (x axis) -> Abs (so i dont get reversed anims) and then plug that into the animatioin time.

This works but there are issues with this. if the object is on 0,0,0 the animation is stopped but if I move it on the x-axis the animation it plays faster the higher the value is (100,0,0 is faster than 10,0,0).

Using clamp does not work since it does something to the time making it stop completely,

Using Remap can help but the higher the X transform is the faster it goes. but It does not pause the anim at 0,0,0.

I need something that can modify the time based on world position or a random number generator.

any help would be greatly appreciated.

best

G
sjuskadur
 
Posts: 6
Joined: Tue May 29, 2018 2:04 pm

Re: Texture Animation Offset based on world position Issue

Postby Amplify_Borba » Wed Aug 08, 2018 9:25 am

Hey there, I strongly recommend that you take a look into our Simple GPU Instancing sample, as it's one of the best approaches for providing random values to your shader, which is through scripting.

If you'd rather generate pseudo random numbers through specific node setups, you can refer to the example I'm sharing below, which tints an object based on its position. We're using this "random" value appended as a float2 that will go into the TintTexture UV to define which one of its colored pixels will be used as tint, which is multiplied by a MainTexture in order to apply the tint

Image

This is just one of several ways of simulating a random effect through a shader but, in order to achieve proper random values, you'll have to resort to scripting.

Do note that dynamic batching will likely influence your object position resulting in incorrect/unexpected results, be sure to use GPU Instancing in order to avoid possible issues.

Please let me know if this helps, 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: 880
Joined: Mon Jul 24, 2017 9:50 am

Re: Texture Animation Offset based on world position Issue

Postby sjuskadur » Wed Aug 08, 2018 12:01 pm

Thanks for the quick reply!

Amplify_Borba wrote:Hey there, I strongly recommend that you take a look into our Simple GPU Instancing sample, as it's one of the best approaches for providing random values to your shader, which is through scripting.


I am a technical novice when it comes to shader creation as I dont have any coding knowledge or background, but I can clamber things together to look the way I want them to look X) So scripting is not really an option for me.

I did manage to get the result I wanted though, with this:

Image

Thanks for the help!
sjuskadur
 
Posts: 6
Joined: Tue May 29, 2018 2:04 pm

Re: Texture Animation Offset based on world position Issue

Postby Amplify_Borba » Wed Aug 08, 2018 1:42 pm

No problem, thank you for sharing your 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!
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: 880
Joined: Mon Jul 24, 2017 9:50 am

Re: Texture Animation Offset based on world position Issue

Postby sjuskadur » Wed Aug 08, 2018 3:10 pm

I will review it and all the unity devs I know already use amplify =)

I realized I jumped the gun on my solution, and the solution is a bit messy since I have to use some really big numbers but it works

Image

Values that worked for me were

LocTimeDiv: -1000 (since i play the anim in reverse for this purpose)
TimeDiv: -1
NeverLessThan: -0.1

This is the solution until I make the programmers sad.
sjuskadur
 
Posts: 6
Joined: Tue May 29, 2018 2:04 pm

Re: Texture Animation Offset based on world position Issue

Postby Amplify_Borba » Thu Aug 09, 2018 8:34 am

Thank you, we really appreciate it, please let us know if you have any further questions!
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: 880
Joined: Mon Jul 24, 2017 9:50 am


6 posts • Page 1 of 1

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest