Giter Site home page Giter Site logo

turp's Introduction

Introduction

Toon render pipeline modified from URP. Support deferred rendering and forward rendering, support NativeRenderPass. Not support subtractive lightingMode.
image-UnityChan

ShadingModel

Use global ramp map to control shadow.(In "Universal RP/Textures/Toon/ToonDiffuseRamp.png").

image-ToonDiffuseRamp

Now we have two shadingModel, Lit and SimpleLit, both modify from PBR.

Lit

image-Lit
Lit must be metallic workflow. It can interpolate between PBR.

-Outline : Back face outline, Color.R control width. Support smoothNormal outline. Use bakeTool to bake smoothNormal in tangent space, and store in uv3. Add suffix "_SN" on fbx file, then check "ToonOutlineSmoothNormal" on material. BakeToolReference:https://zhuanlan.zhihu.com/p/107664564

-Shadow : Use ToonDiffuseRampV control how to sample global ramp map. Shadow color only in MainLight, prevent overexposure.

-DepthShadow: Sample ToonDepthTexture with offset screenUV and screenUV, then compare to get depthShadow.

-PointShadow: In some cases, we dont want slefShadow, for example character, when disable receiveShadows, character alway in lighting, this function sample a worldSpace point in MainLightShadowMap, use control a character in lighting or not, have to setup a "ToonShadingProperty" component.

-Specular : Only control specular feather.

-Rim: ToonDepthTexture control rim(must enable "ToonData"), not support in forward rendering path.

-MatCap: Add as emission.

-ToonData: Render in ToonDepthTexture and ToonDataTexture.(Enable on Character)

-ToonID: Use in rimLight、depthShadow、outline, set different id for different parts of the character.

SimpleLit

image-SimpleLit
SimpleLit have more control on shadow, but simple specular.

-Outline : Same as lit.

-Shadow : Use ToonDiffuseRampV control how to sample global ramp map. Can control ShadowOffset and StaticShadowMap.

-DepthShadow: Same as lit.

-SDFShadow: Character face shadow.(Have to setup "ToonShadingProperty" component)

-PointShadow: Same as lit.

-Rim: Same as lit.

-MatCap: Same as lit.

-ToonData: Same as lit.

-ToonID: Same as lit.

Deferred Rendering Path

image-DeferredFrame

Gbuffer Layout

Default URP Gbuffer layout

https://docs.unity3d.com/Packages/[email protected]/manual/rendering/deferred-rendering-path.html

image-GbufferLayout

TURP Gbuffer Layout

Different from default URP layout:

-Lit
Gbuffer1: Metallic DiffuseRampV SpecularFeather Occlusion

MaterialFlags:
Bit 0, ReceiveShadowsOff: if set, the pixel does not receive dynamic shadows.
Bit 1, SpecularHighlightsOff: if set, the pixel does not receive specular highlights.
Bit 2, DepthShadowEnable: if set, the pixel sample ToonDepthTexture to get depthShadow.
Bit 3, PointShadow. if ReceiveShadowsOff, the pixel uses check object in shadow.

-SimpleLit
Gbuffer1: Specular DiffuseRampV DiffuseRampOffset StaticShadow

MaterialFlags:
Bit 0, ReceiveShadowsOff: if set, the pixel does not receive dynamic shadows.
Bit 1, SDFShadow: enable SDFShadow.
Bit 2, DepthShadowEnable: if set, the pixel sample ToonDepthTexture to get depthShadow.
Bit 3, PointShadow. if ReceiveShadowsOff, the pixel uses check object in shadow.

ToonData buffer

No memoryless. (Vulkan API subpassLoad() cant load gbuffer with specific uv, we need to sample toonData with offsetuv)
-ToonDepthTexture: 16 bit depth buffer.Use to render character rim, depthShadow.
-ToonDataTexture: 8 bit. Store material id, use to render character depthShadow、 PostProcessOutline.

Setting

image-Setting

ShaderGraph

image-ShaderGraph
Only lit Shader, not fully feature.

ToneMapping

Modify ACES (In "Core RP Library/ShaderLibrary/Color.hlsl").
image-ToonACES

Other

Forward+ RenderingPath has some problems. NativeRenderPass dont work in scene window. NativeRenderPass has bug, if scene shadow look wrong, maybe re-check NativeRenderPass in UniversalRenderer asset.
UnityEditor 2022.2+
Universal RP 14.0.6

Reference

© Unity Technologies Japan/UCL(https://unity-chan.com/)
https://github.com/TechMiZ/ToonShadingCollection

turp's People

Contributors

chilimilk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.