# Anime Inspired Shading Model

**URL:** <https://forums.unrealengine.com/t/anime-inspired-shading-model/156903>\
**Category:** Rendering\
**Tags:** unreal-engine\
**Created:** [January 26, 2021, 3:10am UTC](https://forums.unrealengine.com/t/anime-inspired-shading-model/156903 "2021-01-26T03:10:35Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![SirCodalot](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sircodalot/32/88719_2.png) [@SirCodalot](https://forums.unrealengine.com/u/SirCodalot)\
**Post date:** [January 26, 2021, 3:10am UTC](https://forums.unrealengine.com/t/anime-inspired-shading-model/156903/1 "2021-01-26T03:10:35Z")

</div>

https://i.ibb.co/ZKCDBrv/image.png

After struggling to find a shader that will fit my projects, I decided to make my own anime-inspired shading model. It was a very fun experience and I’m planning to expand this project and add more shading models in the future! In the meantime, I hope you like this shading model. It is designed to give you as much control as possible over your material’s color. The material’s base color is completely separated from the highlight color and shadow color. You can even make a black material with white shadows! The shader supports multiple light sources and it has cool features such as a stylized specular and rim light.

https://i.ibb.co/Dgq1Zjb/Michiru-Side-800.gif

Michiru (BNA)  
Model + Rig Created by [Christoph Schoch](https://twitter.com/artstoff)  
[Download the rig here!](https://gumroad.com/thestoff#pSXRn)  
ArtStation: [ArtStation - Michiru - Fan Model](https://www.artstation.com/artwork/d836rX)  
If you made something cool with the shader, send it to me and I’ll add it to the post!

**I made a short video that shows the material’s features, I recommend watching it!**

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/d/6/ed6c001e5cfe187e02433ee55cf4e04d673642e4.jpeg "UE4 Anime/Toon Shading Model (Preview)") ](https://www.youtube.com/watch?v=tPZ1M6iWbh8)

**I also made this installation guide that explains how to download and use the materials:**

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/8/8/9885654f47983da4c6d450160d75e1a0c4463919.jpeg "UE4 Anime/Toon Shading Model (Installation Guide)") ](https://www.youtube.com/watch?v=kYyPWIhS8a8)

**Github Repository:** [https://github.com/SirCodalot/UnrealEngine](https://github.com/SirCodalot/UnrealEngine)  
**My Twitter:** [https://twitter.com/Sir\_Codalot](https://twitter.com/Sir_Codalot)  
**Example Project:** [GitHub - SirCodalot/ShadersExample](https://github.com/SirCodalot/ShadersExample)

**Recommended Project Settings:**

- **Project Settings \> Rendering \> Static Lighting** = Enabled
- **Project Settings \> Rendering \> Auto Exposure** = Disabled
- **Project Settings \> Rendering \> Auto Exposure Bias** = 1.0
- **Main Light Source \> Light \> Intensity** = 1.0 lux

**When you create a new material and set the shading model to “Toon”, use these material properties to control your material:**

- **Base Color:** Defines the overall color of the material.

- **Shadow Color:** The color of the unlit areas of the material.

- **Highlight Color:** The color of the material’s specular and rim light.

- **Offset:**

- **Range:**

**Known Issues:**

- The shading model probably doesn’t work with Forward Rendering.
- Using more than one directional light might look weird, but you can use as many SpotLights and PointLights as you want.
- Only works with moveable light sources (but you still have to enable static lighting in your project’s settings).

I want to thank the creators of a few other shading models. It is very hard to find information on this subject and without them, I would’ve failed. Please check out their shading models, they might fit your project more than mine!

**Other cool shading models:**

- [https://forums.unrealengine.com/deve…-shading-model](https://forums.unrealengine.com/development-discussion/rendering/1704696-wip-anime-toon-stylized-shading-model)
- [https://forums.unrealengine.com/deve…ng-experiments](https://forums.unrealengine.com/development-discussion/rendering/1537277-toon-shading-models-stylized-rendering-experiments)
- [https://www.reddit.com/r/unrealengin…model\_for\_425/](https://www.reddit.com/r/unrealengine/comments/hg99qz/wip_toon_shading_model_for_425/)

**Other helpful links:**

- [https://medium.com/@lordned/unreal-e…1-c47f2da65346](https://medium.com/@lordned/unreal-engine-4-rendering-overview-part-1-c47f2da65346)
- [Unity Toon Shader Tutorial](https://roystan.net/articles/toon-shader.html)

---

<div class="post-metadata">

**Author:** ![cybereality](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@cybereality](https://forums.unrealengine.com/u/cybereality)\
**Post date:** [January 26, 2021, 6:27am UTC](https://forums.unrealengine.com/t/anime-inspired-shading-model/156903/2 "2021-01-26T06:27:54Z")

</div>

Looks cool. Thanks for sharing.

---

<div class="post-metadata">

**Author:** ![Arkiras](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/arkiras/32/1008648_2.png) [@Arkiras](https://forums.unrealengine.com/u/Arkiras)\
**Post date:** [January 26, 2021, 8:41am UTC](https://forums.unrealengine.com/t/anime-inspired-shading-model/156903/3 "2021-01-26T08:41:02Z")

</div>

Is it possible to use cast shadows as a mask to lerp between multiple textures like [in your first link](https://i.imgur.com/JjHRFzu.gif)? Been hoping to see someone implement it with the deferred renderer, but I’ve never known whether it was even possible.

Nice work regardless

---

<div class="post-metadata">

**Author:** ![SirCodalot](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sircodalot/32/88719_2.png) [@SirCodalot](https://forums.unrealengine.com/u/SirCodalot)\
**Post date:** [January 26, 2021, 2:07pm UTC](https://forums.unrealengine.com/t/anime-inspired-shading-model/156903/4 "2021-01-26T14:07:56Z")

</div>

> [@Arkiras](#):
>
> Is it possible to use cast shadows as a mask to lerp between multiple textures like [in your first link](https://i.imgur.com/JjHRFzu.gif)? Been hoping to see someone implement it with the deferred renderer, but I’ve never known whether it was even possible.
> 
> Nice work regardless

Yes, it works in the Deferred Renderer and it still supports multiple light sources. You just need to connect your first texture to the Base Color and your second texture to the Shadow Color. The result looks like this:

https://i.ibb.co/XSL0zPW/Dragon-Ball-800.gif

---

<div class="post-metadata">

**Author:** ![Envieous](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/envieous/32/1194501_2.png) [@Envieous](https://forums.unrealengine.com/u/Envieous)\
**Post date:** [January 26, 2021, 4:13pm UTC](https://forums.unrealengine.com/t/anime-inspired-shading-model/156903/5 "2021-01-26T16:13:59Z")

</div>

neat! I love seeing more of these pop up :\>

> [@SirCodalot](#):
>
> Yes, it works in the Deferred Renderer and it still supports multiple light sources. You just need to connect your first texture to the Base Color and your second texture to the Shadow Color. The result looks like this:
> 
> https://i.ibb.co/XSL0zPW/Dragon-Ball-800.gif

How does this look when you have multiple light sources? The reason I don’t support deferred in my shading model is because when I put the lighting together I take the results from all lights and break things down into either a lit pixel, or an unlit pixel so that I’m eliminating any partial shadows that come up when there’s multiple lights whereas deferred just adds the lighting results together. I’ve searched through the source code a few times and I was never able to find where the deferred pipeline actually puts together the result of GetDynamicLightingSplit function like forward rendering does in ForwardLightingCommon.ush so I could achieve the same result through that pipeline.

---

<div class="post-metadata">

**Author:** ![SirCodalot](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sircodalot/32/88719_2.png) [@SirCodalot](https://forums.unrealengine.com/u/SirCodalot)\
**Post date:** [January 26, 2021, 4:39pm UTC](https://forums.unrealengine.com/t/anime-inspired-shading-model/156903/6 "2021-01-26T16:39:17Z")

</div>

> [@Envieous](#):
>
> neat! I love seeing more of these pop up :\>
> 
> How does this look when you have multiple light sources? The reason I don’t support deferred in my shading model is because when I put the lighting together I take the results from all lights and break things down into either a lit pixel, or an unlit pixel so that I’m eliminating any partial shadows that come up when there’s multiple lights whereas deferred just adds the lighting results together. I’ve searched through the source code a few times and I was never able to find where the deferred pipeline actually puts together the result of GetDynamicLightingSplit function like forward rendering does in ForwardLightingCommon.ush so I could achieve the same result through that pipeline.

I made it so the shadow can only be controlled by the directional lights, while the point/spotlights can only add more of the base color on top of it.

https://i.ibb.co/fvfswcN/image.png

---

<div class="post-metadata">

**Author:** ![Arkiras](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/arkiras/32/1008648_2.png) [@Arkiras](https://forums.unrealengine.com/u/Arkiras)\
**Post date:** [January 26, 2021, 6:52pm UTC](https://forums.unrealengine.com/t/anime-inspired-shading-model/156903/7 "2021-01-26T18:52:01Z")

</div>

> [@SirCodalot](#):
>
> Yes, it works in the Deferred Renderer and it still supports multiple light sources. You just need to connect your first texture to the Base Color and your second texture to the Shadow Color. The result looks like this:
> 
> https://i.ibb.co/XSL0zPW/Dragon-Ball-800.gif

Oh man, that’s awesome 🙂

---

<div class="post-metadata">

**Author:** ![SirCodalot](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sircodalot/32/88719_2.png) [@SirCodalot](https://forums.unrealengine.com/u/SirCodalot)\
**Post date:** [January 27, 2021, 8:32pm UTC](https://forums.unrealengine.com/t/anime-inspired-shading-model/156903/8 "2021-01-27T20:32:18Z")

</div>

I uploaded an example project to GitHub! [GitHub - SirCodalot/ShadersExample](https://github.com/SirCodalot/ShadersExample)  
It contains a useful M\_ToonBase material that you can copy to your own projects.

---

<div class="post-metadata">

**Author:** ![Anonymous\_a37eb8df8d4b42a363f5cdf74846c369](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_a37eb8df8d4b42a363f5cdf74846c369](https://forums.unrealengine.com/u/Anonymous_a37eb8df8d4b42a363f5cdf74846c369)\
**Post date:** [February 5, 2021, 7:14am UTC](https://forums.unrealengine.com/t/anime-inspired-shading-model/156903/9 "2021-02-05T07:14:57Z")

</div>

this shading model support ILM textures?

---

<div class="post-metadata">

**Author:** ![SirCodalot](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sircodalot/32/88719_2.png) [@SirCodalot](https://forums.unrealengine.com/u/SirCodalot)\
**Post date:** [February 7, 2021, 10:12am UTC](https://forums.unrealengine.com/t/anime-inspired-shading-model/156903/11 "2021-02-07T10:12:33Z")

</div>

> [@Anonymous\_a37eb8df8d4b42a363f5cdf74846c369](#):
>
> this shading model support ILM textures?

Yes, but you’ll need to separate the RGB channels and modify the values in the material graph. I might add an ILM material to the example project, so if you couldn’t get it to work, the example might help.

---

<div class="post-metadata">

**Author:** ![Anonymous\_a37eb8df8d4b42a363f5cdf74846c369](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_a37eb8df8d4b42a363f5cdf74846c369](https://forums.unrealengine.com/u/Anonymous_a37eb8df8d4b42a363f5cdf74846c369)\
**Post date:** [February 9, 2021, 9:34am UTC](https://forums.unrealengine.com/t/anime-inspired-shading-model/156903/12 "2021-02-09T09:34:36Z")

</div>

> [@SirCodalot](#):
>
> Yes, but you’ll need to separate the RGB channels and modify the values in the material graph. I might add an ILM material to the example project, so if you couldn’t get it to work, the example might help.

ok thank you！

---

<div class="post-metadata">

**Author:** ![KingKrouch](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kingkrouch/32/936134_2.png) [@KingKrouch](https://forums.unrealengine.com/u/KingKrouch)\
**Post date:** [May 27, 2021, 10:17pm UTC](https://forums.unrealengine.com/t/anime-inspired-shading-model/156903/13 "2021-05-27T22:17:48Z")

</div>

I’m wondering if you have any plans on getting this shader up and running in the UE5 preview?

I suspect that something is either wrong with how I got the shaders up, or it might be because I had to comment some code out from the RectLight and CapsuleLight integrate shader files, as it was causing some compilation issues due to the GBuffer not being passed as an argument in those functions that were modified anymore.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/c/f/cf929549e558e614c498ee1ac08df9c5892330bf.jpeg)

EDIT: Interestingly enough, after enabling Mesh Distance Fields, this is what happened.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/b/b/bb91405fd3b7608af6be9c06b4c6b8ef3956cd2c.jpeg)

---

<div class="post-metadata">

**Author:** ![SirCodalot](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sircodalot/32/88719_2.png) [@SirCodalot](https://forums.unrealengine.com/u/SirCodalot)\
**Post date:** [May 28, 2021, 8:30am UTC](https://forums.unrealengine.com/t/anime-inspired-shading-model/156903/14 "2021-05-28T08:30:11Z")

</div>

I definetly want to upgrade to UE5 in the future, but I’ll probably wait for a more stable version. If that’s the only part you commented, the shader should still work but point and spot lights will look weird.

---

<div class="post-metadata">

**Author:** ![chagas125](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/chagas125/32/88714_2.png) [@chagas125](https://forums.unrealengine.com/u/chagas125)\
**Post date:** [July 12, 2021, 1:54am UTC](https://forums.unrealengine.com/t/anime-inspired-shading-model/156903/15 "2021-07-12T01:54:04Z")

</div>

Hey, awesome model, was working really well but yesterday I got this message, do you know how to fix it? Thank you!

![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/2/0/20befed9ceb1265c35794f8365aa2d4c87b337b8.png)

---

<div class="post-metadata">

**Author:** ![sbsong](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@sbsong](https://forums.unrealengine.com/u/sbsong)\
**Post date:** [September 20, 2021, 9:45am UTC](https://forums.unrealengine.com/t/anime-inspired-shading-model/156903/16 "2021-09-20T09:45:50Z")

</div>

Are you planning to upload version 4.27 ?

---

<div class="post-metadata">

**Author:** ![SirCodalot](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sircodalot/32/88719_2.png) [@SirCodalot](https://forums.unrealengine.com/u/SirCodalot)\
**Post date:** [September 20, 2021, 10:14pm UTC](https://forums.unrealengine.com/t/anime-inspired-shading-model/156903/17 "2021-09-20T22:14:18Z")

</div>

Probably not. I’m waiting for UE5 to come out.

---

<div class="post-metadata">

**Author:** ![sbsong](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@sbsong](https://forums.unrealengine.com/u/sbsong)\
**Post date:** [September 21, 2021, 11:19am UTC](https://forums.unrealengine.com/t/anime-inspired-shading-model/156903/18 "2021-09-21T11:19:49Z")

</div>

I will try to port 4.27 myself.  
and I would be very grateful if you could give a tip about Android toon shading model.

---

<div class="post-metadata">

**Author:** ![SirCodalot](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sircodalot/32/88719_2.png) [@SirCodalot](https://forums.unrealengine.com/u/SirCodalot)\
**Post date:** [September 22, 2021, 10:24pm UTC](https://forums.unrealengine.com/t/anime-inspired-shading-model/156903/19 "2021-09-22T22:24:11Z")

</div>

I don’t know much about the mobile rendering system so I don’t think I’ll be able to help you.  
Send me a message when your fork is ready, I’d love to try it out!

---

<div class="post-metadata">

**Author:** ![KingKrouch](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kingkrouch/32/936134_2.png) [@KingKrouch](https://forums.unrealengine.com/u/KingKrouch)\
**Post date:** [December 12, 2021, 9:40pm UTC](https://forums.unrealengine.com/t/anime-inspired-shading-model/156903/20 "2021-12-12T21:40:45Z")

</div>

I managed to get this shader ported to Unreal Engine 4.27 for the time being (Although the issue with my fork is that I also updated to Steamworks v1.53). The only big downside currently being that raytracing shadows results in weird dark shadow artifacts on materials. It seems to work good enough with raytraced reflections and screen space global illumination. I’m personally pairing this with an invert hull mesh. This is probably one of the better toon shading solutions that I’ve seen in Unreal Engine that still works with deferred rendering (No forward rendering trickery needed).

A few things I’d definitely suggest adding for this to be a great universal solution:

- Having the option for multiple shading and specular steps would be nice
- Some sort of 2D subsurface scattering (Basically a small line between the lit and unlit area) for toon shaded skin would be a nice addition to have.
- Some sort of way to affect how sharp shadows can be when casted onto the material (currently, shadows when casted onto the material look sharp no matter the shading softness set in the material)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/3X/9/6/96ca1591cebfcfb9b1be21a2becae43d49801966.jpeg)

Thanks for the work done on the shader! Just needs a little more polishing and I’d recommend to submit a pull request to get an NPR shader implemented in the engine (as binary builds have desperately been needing a proper toon shading solution for a while).

---

<div class="post-metadata">

**Author:** ![DevMultiversale](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DevMultiversale](https://forums.unrealengine.com/u/DevMultiversale)\
**Post date:** [December 21, 2021, 4:38pm UTC](https://forums.unrealengine.com/t/anime-inspired-shading-model/156903/21 "2021-12-21T16:38:29Z")

</div>

This is great!  
I tried but without success. What are the changes to make compared to 4.26? Is there a fork?

[Next page](https://forums.unrealengine.com/t/anime-inspired-shading-model/156903.md?page=2)
