- Home /
No vertex lighting on Android tablet (Unity bug?)
How can this be? I think every Android 4 device will support Vertex Lighting, right?
In a new project with a new scene I added some objects and a point light. The shader is set to Mobile/VertexLit. Only exception is the cylinder. It uses the standard shader.
Thing is: on my Android tablet (Android 4), the lighting does not work. But on my Android phone, it works well.
Used shader is Mobile/VertexLit that ships with Unity.
I found this thread: https://forum.unity3d.com/threads/black-textures-on-some-devices-android-versions.195328/ But none of the solutions worked for me.
Is there some user made shader I could use? I need vertex colors and lighting from a point light. For mobile devices.
Answer by AurimasBlazulionis · Jan 15, 2017 at 12:31 PM
Better use regular standard shader and use Shader.globalMaximumLOD = 150 inside some script to get vertex-lit shading. Otherwise I do not know any other solution.
Setting this variable did not show vertex colors for me when using the standard shader
Answer by achimmihca · Jan 15, 2017 at 02:03 PM
I now wrote a simple surface shader that considers vertex colors. This works for me, because the point light is calculated on pixel level and the color is added using vertex colors.
BUT: Using this shader Dynamic Batching does not work anymore. It also does not work when I use the Standard shader. Only with Mobile/VertexLit. And because Batching is the only reason I started with vertex color stuff, this is not really a solution for me.
So in addition to my first question: Why does Dynamic Batching not work with this shader?
Shader "Custom/LambertVertexColors" {
Properties {
_MainTex ("Albedo (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType" = "Opaque" }
CGPROGRAM
#pragma surface surf Lambert vertex:vert
struct Input {
float2 uv_MainTex;
float3 customColor;
};
void vert (inout appdata_full v, out Input o) {
UNITY_INITIALIZE_OUTPUT(Input,o);
o.customColor = v.color;
}
sampler2D _MainTex;
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
o.Albedo *= IN.customColor;
}
ENDCG
}
}
I think the problem is that one needs a shader with a single pass to have Dynamic Batching. It seems the above shader and the standard shader do not meet this requirement. Does anyone know a shader, which calculates a point light in a single pass and also considers vertex colors?
Dynamic Batching does work with the option noforwardadd
in #pragma
. I just had a look at the default $$anonymous$$obile/Diffuse shader and found this option. When adding this, dynamic batching works again, so I now have (a) one per-pixel point light, (b) vertex colors, (c) dynamic batching. $$anonymous$$y batches dropped from 130 to 40. Everything's peachy!
Answer by dputros · Oct 02, 2017 at 08:02 AM
Actually, @achimmihca, this IS a unity bug with Vertex-lit combination with Spot light on some Android GPUs.
This issue seems to have started with version 5.3 so it's been there for a while. Maybe it's worth upvoting this issue in the link above so unity can get it fixed.