Transparent pixels and performance

Hello,

Does the transparent pixels on the edge of a sprite has an impact on the performance (for mobile devices)??
check the image below:
the first one have no transparent pixels on the edges unlike the second one.

Yes there is a difference. Since those pixels are see-thru, the pixels behind it must render first, then these transparent pixels will render and blend on top. That means instead of rendering that pixel location once, it renders twice. The more transparency you have overlapping, the more a single pixel location has to render.

If it were opaque (and using a non-transparent material), it would just render just once, because everything behind that pixel is hidden by it.

If you’re going for maximum device compatability and performance on mobile, avoid transparent shaders if possible.

actually, i was going to remove all transparent pixels from my sprites (converting them in indexed color in Photoshop then reconverting them into RGB), but using a non transparent shader seem to be easier, the problem is i don’t know how to use the shader with the sprites, unity does not give me the option.

Do You mean to add a new material to sprites

5288871--530673--unityI.JPG

I think your best option is to use the default sprite shader, but remove any semi-transparent pixels from your sprite. Just make sure every pixel is either opacity 0 or 1.

Unity doesn’t provide a default cutout-shader style sprite shader. So in order to use SpriteRenderer and sprite features, you would need to edit the default one which you probably don’t want to muck about with.

In the sprite settings, if your “mesh type” is set to “tight” it will try to shrink the sprite’s geometry so that the pixels with 0 alpha are cut out and don’t draw. You can further reduce overdraw by giving your sprites custom outlines in the sprite editor.

1 Like

Just for clarity (before you do too much work editing your sprites) – with regards to your original question, the goal with the default sprite shader is to reduce the mesh size so there are less pixels overlapping. So you can probably leave your sprites as-is and focus on making your Custom Outline as tight as possible in the Sprite Editor.

There would only be a notable difference if you were using a Geometry shader instead of a Transparent shader, but I’m not going to recommend coding a custom sprite shader just for that reason.

I’m unsure whether there is anything happening under the hood that differentiates between semi-transparent pixels and fully opaque pixels when using Sprites-Default. I just asked about this over here: Opaque sprites & default sprite shader render queue

Hopefully someone will clarify whether (while only using the default sprite shader) it makes any difference to make those transparent pixels opaque. An anti-aliased edge with transparency will definitely look nicer.

1 Like