1. Welcome to VRCat! Please note that this message board is not related to VRChat in any official manner. It is run entirely by the community, and moderated by the community. Any content present has not been reviewed by VRChat moderators or staff. Your use of these forums implies understanding of this message. Thanks!
    Dismiss Notice

Silent's Cel Shading Shader

Discussion in 'Tutorials and Tools' started by Silent, Nov 23, 2017.

  1. Silent

    Silent Member

    Joined:
    Nov 19, 2017
    Messages:
    20
    Likes Received:
    18
    Hi everyone! Presenting...
    [​IMG]
    (Sorry, couldn't resist.)

    This is a heavily modified version of Cubed's Flat Lit Toon shader, allowing more varied expressions of light and shadow than ever before. It adds the following exciting features:

    - Support for Specular and Smoothness maps, like the Standard shader!
    - Customisable ambient fresnel for specific art styles.
    - A customisable lighting ramp system, with support for MMD light ramps, designed to work in all kinds of light.
    - Supports all the lighting types Cubed's shader does, and more! You'll always be lit.
    - Lots of options for tweaking and tuning your shadows and shading! Have an ambient occlusion map? Put it into the shadow mask setting and get the benefits while still having cel shading!
    - Outlines that shift to avoid the "broke edge" problem that happens when you get too close.
    - Matcap support for additive and multiplicative matcaps, anchored in world space.
    - Comprehensive advanced options for setting blend mode settings and more!

    [​IMG]
    The latest version is available on GitLab!
    GitLab Page For The Project
    Releases:
    v1.1 1.0

    Note:
    You must set ramp textures to Wrap Mode: Clamp in order for new lightramps to look correct.
    Disabling sRGB for ramp textures will give them more intense colours.

    ◆ How to install?
    Extract the contents of the "Assets" folder into your Unity project "Assets" folder.

    ◆ Screenshots
    [​IMG]
    [​IMG]
    [​IMG]

    Please test and enjoy!

    Ancient history:
    ◆ Cubed's toon shader with custom lighting ramp
    version: 1 | 1.5 | 2 | 2.1 | 2.2 | 2.3 | 3.0 | 3.1 | 3.4 | 3.7


    Where applicable, this work is licensed under a Creative Commons Attribution 4.0 International License and MIT License.
     
    #1 Silent, Nov 23, 2017
    Last edited: Oct 17, 2018
    Jakhaxz, Mimi, Hackspanner and 3 others like this.
  2. Silent

    Silent Member

    Joined:
    Nov 19, 2017
    Messages:
    20
    Likes Received:
    18
    Hi everyone.

    I've updated the modified toon shader to version 1.5 2 2.1. It now supports specular maps. I've also done some adjustment to try and make it look better in varied lighting conditions.

    This new version is not a Unity package because the packager was missing certain files. Also, it was made to not replace Cubed's shader but work as a separate entry.

    I haven't updated it to the keep step with the latest changes, but it'll be there soon. Shader has been updated to correspond with version 0.19.
     
    #2 Silent, Dec 10, 2017
    Last edited: Dec 10, 2017
    desunesu likes this.
  3. Silent

    Silent Member

    Joined:
    Nov 19, 2017
    Messages:
    20
    Likes Received:
    18
    This isn't an update to the shader, but here's a lighting ramp I had good results with.

    ◆ Light cel-shading ramp

    [​IMG]

    Instead of going completely dark, it stays fairly light with shades of blue. It's good for models that have their own lighting details painted on.
     
    desunesu likes this.
  4. Tupper

    Tupper The Strongest
    Forum Staff

    Joined:
    Nov 14, 2017
    Messages:
    117
    Likes Received:
    106
    VRChat:
    Tupper
    This looks really nice. I might try playing with it on Cirno.

    I'm sorry if I misunderstood your post, but you're keeping up to date with the Cubed's Shader builds, right? Would it be too much to ask for you to start a fork so you could easily merge changes and etc?

    You might even want to talk to Cubed about doing a pull request to add the feature to Flat Lit Toon baseline.

    Edit: I'm getting the following errors when attempting to use the latest version (2.1)
    [​IMG]
     
  5. Silent

    Silent Member

    Joined:
    Nov 19, 2017
    Messages:
    20
    Likes Received:
    18
    Oops, looks like I do need to release a new version after all.

    I've updated the toon shader to 2.2 in the main post. It contains a fix for that issue, though the Alpha cutoff setting won't work until I've fixed it properly.
     
  6. Silent

    Silent Member

    Joined:
    Nov 19, 2017
    Messages:
    20
    Likes Received:
    18
    I've corrected the issue with alpha cutoff and updated the shader to 2.3 in the main post. It's also got the latest changes to the original shader. Please try it out.

    Also, I made a minor update to Standard With Dithering. The new shader provides a few more options.
     
    #6 Silent, Dec 23, 2017
    Last edited: Dec 24, 2017
  7. Silent

    Silent Member

    Joined:
    Nov 19, 2017
    Messages:
    20
    Likes Received:
    18
    ◆ Details on using the toon shader
    The biggest visible difference between this shader and Cubed's original is that you can specify how the light falloff operates. This sounds complicated, but it's not too complicated.

    ◆ Prerequisites
    Included are some lightramps you can use. What's a lightramp? It's a texture that the shader references for the lighting. You can make your own, too.

    It's important that you go over each lightramp texture and check the settings match the below:

    [​IMG]

    Wrap Mode: Clamp is the most important one.
    Note: Using sRGB is up to your own preference. Try with it unset, too.
    The main difference is that shadows become darker.
    This chart provides a reference for why.

    ◆ Setting up the Material
    Here is a basic example of a material set up.
    [​IMG]
    This material has no normal map or specular, but you can add them in. Specular lighting will add onto what's already there based on the specular exponent. Experiment and find out what works for you!

    The important part, highlighted here, is the lighting ramp. By default, this is set to nothing, so your meshes will have no lighting. You'll want to select your materials and then click the ◉ to select a ramp texture.

    ◆ Example of ramp textures

    Shadow will allow you to boost the lighting by a specified amount to lessen the impact of shadows.

    Fresnel adds a rim lighting effect. This is pretty common in game and MMD shaders, and it looks pretty nice. The higher the value, the tighter the highlight is. Conversely, a low value will brighten the entire mesh. Watch out!

    Outlines work the same way as in Cubed's original shader.
     
    #7 Silent, Dec 28, 2017
    Last edited: Sep 22, 2018
  8. Silent

    Silent Member

    Joined:
    Nov 19, 2017
    Messages:
    20
    Likes Received:
    18
    After 9 months of work, I'm happy to announce the new version is ready. SCSS 4.0 is out! Because I've moved to releasing on GitLab, though, I've reset version number to 1.0. Anyway, please take a look and give it a spin!!

    [​IMG]
     
  9. Silent

    Silent Member

    Joined:
    Nov 19, 2017
    Messages:
    20
    Likes Received:
    18
    #9 Silent, Sep 28, 2018
    Last edited: Sep 30, 2018
  10. Silent

    Silent Member

    Joined:
    Nov 19, 2017
    Messages:
    20
    Likes Received:
    18
    Version 1.1 is tested and ready for use!

    New in this release:
    • Specular system has been revamped to use Unity's lighting information better.
    • New PBR modes for specular have been added.
    • Transparency support for VRchat has been implemented.
    • You can now change the way lighting is calculated.
    • Added the ability to mask out the matcaps.
    • Lighting ramps now follow the VRchat naming convention internally, so they will fall back when blocked. Note that you'll need to re-specify your lighting ramps.
    The latest version is available from GitLab in the main post, or here!
     
  11. IC_Raz

    IC_Raz New Member

    Joined:
    Feb 24, 2018
    Messages:
    1
    Likes Received:
    0
    VRChat:
    IC_Raz
    Question regarding this shader. It seems to react dramatically to some light sources in worlds within VRChat, regardless of lightramp, specular maps, or normal maps. Some lights just make a flat glow on the avatar. Is there any way to fix it so the lights either a. Don't reflect on the avatar or b. follow a map to control what parts on the model would glow brighter.

    [​IMG]
     
  12. Silent

    Silent Member

    Joined:
    Nov 19, 2017
    Messages:
    20
    Likes Received:
    18
    When a light affects your avatar in that way, that's what Unity considers an Unimportant Light. Unimportant lights are the cheapest kind of light, rendered using per-vertex shading to save on performance. In this shader, the current behaviour is for these lights to have a normalised effect so they don't look weird on flat-shaded avatars (because otherwise things will look blocky/weird).

    Because these lights are done very cheaply, there is not enough information available for them to properly affect normal/specular masks. Conceivably, they could be affected by shadow maps. I'll see if there's anything else I can do. In the meantime, you can disable it yourself by removing all instances of
    Code:
    directContribution += i.vertexLight;
    in FlatLitToonForward.cginc.
     
  13. Silent

    Silent Member

    Joined:
    Nov 19, 2017
    Messages:
    20
    Likes Received:
    18
    The next version (currently available to preview) will include some fancy new features!
    [​IMG]
    Point lights and other kinds of lights have specular highlights now! This applies to all kinds of specular.

    [​IMG]
    By request, subsurface scattering has been added. Bake a thickness map in Blender by inverting the normals of your model and apply! The results can be pretty surprising.

    More changes and fixes are incoming for version 1.2 proper.