Hi everyone,
I’m using a very simple billboard shader that works great when using on only one instance with a material.
But as soon as there is a second billboard instance (or more) using the same material I see a nasty texture translation bug.
I did read these 3 threads:
http://forum.unity3d.com/threads/165361-How-to-make-a-Billboard-shader
http://forum.unity3d.com/threads/181287-Billboard-sprite-shader
http://forum.unity3d.com/threads/183371-Help-with-billboard-alpha-shader
But after trying their suggestions like disabling the batching its still not working ![]()
Again here is the code of the shader in question:
Shader "Custom/Billboard" {
Properties {
_MainTex ("Texture Image", 2D) = "white" {}
}
SubShader {
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// User-specified uniforms
uniform sampler2D _MainTex;
struct vertexInput {
float4 vertex : POSITION;
float4 tex : TEXCOORD0;
};
struct vertexOutput {
float4 pos : SV_POSITION;
float4 tex : TEXCOORD0;
};
vertexOutput vert(vertexInput input)
{
vertexOutput output;
output.pos = mul(UNITY_MATRIX_P,
mul(UNITY_MATRIX_MV, float4(0.0, 0.0, 0.0, 1.0))
- float4(input.vertex.x, input.vertex.z, 0.0, 0.0));
output.tex = input.tex;
return output;
}
float4 frag(vertexOutput input) : COLOR
{
return tex2D(_MainTex, float2(input.tex.xy));
}
ENDCG
}
}
}
I also attached a small project that contains 2 planes with a texture that use the shader so you can easily see the bug in action.
Just open the scene “BillboardTest.unity” in the Assets folder and try to move one of the the billboards on the X axis, the Z axis is even worse and the Y axis don’t move at all.
If you simply deactivate one of the billboards you will suddenly start seeing the other one behaving perfectly when moved in any direction ![]()
If somebody could please explain the nature of this problem and how we can solve this issue I would greatly appreciate it.
Thkx!
1396676–72227–$BillboardTest.zip (738 KB)