Unity3 transparency difference

Hi,

I’m noticing something odd in Unity3 - when compiled to the device (this doesn’t happen when running in the editor), when I put sprite textures in overlap, the transparency behavior is wrong now.

Basically, if one texture is transparent and the other is not for the same pixels, we’re seeing right through both of them, rather than needing them both to be transparent.

It sounds like a shader issue, but then again that’s one part of Unity I haven’t touched yet, so I may have no idea what I’m talking about. If it matters, I’m using the old SpriteManager1/SpriteUI to handle 2D sprites.

Any suggestions / leads on this one? Thanks!

check your shader if they use blending etc

It’s the Particles/Alpha Blended Z-enabled shader, so yes there’s some kind of blending. It looks like that one came with SpriteUI. I guess it needs to be updated for Unity3 then?

I’ll try learning about what I’m looking at - is there a resource for what’s different in Unity3 with shaders?

Here’s what it looks like if anyone can point me at a particular line…

Shader “Particles/Alpha Blended Z-enabled” {
Properties {
_TintColor (“Tint Color”, Color) = (0.5,0.5,0.5,0.5)
_MainTex (“Particle Texture”, 2D) = “white” {}
}

Category {
Tags { “Queue” = “Transparent” }
Blend SrcAlpha OneMinusSrcAlpha
AlphaTest Greater .01
ColorMask RGB
Cull Off Lighting Off ZWrite On Fog { Color (0,0,0,0) }
BindChannels {
Bind “Color”, color
Bind “Vertex”, vertex
Bind “TexCoord”, texcoord
}

// ---- Dual texture cards
SubShader {
Pass {
SetTexture [_MainTex] {
constantColor [_TintColor]
combine constant * primary
}
SetTexture [_MainTex] {
combine texture * previous DOUBLE
}
}
}

// ---- Single texture cards (does not do color tint)
SubShader {
Pass {
SetTexture [_MainTex] {
combine texture * primary
}
}
}
}
}

The shader is writing into the depth and is using alpha testing so it’s not going to work for your purposes. Try using the standard transparent/vertex-lit shader instead.

Okay, tried that. The sprites disappear entirely with transparent/vertex-lit

You may need to put them in separate render queues. But just to clarify, are we talking about semi-transparent sprites or cutout ones? For cutout ones use Transparent/Cutout/Vertex-lit.

These are cut-outs (though I wouldn’t rule out some semi-transparency at some point)… Transparent/Cutout/Vertex-lit is also not showing any output unfortunately… time to learn this shader-syntax I think.

If they’re cutout sprites then it should work out of the box with the built-in shaders without modification… do you mind sending me a small example of the blending you’re trying to achieve. A small Unity package would suffice.

I haven’t had a chance to make a sample, but one quick note: when compiling onto Android, the problem doesn’t show up, so somehow this is only affecting Apple devices.

This one has slipped to the back burner, but one other piece of information in case it’s meaningful to anyone: If I create the sprites with the same z-value, the alpha works correctly. This helps if I create the sprites in the order they should be drawn… but then over time, part of the interface allocates and de-allocates sprites and eventually the order of drawing for those sprites is no longer deterministic so isn’t a perfect solution either.