- Home /
Question by
Cliwo · Sep 04, 2017 at 01:14 AM ·
shadergpuinstancing
When I enable 'GPU Instancing', transparent object starts flickering.
When I enable 'GPU Instancing', transparent object starts flickering. Some are drawn but shape is changed the others are not drawn.
Here is my custom shader code. just simple unlit, transparent shader and I added some codes for instancing.
Shader "Custom/Unlit/TransparentUnlit"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" "Queue"="Transparent" "IgnoreProjector"="True" }
LOD 100
ZWrite Off
Cull Off
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_instancing
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
return o;
}
UNITY_INSTANCING_CBUFFER_START(Props)
UNITY_INSTANCING_CBUFFER_END
fixed4 frag (v2f i) : SV_Target
{
// sample the texture
fixed4 col = tex2D(_MainTex, i.uv);
return col;
}
ENDCG
}
}
}
This is when I off 'Enable Instancing' https://drive.google.com/open?id=0B32wWfDTQhRfT0JfdmlKUWw4SHc (link is video)
And this is when I on 'Enable Instancing' https://drive.google.com/open?id=0B32wWfDTQhRfTXVfNmJRRUMtaEE (link is video)
Why results are different? Shader code is reason?
screen-shot-2017-09-04-at-101113-am.png
(326.6 kB)
screen-shot-2017-09-04-at-101129-am.png
(377.4 kB)
Comment
Your answer
Follow this Question
Related Questions
Shader and material for GPU instancing particles? 2 Answers
Why are my GPU instanced objects all black? 2 Answers
Shader to a Camera 1 Answer
Cant find Standard Surface Shader (Instanced) in Unity 2 Answers