I'm trying to achieve a shading similar to the one on this image:

Image 1: https://i.sstatic.net/iB5nH.jpg

To get something similar to this I wrote a toon ramp shader (similar to the one in the Standard Assets) with normal maps. The shader works, and without a normal map you can see the lighting bands strictly defined, with visible seams separating them (Image 2). But once you add a normal map, the toon bands won' t have well defined seams anymore, and will blend smoothly all across the mesh (Image 3).

Image 2 & 3: https://i.sstatic.net/hIVo4.jpg

This is my current shader:

Shader "Custom/ToonRampWithNormals" 
        _Color ("Color", Color) = (1,1,1,1)
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _BumpMap("Bumpmap", 2D) = "bump" {}
        _Ramp("Toon Ramp", 2D) = "white" {}
        Tags { "RenderType"="Opaque" }
        LOD 200

        #pragma surface surf Ramp

        // Use shader model 3.0 target, to get nicer looking lighting
        #pragma target 3.0

        sampler2D _Ramp;

        half4 LightingRamp(SurfaceOutput s, half3 lightDir, half atten) 
            half NdotL = dot(s.Normal, lightDir);
            half diff = NdotL * 0.5 + 0.5;
            half3 ramp = tex2D(_Ramp, float2(diff,diff)).rgb;
            half4 c;
            c.rgb = s.Albedo * _LightColor0.rgb * ramp * atten;
            c.a = s.Alpha;
            return c;

        struct Input
            float2 uv_MainTex;
            float2 uv_BumpMap;

        sampler2D _MainTex;
        sampler2D _BumpMap;
        half _Glossiness;
        fixed4 _Color;

            // put more per-instance properties here

        void surf (Input IN, inout SurfaceOutput o)
            // Albedo comes from a texture tinted by color
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
            o.Albedo = c.rgb;
            o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
            o.Alpha = c.a;
    FallBack "Diffuse" 

So, what have I done wrong? How can I have well defined lighting bands and have normal mapping?

If you can think of a better way to achieve something similar to the reference or have any thoughts about it please share, any contribution is much appreciated.


1 Answer 1


Everything is all right with the shader. The issue was in the texture itself, it had too many small details, tried another texture with fewer details and BAM it works as intended.

enter image description here.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .