Page 1 of 1

Sprite template

PostPosted: Sun Oct 15, 2017 7:49 am
by zigtom
I just purchased this tool and it looks very promising.
I wanted to try it out with a UGUI sprite as per the documentation saying it has sprite support.
I created a default sprite template and I am able to effect change on my UGUI Image component. However I am confused on a point. How do I perform operations on the main texture instead of providing another texture. I would like my shader to take whatever the image it is on, and greyscale it. However to get grayscale to work I had to drag a texture into my shader(which now makes it not dynamic) and then greyscale from that into the final sprite template node you have at the start.

So basically how do I use the main texture as my source of color?

Re: Sprite template

PostPosted: Sun Oct 15, 2017 3:36 pm
by zigtom
As an example I was able to edit the shader after using your grayscale as a starting point to do this like so:

fixed4 frag(v2f IN ) : SV_Target
{
fixed4 c = SampleSpriteTexture (IN.texcoord) * IN.color;
float oldA = c.a;
c = (Luminance(c.rgba)).xxxx;
c.a = oldA;
c.rgb *= c.a;
return c;
}

However it would get lost if it regnerated

Re: Sprite template

PostPosted: Mon Oct 16, 2017 10:59 am
by Amplify_RnD_Rick
Hey zigtom,

Thank you for reaching us and using ASE!

We have a node called Template Parameter which allows you to use shader properties or global variables that are already declared on the template.

In your case you'll create a Template Parameter node and it will have the Sprite Texture parameter selected by default, which is the one you want.

By having that parameter selected this node will behave like a Texture Object so you will need to connect it to a Texture Sample node in order to fetch its color value.

After that you can use our Grayscale node to grayscale the color value.
Here's a quick snippet on an example:
GUIGrayscale.jpg
GUIGrayscale.jpg (60.92 KiB) Viewed 5281 times


We've placed a Lerp in there associated with a Float shader property just to allow you to define the amount of grayscale you want.

Please don't hesitate on reaching us if you need further clarification!

Re: Sprite template

PostPosted: Tue Oct 17, 2017 2:28 am
by zigtom
Thanks so much. Thats exactly what I needed to know.

Re: Sprite template

PostPosted: Tue Oct 17, 2017 10:03 am
by Amplify_Borba
No worries, glad we could be of assistance!

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 issues or questions, thanks!

Re: Sprite template

PostPosted: Wed Oct 18, 2017 5:05 am
by zigtom
Done! Its the one from tomzigza

Re: Sprite template

PostPosted: Fri Oct 20, 2017 9:08 am
by Amplify_Borba
Thank you for your review and rating, we work hard on a daily basis to provide quality products and support, so it truly means alot to us!