- Home /
Alpha Blended Partiles Flickering
I'm wondering if there is an solution for alpha blended particles flickering when I have 2 emitters overlapping.
I require 2 emitters because I need 2 separate textures, and the additive particle materials make the particles wash out!
Any thoughts?
Thanks for your time!
Answer by Jessy · Feb 18, 2011 at 02:41 PM
You're describing Z-fighting. Add an Offset to the shader used for one of the particle emitters. Just copy the entire shader, and add the single line of code needed for offset. Offset -1, -1 will make the particles render in front, and Offset 1, 1 will make them render behind.
Shader "Particles/Alpha Blended" { Properties { _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5) _MainTex ("Particle Texture", 2D) = "white" {} _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0 }
Category { Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } Offset -1, -1 // This line could be here, or anywhere else before "SubShader". Blend SrcAlpha OneMinusSrcAlpha // ...
http://unity3d.com/support/documentation/Components/SL-CullAndDepth.html
Hands down the best support I've had on a website! Thank you very much!
I don't suppose you know where to find the built in shaders (for copying purposes)? I grabbed the built in shader pack from the Unity site, but that has a bunch of errors, possibly due to being an older version...
In Unity I cant seem to locate: Particles/Alpha Blended" to duplicate it or grab the code.
I looked through the project directories to no avail. Perhaps it's somewhere in the install dir.
Thanks again!
I just tested this and had no problems. I grabbed the file at the link I provided above, added the appropriate shader to my project, and added the Offset line to it. What are you doing differently?
Hey Jessy, Interesting! I downloaded the .zip package, and took the particle/Alpha Blended out and dropped it into my project. Unity then gave me 3 errors, as follows:
~Shader error in 'Particles/Alpha Blended': Program 'frag', undefined variable "UNITY_SA$$anonymous$$PLE_DEPTH" at line 71
~Shader error in 'Particles/Alpha Blended': Shader program had errors at line 25
~Shader error in 'Particles/Alpha Blended': GLSL vertex shader: ERROR: 0:264: 'fixed4' : syntax error parse error at line 24
I should note that these errors happen before I make any alterations to the shader!
-John