- Home /
PNG's with Translucency, and Optimization
Hi everyone, I've been working on optimization for my levels but I'm a bit confused about translucency. One common tactic I've noticed in games is to reduce what could be a complex model into a single surface.
An example from Dishonored:
I've seen countless examples of this in games, but what I don't understand is why the textures never appear to have anti aliasing, leaving very rough edges between the solid and the transparent like in the example above.
Here's a grass texture I found:
This one has a translucent edge and looks much better. Is there a reason that the pixels of the PNG should only be at 100% opaque or 0% opaque and that anything between would slow things down? I have tested this myself in Unity and I see no performance difference between either method. But if this is the case, than why do so many games do this? Is there a reason I should be avoiding translucency when using PNGs like this? I would really appreciate any suggestions.
The reduction to a single surface is called Bill boarding, nice question BTW. $$anonymous$$y guess is that the opacity bits would be encoded as 1 or 0 ins$$anonymous$$d of 0.66857524631524 which is easier to process.
An obvious sharp border between opaque and transparent probably means they're using sub meshes. As to why -- maybe Unreal just makes that way easier to do.
And, of course, overlapping partly transparent objects can be tricky.
Answer by supernat · May 26, 2014 at 05:32 AM
In shaders (this goes back to the original fixed function pipeline design), you have two options with regard to alpha: 1) reject a pixel with an alpha value less than some threshold (Alpha Testing) (which is what you see) or 2) blend the alpha with the background. By design, the 1st is much faster (it used to be anyway), because you don't have to perform any blending. The pixel in the non-opaque areas is just immediately tossed out and the color buffer remains with the last color. When you alternatively use the 2nd approach, you have to blend all of the texture, so even places with zero opacity will take a hit, and the actual blending itself is a bit heavy. They don't specifically call this out as the reason on this linked page, but I think they are doing a two pass render to optimize the speed: https://docs.unity3d.com/Documentation/Components/SL-AlphaTest.html
Your answer
Follow this Question
Related Questions
How do I soften the edges of a transparent Plane texture 1 Answer
Mobile shader with transparent rendering mode 1 Answer
How to use Transparent Material ? 0 Answers
How to make a part of a texture transparent? 0 Answers
Problems with Textures 2 Answers