Issue with SetTextureOffset and Transparency/ZWrite

Hi,

I am having a problem with “Material.SetTextureOffset()”. Specifically when using an alpha transparency. When animating the texture with “ZWrite On” in the shader source the texture has the correct transparency but is drawn behind everything in the scene. If “ZWrite Off” is set the material is drawn in the correct order but no transparency. This was on a custom shader (it’s only a simple sprite texture. No lighting etc). But it also appears to happen with the default Diffuse Transparent material.

Any pointers or help?

Thanks

Which render queue your shader is using?

Generally semitransparent things that don’t write to depth buffer should be using “transparent” render queue (that guarantees they are drawn after all opaque geometry)

Hi,

I’m using"Tags { “Queue” = “Transparent” }"

Actually I’ll post the whole shader. As I say it’s only a simple test thing. The ZWrite change only came about by my attempts to fix it.

It works correctly as long as I don’t animate the “Material.SetTextureOffset()”

Properties
{
_Color (“_Color”, Color) = (1,1,1,1)
_MainTex (“_MainTex”, 2D) = “white” {}
}

Category
{
Lighting Off
//Offset -1, -1
ZWrite Off
ztest LEqual
Cull Back
Blend SrcAlpha OneMinusSrcAlpha
Tags { “Queue” = “Transparent” }
SubShader
{
Material
{
Emission [_Color]
}
Pass
{
SetTexture [_MainTex]
{
constantColor [_Color]
Combine texture * constant, texture * constant
}
}
}
}

Thanks

As a note I’ve tried removing “Material.SetTextureOffset()” and added a “Material.SetColor()” and this has the same effect. In the scene view I can see it draws everything on top of this shader?? without either everything works fine.

Also these calls are being made from Update(). Could this have an effect?

Thanks