Swapping Sprite's Texture with shader

Node-based Shader Editor

Swapping Sprite's Texture with shader

Postby skipadu » Sat Jun 02, 2018 8:00 am

Hi,

I found one way to swap sprite's texture to a different one using the following:
https://github.com/RetryEntry/UnityAnimatorChangeSprite
It is working when switching texture for the object and animation works nicely without a problem.

I would like to learn to do this with Amplify Shader and get rid of other nonsense. Just want to swap the texture.
What node(s) I should use? If no texture is given, use the one already on the sprite renderer?

And it seems that because the shader I linked, is using surface shaders it does have some lightning info (?) and my sprite is getting a weird dark overlay on it.

Thanks in advance.
skipadu
 
Posts: 2
Joined: Sun Apr 22, 2018 7:20 pm

Re: Swapping Sprite's Texture with shader

Postby Amplify_Borba » Mon Jun 04, 2018 10:20 am

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

In order to change a sampler's texture, you'll have to do so via script. If you need to do it within the shader, you will have to sample additional textures and making use of the Logical Operators, which isn't as performant as simply doing so by script, or making use of a texture atlas, as per our ReadFromAtlasTiled sample.

If you don't want your shader to be affected by Unity's default lighting, you'll need to swap its Shader Type either to Unlit or to the Default Sprites shader template, since both types do not make use of that information and expect you to add your custom lighting setup.

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: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Swapping Sprite's Texture with shader

Postby skipadu » Fri Jun 08, 2018 7:34 pm

Thanks for the answer.

I did get it working by switching the sprite with the script.

So new to these shaders, so really not sure what should be done and where. But hopefully learning it piece by piece.
skipadu
 
Posts: 2
Joined: Sun Apr 22, 2018 7:20 pm

Re: Swapping Sprite's Texture with shader

Postby Amplify_Borba » Mon Jun 11, 2018 9:12 am

No problem, thank you for letting me know you've managed to get it working.

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: 1239
Joined: Mon Jul 24, 2017 9:50 am


Return to Amplify Shader Editor

Who is online

Users browsing this forum: Bing [Bot] and 31 guests

cron