Drawing pixels outside of a Sprite's texture

leoddleodd Posts: 2Member

Basically, I'm trying to get rid of this issue I have with my shaders that are supposed to draw outside of a Sprite's texture, like outlines, glow etc.

My only somewhat working attempt so far has been to extend the Sprite's vertices and then scaling down the UV in the fragment shader, successfully leaving me with extra pixels around the Sprite for my shaders to write to.

My issue now is that pixels outside of a Texture's area are read as copies of the last pixel row/column, leaving me with this:

Is there a way to fix this or make the shader read all those pixels as fully transparent? Changing the Repeat flag on image import can change those rows to be repetitions of the sprite, but there's no option to paint the area outside of the texture as transparent.
If anyone knows another way to fix this issue (that isn't giving every image file 20 pixels of transparent edges), I'd be all ears as well. More interested in getting it working than making my code work.

Answers

  • MegalomaniakMegalomaniak Posts: 309Member

    One idea could be masking, possibly by using vertex colors for an example?

  • leoddleodd Posts: 2Member

    How exactly do you mean?

  • MegalomaniakMegalomaniak Posts: 309Member

    Sorry been a bit busy elsewhere...

    I'm sorry to say that I initially misread your post and thought you said:

    "My only somewhat working attempt so far has been to extrude the Sprite's vertices..."

    instead of:

    "My only somewhat working attempt so far has been to extend the Sprite's vertices and then scaling down the UV in the fragment shader, successfully leaving me with extra pixels around the Sprite for my shaders to write to."

    Ok, so derived from UV coordinates you could construct a black and white mask(minmaxing the X and Y[or U and V if you'd rather] coordinates) that you can lerp between the relevant part of the sprite and say a solid color for the outline. Alternatively based on your example gif you have a alpha channel to work with.

Sign In or Register to comment.