- Home /
How to add rim light for mobile in my shader?
Hello community!
I found so many answers here... I finished a game out of it. Now I'm trying stuff to prepare the next game, and I'm facing a wall made of shader-coding-lack-of-knowledge...
I made a shader from unity's doc code sample, and it's fine, except it lacks Rim Lighting. The thing is it works in editor with:
 void surf (Input IN, inout SurfaceOutput o) {
 //Shading stuff
    half rim = 1.0 - saturate(dot (normalize(IN.viewDir), o.Normal));
    o.Emission = _RimColor.rgb * pow (rim, _RimPower);
 //...
But it displays black when I run it on Android. Here is my full shader:
 Shader "Mobile/Diffuse Detail" {
     Properties {
         _MainTex ("Base (RGB)", 2D) = "white" {}
         _Detail ("Detail (RGB)", 2D) = "gray" {}
         _Lightmap ("LightMap (RGB)", 2D) = "gray" {}
         _BumpMap ("Bumpmap", 2D) = "bump" {}
         _RimColor ("Rim Color", Color) = (0.26,0.19,0.16,0.0)
           _RimPower ("Rim Power", Range(0.5,8.0)) = 3.0
         
         
     }
     SubShader {
         
         Pass{
                         
             Lighting On
             Fog { Mode Off }
             SetTexture [_MainTex] { combine texture * primary Double, texture * primary}
             //SetTexture [_Detail] { combine previous * texture Double, previous}
             
         }
         Tags { "RenderType" = "Opaque" }
       CGPROGRAM
       #pragma surface surf WrapLambert
       
       half4 LightingWrapLambert (SurfaceOutput s, half3 lightDir, half atten) {
           half NdotL = dot (s.Normal, lightDir);
           half diff = NdotL * 0.2 + 0.8;
           half4 c;
           c.rgb = s.Albedo * _LightColor0.rgb * (diff * atten * 2);
           c.a = s.Alpha;
           return c;
       }
 
       struct Input {
           float2 uv_MainTex;
           float2 uv_Detail;
           float2 uv_BumpMap;
           float2 uv_Lightmap;
           float3 viewDir;
       };
       sampler2D _MainTex;
       sampler2D _Detail;
       sampler2D _BumpMap;
       sampler2D _LightMap;
       float4 _RimColor;
       float _RimPower;
       
       sampler2D _Lightmap;
       void surf (Input IN, inout SurfaceOutput o) {
           o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
           o.Albedo *= tex2D (_Detail, IN.uv_Detail).rgb * 1;
           o.Albedo = ((o.Albedo) + (tex2D (_MainTex, IN.uv_MainTex).rgb))/2;
           o.Albedo *= tex2D (_Lightmap, IN.uv_Lightmap).rgb * 2;
           o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap));
           half rim = 1.0 - saturate(dot (normalize(IN.viewDir), o.Normal));
           o.Emission = _RimColor.rgb * pow (rim, _RimPower);
           
       }
       ENDCG
     } 
     FallBack "VertexLit", 2
 }
So, could someone please tell me how to make this RimLighting work on Android? It really enhances my visuals by giving more volume to the normal mapping. I did research yet, and found this: http://forum.unity3d.com/threads/45264-Rim-Light-Shader-Question-First-Unity-Shader!?p=287554&viewfull=1#post287554 It does work very well on Android, but I really don't know enough about shader coding to understand it and merge it with my shader. Help? Please...
Julien
Really? No one? It really changes a lot the look of my environment, it would be wonderful if someone could help...
Your answer
 
 
             Follow this Question
Related Questions
Mobile Bumped Specular: Point Lights Only 0 Answers
Rim Light shader problem 0 Answers
android shader issue 1 Answer
Shader: Rim outer & Inner 1 Answer
My shader works on desktop, but black screen on Android. 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                