x


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!

more ▼

asked Feb 18 '11 at 02:16 PM

Emericanized gravatar image

Emericanized
31 6 9 13

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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

http://www.youtube.com/watch?v=MlLvQxZv3h4

more ▼

answered Feb 18 '11 at 02:41 PM

Jessy gravatar image

Jessy
15.6k 72 95 196

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!

Feb 18 '11 at 03:36 PM Emericanized

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?

Feb 18 '11 at 04:22 PM Jessy

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_SAMPLE_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

Feb 18 '11 at 05:31 PM Emericanized

Are you using Unity 2.x? 3.2 yields no errors for me.

Feb 18 '11 at 05:54 PM Jessy

3.1.0f3, pro trial at the moment!

Feb 18 '11 at 06:12 PM Emericanized
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x641
x201

asked: Feb 18 '11 at 02:16 PM

Seen: 2275 times

Last Updated: Feb 18 '11 at 02:16 PM