KURPToonShading
March 6, 2024 · View on GitHub
Unity URP Toon Shading Library.
Unity Version: 2023.2.12f1
Artstation showcase: https://www.artstation.com/artwork/aox2xq
Maya
Toon Shading in ShaderFX
-
Toon shader for WYSIWYW
dx11 toon shader
Encode average normals in uv2 (Deprecated)
-
Github address
https://github.com/SelfishKrus/MayaPython_AverageNormalsToUVs
-
Encode
- AverageNormalWS → AverageNormalTS → Encode to uv2 by Octahedron compression
-
Decode
- Decode uv2 → AverageNormalTS → AverageNormalWS
Deprecated due to undesirable gap of outlines
Asset Specification
- _IlmTex
-
r - specular layer
Specular Layer Value Material Feature 0 general no specular, no rim 50 general only rim 100 leather specular and rim ≥200 metal only specular -
g - shadow offset
-
b - specular range
-
a - inner lines
-
- Vertex Color
- r - AO
- g - position ID
- b - Z offset for outline offset
- a - outline thickness
- UV
- TEXCOORD0 - uv0 - for texture mapping
- TEXCOORD1 - uv1 - to sample texture for uv lines
- TEXCOORD2 - uv2 - encoded average normals
- TEXCOORD3 - uv3 - tri-planar projected uv for shadow hatch
- Tangent
- as the smooth normal direction for outline offset
Uber Toon Shader
-
Diffuse
-
Control diffuse with AnimationCurve
Diffuse illuminance controlled by AnimationCurve
Pass AnimationCurve to shader as GradientTexture
-
Lerp between BaseColor Map and SSSColor Map
base color and sss color
-
-
Specular from Direct Light
direct light specular
-
Rim Specular
-
option 1 - by depth difference
-
Depth Difference Specular
-
option 2 - by NoV
NoV Specular
-
Outline
Outline
- Outlines include
- Back-face extrusion in NDC
- Edge detection by Sobel depth
- Inner lines include
- Edge detection by Sobel normal
- Texture
- UV lines
Shadow
-
Custom shadow pattern
-
Sample shadow pattern texture via Tri-planar projection UV
uv3 - Tri-planar projection UV
-
Shadow hatch by SD
Customized shadow hatch texuture
-
-
Custom high-resolution shadow map for character
-
2048x shadow map
Custom high-res shadow map
-
PCSS
Percentage closer soft shadow with different PCF step
-
Supports for directional light mode (orthographic projection) and spot light mode (perspective projection)
Orthographic shadow and perspective shadow
-
Post-Process
-
Streak bloom
Streak Bloom
Tips
- Dfference between
SampleSceneDepth(float2 uv)andLoadSceneDepth(uint2 uv)in URP Shader Library:- SampleSceneDepth
- screen space uv, ranging from 0 to 1
- bilinear filter. smoother
- LoadSceneDepth
- screen space uv, ranging from 0 to screen pixel size
- no filtering
- SampleSceneDepth
- Add DepthOnly Pass in shader to make fragment depth written in _CameraDepthTexture
- Params should make sense to artists, and range being clamped between 0 to 1
- In maya, tangent can’t be modified because it’s determined by UV.
- Coordinate system difference
- Maya - left-hand coordinate. Y up;
- Unity - right-hand coordinate; Y up;
- When exporting FBX, make sure coordinate axes of Object Space align with the one of World Space in Maya
Ref
Learn how to do stylized shading with Shader Graph - SIGGRAPH 2019
[UFSH2023]虚幻引擎5全端卡通渲染管线 | YivanLee S1项目_哔哩哔哩_bilibili
-
Guilty Gear
【翻译】西川善司「实验做出的游戏图形」「GUILTY GEAR Xrd -SIGN-」中实现的「纯卡通动画的实时3D图形」的秘密,前篇(1) - Trace0429 - 博客园
【翻译】西川善司「实验做出的游戏图形」「GUILTY GEAR Xrd -SIGN-」中实现的「纯卡通动画的实时3D图形」的秘密,前篇(2) - Trace0429 - 博客园
-
Rim Light
-
Outline
【Job/Toon Shading Workflow】自动生成硬表面模型Outline Normal
-
Custom Shadow map