Quantcast
Channel: Questions in topic: "drawcall"
Viewing all articles
Browse latest Browse all 33

Using Vertex Color increases Draw Call

$
0
0
I am working on a card game right now and to keep draw calls at minimum i am using single texture atlas for all cards where i set UV values of vertices programmatically to change each card. Each card has face and back mesh also with a text mesh in front. By changing each card as i said earlier for any number of cards i can keep the draw calls at 2 thanks to dynamic batching but i also want to add highlight to cards. To do this i wanted to use vertex colours, thou this totally screwed up the dynamic batching, causing draw calls to increase linearly related to card count. Every article i've read remotely related to this topic says that usage of vertex colours does not increase draw calls and here is the interesting part, this is unlit shader i use : Shader "Custom/Unlit Cutoff Vertex" { Properties { _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 } SubShader { Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"} LOD 100 Lighting Off Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct appdata_t { float4 vertex : POSITION; float2 texcoord : TEXCOORD0; float4 color : COLOR; }; struct v2f { float4 vertex : SV_POSITION; half2 texcoord : TEXCOORD0; float4 color : COLOR; }; sampler2D _MainTex; float4 _MainTex_ST; fixed _Cutoff; v2f vert (appdata_t v) { v2f o; o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex); o.color = v.color; return o; } fixed4 frag (v2f i) : SV_Target { fixed4 col = tex2D(_MainTex, i.texcoord); clip(col.a - _Cutoff); return col * i.color; } ENDCG } } } ..the built-in unlit cutoff shader slightly modified to support vertex color. Whenever i add > o.color = v.color; to vertex shader it screws up the batching. Anyone has an idea why?

Viewing all articles
Browse latest Browse all 33

Trending Articles