Hi there, I just modified the Mobile diffuse shader included in Unity to support vertex color. The shader is pretty simple, I have just add a line: Code (csharp): Shader "Mobile/Diffuse Vertex Colored" { Properties { _MainTex ("Base (RGB)", 2D) = "white" {} } SubShader { Tags { "RenderType"="Opaque" } LOD 150 CGPROGRAM #pragma surface surf Lambert noforwardadd sampler2D _MainTex; struct Input { float2 uv_MainTex; float3 color : COLOR; }; void surf (Input IN, inout SurfaceOutput o) { fixed4 c = tex2D(_MainTex, IN.uv_MainTex); o.Albedo = c.rgb * IN.color.rgb; } ENDCG } Fallback "Mobile/VertexLit" } It runs great on iPhone 3GS and iPad 2 (60fps) with just one plane and the shader applied (the plane takes all the screen). But in iPad1 and iPhone 4, it runs at 45fps!!. The line that "breaks" everything is o.Albedo = c.rgb * IN.color.rgb . Only that. If I use vertex colors only, or the texture colors only works great, but that operation kills the performance. I can't imagine what is happening. (Using OpenGL 2.0). Do you know why? I will try to write a GLSL shader form scratch, but I need also Beast lightmaps and I struggling to make them working (there is another post with this subject) Thanks
Just to clarify: if you replace "o.Albedo = c.rgb * IN.color.rgb;" by "o.Albedo = c.rgb;", the performance is OK?
Yes thats it. Its when I multiply both when the performance drops. I just tried to reduce the precision to fixed3, and it works perfectly. I though that a "simple multiplication" can't hurt performance... I have learned a good lesson here. Many thanks
So is this ultimately the answer as to why using OpenGL 2.0 with Vertex Colors with the built in shaders causes such a large performance drop? I've seen the drop on iPhone 4 as well.