Skip to content

artbarte/AnimeToonShader

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AnimeToonShader

This sample is recreate and mimic the shader of ' Star Rail ' and ' ZenLess Zone Zero '.

combined_horizontal_video.mp4

How to use it?

  1. Download this github code.
  2. Unzip the file and load this unity project with 2022.3.38f1 or newer. (This project is not support Unity6 yet.)
  3. First time open the project might takes 5~10 minutes to compress skybox textures.
  4. Open the 'AnimeToonSample.unity' scene to view the sample.

Does it allow for comercial use?

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.

Function Explain

MainTex

image
BaseMap texture and color.

Outline (Optional)

image

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

Why i can't see the outline?

Turn on the 'Enable Character Outline' from the render features.
image

Where to use the smooth normal function and put it in UV4?

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. image

LightMap (Optional)

image

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.

EmissionMap (Optional)

image

Emission Map : Sample this texture color and add on.  
Emission Color : Multiply with the Emission Tex.

NormalMap (Optional)

image

Normal Map and Intensity.

Light

image

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 (Optional)

image

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.)

image

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

image

Debug Mode

image

Show Vertex Color (Debug) : Show the vertex color on.

Additional Setting (Optional)

image

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).
image
If you're using blender, change the bone's setting like this when you export the fbx.
image

Finish!
If you still have question or want to get a custom-plan, you can DM me with mail.

Contact Me

Gamil : [email protected]

Project Resource

Mihoyo models:

  • Kafka
  • Gallagher
  • Lycaon
  • Miyabi

Skybox :

Sox Animation Bone :

About

This sample is recreate the shader of ' Star Rail ' and ' ZenLess Zone Zero '.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 79.1%
  • ShaderLab 15.1%
  • Mathematica 5.8%