- Home /
Unity 5: Using mobile shaders with Point Light and Spot Light
Hello everyone, we are building a physics racing game for mobile and have used spot lights for car headlights and point lights for lamp posts. When we use mobile shaders in the environment we don't see light falling on other objects. But when we use computer shaders we see the light falling on other objects. But computer shaders decrease the performance of the game. How to fix this? Thank you
Mobile shader used: Mobile/Diffuse Computer shader used: Standard or Legacy Shaders/Diffuse
Answer by cjdev · Aug 30, 2015 at 08:39 PM
The Mobile shaders use Mobile/VertexLit as their fallback which is what they use to render shadows. If you want to enable full shadows in the Mobile shader you can change the pragma directive noforwardadd to fullforwardshadows. This will probably still give you a performance hit since you have to render the shadows anyways. If you want the source and don't want to download the standard shaders from Unity's download page, this is the standard Mobile Diffuse shader with the change:
Shader "Mobile/Diffuse" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 150
CGPROGRAM
#pragma surface surf Lambert fullforwardshadows
sampler2D _MainTex;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
Fallback "Mobile/VertexLit"
}
Answer by Girish-sruthkia · Sep 15, 2015 at 04:52 PM
@kashif789us You may not see the shadows and the light impact on the object, because the shaders u are using is mobile shaders, but if u lightmap them then u will get the proper shadows and light impact on the objects. The result you see in realtime(editor) will be different from the one which u see after lightmapping.
Your answer
Follow this Question
Related Questions
How to combine several Materials into one? 0 Answers
Does Unity 5 still have Decal Shaders? 1 Answer
Render back faces in deferred 1 Answer
How to change the reflection according to skybox-material? 2 Answers
Realistic metalic on mobile 0 Answers