- Home /
which is the most efficient additive transparent shader?
I can't seem to get decent frame rates with any of them on a couple of large objects in the scene.
Answer by Jessy · Dec 27, 2010 at 08:49 AM
I'll assume you just need a texture. Let me know if you need further functionality. Also, please tell us what the target platform is; this one would be ideal for iOS, but a desktop variant could run faster if alpha testing were involved. And if this is for iOS, and your specific target platform is iPad or anything with a retina display, then you might just be out of luck, because the GPUs in those devices don't have the fill rate necessary to run shaders that require overdraw, with a reasonable framerate.
Shader "Additive Texture" {
Properties { _MainTex ("Texture", 2D) = "" }
SubShader { Tags {Queue = Transparent} Blend One One ZWrite Off Pass { SetTexture[_MainTex] } }
}
Your a $$anonymous$$e of information. Yes, this is for iOS. And during testing had some abysmal frame rates in webplayer as well. From what you're saying I should try avoid big objects with alpha textures used for additive effects on iOS? Is there any difference how I bring the alpha'd textures in? eg PNG, PSD, Tiff etc? 2... I think I'll move this to Forums, you think there's an advantage to structuring multiple planes in a grid so that screen culling gets rid of overdraw on large objects? Or is the cost of more objects going to negate the gains?
An alpha channel can be useful on the desktop, because you can choose to only conditionally render pixels to the color buffer (which takes time), based on alpha testing. But this interferes with the way the POWERVR GPUs "want" to render things, which involves collecting everything in the scene and THEN deciding what not to render. So, although you can alpha test on iOS, this is not a good case for it; just additively blending black should be faster.
Let me know if you experience a speedup with this; it should be noticeably faster than "$$anonymous$$obile/Particles/Additive Culled", which uses an alpha test, and "Color$$anonymous$$ask RGB", both of which are no-nos on iOS (at least currently).
File format doesn't matter at all; I use PSDs for Photoshop files, because Unity can import them directly, and PNGs, generally, from Illustrator, because they are uncompressed, and still small. Use whatever is easiest for you, but you should not need alpha at all, with this additive shader.
I'm not sure what you mean about this "grid". Please do link to a forum post.
will do. Your tip on using additive and black backgrounds without alpha may be the single best thing I've learned this year! Certainly about Unity shaders at any rate. Sensational tip. Where's the sticky for that tip and your shader code? Oh, that's right, it's Unity.Answers... not Unity.Helpful.Resource I'll start another question explicitly so you can answer with this feature regarding your shader and black background images as textures in additive.
Your answer
Follow this Question
Related Questions
Transparency issue on iOS 1 Answer
Transparent Shader performance, intermediate-advanced question? 0 Answers
Rendering a plane is dropping 10 fps 0 Answers
transparent shader 0 Answers
Semitransparent shader not visible in front of objects 1 Answer