Sprite template

Node-based Shader Editor

Sprite template

Postby zigtom » Sun Oct 15, 2017 7:49 am

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?
zigtom
 
Posts: 4
Joined: Sun Oct 15, 2017 7:46 am

Re: Sprite template

Postby zigtom » Sun Oct 15, 2017 3:36 pm

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
zigtom
 
Posts: 4
Joined: Sun Oct 15, 2017 7:46 am

Re: Sprite template

Postby Amplify_RnD_Rick » Mon Oct 16, 2017 10:59 am

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 5185 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!
Amplify_RnD_Rick
 
Posts: 40
Joined: Wed Mar 01, 2017 6:33 pm

Re: Sprite template

Postby zigtom » Tue Oct 17, 2017 2:28 am

Thanks so much. Thats exactly what I needed to know.
zigtom
 
Posts: 4
Joined: Sun Oct 15, 2017 7:46 am

Re: Sprite template

Postby Amplify_Borba » Tue Oct 17, 2017 10:03 am

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!
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 template

Postby zigtom » Wed Oct 18, 2017 5:05 am

Done! Its the one from tomzigza
zigtom
 
Posts: 4
Joined: Sun Oct 15, 2017 7:46 am

Re: Sprite template

Postby Amplify_Borba » Fri Oct 20, 2017 9:08 am

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!
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: No registered users and 0 guests