Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Making a better Unity toon shader

Discussion in 'Shaders' started by AshGetem, Aug 26, 2016.

  1. AshGetem

    AshGetem

    Joined:
    Aug 26, 2016
    Posts:
    4
    I've been working on a game now for about one month when I stumbled across the idea of cel shading as well as using an outline on my game objects to give a "toon link" + anime/comic book style. While the unity default unlit toon shader worked for a long time, I began to find the flaws in the shader: how the outline hovers above the game object's outline instead of on it, how for some reason when I apply a toon shadered material on the floor my shadows stop casting on the floor.

    I'm just asking for help on how to make, which I have already searched for, or an already made cel shading script which includes shadows, cel shading and and outline (and maybe emission).
     
  2. tsangwailam

    tsangwailam

    Joined:
    Jul 30, 2013
    Posts:
    280
  3. AshGetem

    AshGetem

    Joined:
    Aug 26, 2016
    Posts:
    4
    I'm not very experienced with shaders (as in, had about 1 week of google research) so I need some clarification on what to do. Sorry, I'm just new to this. I linked the standard unity toon outline shader and I was just wonder what exactly could I do to make my objects receive shadows and not just cast them (because I use this shader on my floor). Also how can I add an emission modifier, and is there a way to get better outlines because the default unity outline has some graphical errors.

    And by the way, thanks for the quick response!
     

    Attached Files:

  4. AshGetem

    AshGetem

    Joined:
    Aug 26, 2016
    Posts:
    4
    After some more research I have located an asset pack in the asset store which contains the toon shader that looks like the one I want! It is called MK toon (For anyone wondering). I haven't got a chance to try it out but it looks like exactly what I wanted. Thanks for the support!
     
  5. Stevepunk

    Stevepunk

    Joined:
    Oct 20, 2013
    Posts:
    205

    If you want full shadows then find this code in MK Toon's MKToonDefault.shader:

    Code (CSharp):
    1.         CGPROGRAM
    2.         #pragma shader_feature _USE_NORMAL_MAP
    3.         #pragma shader_feature _USE_RIM
    4.         #pragma shader_feature _LIGHTMODE_DEFAULT _LIGHTMODE_TRESHOLD _LIGHTMODE_LEVELS
    5.         #pragma shader_feature _USE_SPECULAR
    6.         #pragma shader_feature _USE_CUSTOM_SHADOW
    7.         #pragma shader_feature _USE_M_TEX
    8.         #pragma fragmentoption ARB_precision_hint_fastest
    9.         #pragma surface surf MKToon interpolateview
    10.         #pragma target 2.0
    And change to:

    Code (CSharp):
    1.         CGPROGRAM
    2.         #pragma shader_feature _USE_NORMAL_MAP
    3.         #pragma shader_feature _USE_RIM
    4.         #pragma shader_feature _LIGHTMODE_DEFAULT _LIGHTMODE_TRESHOLD _LIGHTMODE_LEVELS
    5.         #pragma shader_feature _USE_SPECULAR
    6.         #pragma shader_feature _USE_CUSTOM_SHADOW
    7.         #pragma shader_feature _USE_M_TEX
    8.         #pragma fragmentoption ARB_precision_hint_fastest
    9.         #pragma surface surf MKToon interpolateview fullforwardshadows //added shadows
    10.         #pragma target 2.0
    Unfortunately MK Toon has the same outline hover effect though, but at least you get full light and shadow from all light types and can also add normal maps.
     
  6. AshGetem

    AshGetem

    Joined:
    Aug 26, 2016
    Posts:
    4
    Thanks for the response, I'll see what I can do with the MK Toon shader now.
     
  7. Ohmydumbledear

    Ohmydumbledear

    Joined:
    May 16, 2017
    Posts:
    7
    Hey ! I'm trying to use the MK Toon Shader as well, it's great for the shadows, but I'm trying to change the outline color and it just doesn't seem to be working, it remains black even tough there is an option is the shader parameters.

    Any idea ? Tip ?