- Home /
Are transparent shaders more efficient when they're 100% opaque?
OK, so I know that shaders with transparency costs more to render -- specifically in my case, I have to use the standard Transparent/Specular shader because there's no equivalent under the Mobile selection. And I don't have the knowledge or time to write one.
My question: When the shader is 100% opaque, is it more efficient? In other words, does the shader know when to skip a render pass if it doesn't need it?
The transparent effect I'm using is not during a performance critical part of the game so I'm hoping the answer is "Yes" but would like to know for sure.
I know I could probably swap out materials during run-time but would prefer not to if it can be avoided.
Thanks, Manny
Answer by tswalk · Jul 08, 2014 at 09:17 PM
Q: When the shader is 100% opaque, is it more efficient?
depending on the shader, more likely not. You could perhaps customize a shader to do branching, but on simple things branching is even less efficient (depending on how complex you need the shader to be).
As for 'render pass' is concerned, you need to think of it more in the sense of per pixel passes. You can make a shader with multiple passes, and the glass like shaders I've seen do.. but you don't necessarily need to do this for a simple alpha blend.
You could easily make a single pass, forward base render shader that uses blend "SrcAlpha OneMinusSrcAlpha" to get very basic and efficient transparent shader.
I would say, that in your case, using the unity provided shader may be sufficient, but the only way to know is to test it. Use it in a complex scene and see how it works. Otherwise, there's a bunch of low cost shader packages on the asset store, and i'm sure many have mobile ready.. some free, some not.
Your answer
Follow this Question
Related Questions
Shader performance question. 0 Answers
Same texture in different materials performance 2 Answers
Is having many instances of the same material bad for performances? 3 Answers
Material doesn't have a color property '_Color' 4 Answers
Very slow performance when I use scalled quad on a mobile device. 0 Answers