This sample is recreate and mimic the shader of ' Star Rail ' and ' ZenLess Zone Zero '.
combined_horizontal_video.mp4
- Download this github code.
- Unzip the file and load this unity project with 2022.3.38f1 or newer. (This project is not support Unity6 yet.)
- First time open the project might takes 5~10 minutes to compress skybox textures.
- Open the 'AnimeToonSample.unity' scene to view the sample.
Yes, only shader can! The models are belong to Mihoyo company.
This source code doesn't get any optimization, and make sure you have test target platform first when you want to use in your project.
Outline Normal Source :
- Mesh Normal : Directly use the normal of the mesh to expand the outline.
- CustomNormal(UV4) : Take the pre-smoothNormal data from the mesh of uv4 to expand the outline.
Outline Color (Lerp Mode) : Alpha is a weight to control the baseMap color and outline Color.
Outline Width : Control the thickness of outline.
Receieve Light Color : Enable to multiply with mainLight color.
Impacted By Vertex Color : Enable to multiply with single channel color of vertex.
Tip
Turn on the 'Enable Character Outline' from the render features.

There is a extension script called 'AnimeToonFBXImporter.cs' to extend the function in your FBX model inspector.
Turn on the 'Store Smooth Normal in UV4' and 'Tangents' to get a perfect smooth normal data.

LightMap Mode :
- Normal : Deal with the cloth, body, hair and so on.
- Face SDF : Deal with the face.
LightMap : 4 channel deal with four different ways.
- R : Constant Shadow
- G : None (It means no data be used here, you can custom this property for you like.)
- B : Metal (Metcap Texture)
- A : Gradient Color Index (The maximum is 8 colors to be safe on each different platform and texture compression.)
Gradient Color : Map the light and shadow color with gradient map.
MatCap Tex : Deal with the reflection quality.
Metal : Control the MatCap Tex Intensity.
Emission Map : Sample this texture color and add on.
Emission Color : Multiply with the Emission Tex.
Normal Map and Intensity.
MainLight Shadow Range : Control the ratio of light and shadow.
AdditionalLight Shadow Range : Control the ratio of light and shadow.
AdditionalLight Clip Range : Control the smoothness of light and shadow.
Depth Rim Mode : There are three mode can be choosed.
- Additive
- Multiply
- Replace
Offset Depth Rim : Make sure the offset value be positive. (MainLight's direction would impact the rim's offset)
Rim Color : Multiply the rim color. (Mainlight's color would also multiply with it.)
Render Mode :
- Opaque : This mode the transparent is not work.
- Transparent : This mode the transparent is work. (Use mainColor's alpha to control)
- Custom : Use SrcBlend and DestBlend to combine what you want.
SrcBlend : Source blend setting.
DestBlend : Destnation blend setting.
CullMask : Controls which sides of polygons should be culled.
ZWrite : Controls whether pixels from this object are written to the depth buffer (default is On).
ZTest : How should depth testing be performed. Default is LEqual
Stencil Setting (https://docs.unity3d.com/2020.1/Documentation/Manual/SL-Stencil.html)
Show Vertex Color (Debug) : Show the vertex color on.
Warning
Make sure the render features 'Anime Toon Features' is enable and turn on the 'Eye Through Hair' and 'Depth Hair Caster' first.
Hair and Face have different setting, please follow the info to set up.
Each skinMesh have to set the correct root bone with it. And root bone's direction is need to be set like this (-z, -x, y).

If you're using blender, change the bone's setting like this when you export the fbx.

Finish!
If you still have question or want to get a custom-plan, you can DM me with mail.
Gamil : [email protected]
Mihoyo models:
- Kafka
- Gallagher
- Lycaon
- Miyabi
Skybox :
- https://assetstore.unity.com/packages/2d/textures-materials/sky/free-hdr-sky-61217
- https://assetstore.unity.com/packages/2d/textures-materials/sky/skybox-series-free-103633
Sox Animation Bone :










