Sprite Crossfade Shader Help

Node-based Shader Editor

Sprite Crossfade Shader Help

Postby Treiger » Tue Oct 09, 2018 6:40 am

Hello,

I'm a bit of a noobie to shaders and so far, I setup this shader that lets me crossfade between two sprites using the Sprite Template:

Image

The crossfading part works just fine, but I found that the main texture of the sprite (from the Template Parameters) is masking the sub texture, so a part of it is cut off.

I offset the sub texture a bit to show this more clearly:

Image

You can see the masking of the sprite on the left side. My question is, how do I fix that? Is there a way to just overlay the sub texture on top, or do I need to mess with UVs or something? Thanks.
Treiger
 
Posts: 6
Joined: Tue Oct 09, 2018 6:33 am

Re: Sprite Crossfade Shader Help

Postby Treiger » Wed Oct 10, 2018 4:09 am

Okay, so I made the Mesh Type of the sprites "Full Rect" and now it's working properly. The problem now is that when I'm adjusting the fade slider back and forth, I noticed one of my CPU cores (and only one) spiking to near 100% usage and it's causing stuttering in the effect. Is it supposed to be like that? Is there a way to optimize it?
Treiger
 
Posts: 6
Joined: Tue Oct 09, 2018 6:33 am

Re: Sprite Crossfade Shader Help

Postby Amplify_Borba » Wed Oct 10, 2018 9:01 am

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

What Unity and ASE versions are you using? Does the CPU spike in the editor, play mode, build?
Can you replicate it in a new project with just ASE imported?

Seeing that you might have stumbled upon an issue, could you please send us a sample with that issue present, including shaders and textures, so that we can debug it on our side? If you'd rather share it privately, please use [email protected], 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: Sprite Crossfade Shader Help

Postby Treiger » Thu Oct 11, 2018 2:01 am

Hi Borba,

I'm on Unity 2017.4.7f1 and Amplify 1.5.6. It happens in editor and play mode. I made a Windows build, and it was completely fine. In play mode, there is a bit of an increase in the core utilization when I'm letting the script change the fade amount value, and a huge increase when I manually adjust the fade amount slider in the inspector.

The project only has ASE, the images, and the shader I made in it.

You can see here that my third core (though it varies) is spiking to 90% when I adjust the slider back and forth:

Image

I've sent the project file to the email.
Treiger
 
Posts: 6
Joined: Tue Oct 09, 2018 6:33 am

Re: Sprite Crossfade Shader Help

Postby Amplify_Borba » Thu Oct 11, 2018 9:07 am

Hello, we've ran a few tests on the sample that you kindly shared using the same Unity version and Unity's Profiler with V-Sync Off, but there seems to be no performance issue when running your project with the script toggled on. Have you tried forcing V-Sync Off?

The CPU usage data you've shared is quite odd, but likely to be unrelated to ASE or the shader itself, since shaders run on the GPU, so we would assume that it might be Unity related. Even with our editor canvas open, we didn't notice anything irregular.

Unfortunately, I don't think there's anything that we can on our side do regarding this matter.
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: Sprite Crossfade Shader Help

Postby Treiger » Fri Oct 12, 2018 3:29 am

Thanks Borba. I did some profiling of my own and found that it was the Unity editor. It's not too bad, so I can live with it since it's less pronounced in play mode and non-existent in builds.

I've added a dissolve effect now to the shader and I've run into what I believe is a bug.

Image

When connection from my append to the alpha channel of the lerp is a single line like that, the dissolve works (as you can see in the preview image), but it doesn't actually show up in the game. When I reconnect it and it has a triple line like so:

Image

It works completely fine. Do you think it's a bug? It turns back into a single line connection after I close the shader editor, and the effect stops working if I recompile it when it has that single link. I'm sending the project over to you via email in case you need it (I'm running Unity 2017.4.12f1 now). In that project, the dissolve slider shouldn't do anything until after you reconnect the alpha link between append and lerp and save the shader. Once you reopen the editor, the connection should be a single link again and the effect should stop working after saving it.
Treiger
 
Posts: 6
Joined: Tue Oct 09, 2018 6:33 am

Re: Sprite Crossfade Shader Help

Postby Amplify_Borba » Fri Oct 12, 2018 9:07 am

Hey, no problem!

Regarding the new issue you've reported, I'll be posting any developments here as soon as we have them, 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: Sprite Crossfade Shader Help

Postby Amplify_Borba » Fri Oct 12, 2018 10:11 am

Our developer was able to pinpoint this issue, rest assured that it has been fixed and it will soon be available in the next update, thank you for reporting it!
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: Sprite Crossfade Shader Help

Postby Treiger » Sat Oct 13, 2018 8:50 am

That's good to hear. Thanks again for the help Borba.

I just have one final question regarding the Step node. So from my understanding, it's suppose to set values to 0 or 1, depend on the A and B inputs. But in the shader, I see other values:

Image

Shouldn't the colors just be black and white? I don't understand where the other colors are coming from if the value of the color is only supposed to be 0 or 1.
Treiger
 
Posts: 6
Joined: Tue Oct 09, 2018 6:33 am

Re: Sprite Crossfade Shader Help

Postby Amplify_Borba » Mon Oct 15, 2018 9:17 am

No problem! The result you've shared is expected, as the node returns values of 0 to 1 per channel, and since you've connected the RGBA to the node's A input, the Step is being applied to each one of those channels, and the review is showing all of them simultaneously.

Please let me know if you have any 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

Next

Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 2 guests