Page 1 of 1

Sprite Outline thickness (noob question)

PostPosted: Thu Jun 21, 2018 1:53 pm
by wintermute
Hi everybody!

I googled before asking here, and I tried to replicated the following answer:
Code: Select all
fixed4 pixelUp = tex2D(_MainTex, IN.texcoord + fixed2(0, _MainTex_TexelSize.y));
                    fixed4 pixelDown = tex2D(_MainTex, IN.texcoord - fixed2(0, _MainTex_TexelSize.y));
                    fixed4 pixelRight = tex2D(_MainTex, IN.texcoord + fixed2(_MainTex_TexelSize.x, 0));
                    fixed4 pixelLeft = tex2D(_MainTex, IN.texcoord - fixed2(_MainTex_TexelSize.x, 0));


So I ended up with something like this:
Image

Which seems maybe to big of a sheet but short of works nevertheless.

My problem is that I don't know how to translate the float thickness property into real pixels width so I can controll the number of pixels it is thick. Right now every different sprite has a different outline width. Also scaling a sprite scales the outline too.

How can I tell a shader that a property means pixels?

Thank you.

Re: Sprite Outline thickness (noob question)

PostPosted: Tue Jun 26, 2018 10:53 am
by Ricardo Teixeira
Hello,

Thank you for getting in touch, always happy to help!

Unfortunately, the technique used does not allow you to set a fixed, size-independent, thickness value per-object.

The effect you're looking for is best achieved using a scree-based solution such as the image effect below.

Sprite Outline FX

Looking forward to see what you create.