deleted

I’m very surprised this didn’t get any traction, similar to Make the engine more accommodating for custom shading models. Perhaps because Unreal Engine developers are all interested in realistic PBR rather than NPR? Well, at least you and I are interested in NPR.

I’ve been trying to do something similar, and it should not be this hard to get anything 1/4 as decent as the demo in your GitHub link.

With materials, if you approach the problem with using the directional light as a vector, you don’t get shadows casted onto your shaded actors, and light colors from other light sources go out the window. With the post-process solution you get access to the diffuse data to do your toon shading, but that would cover your whole screen in toon shading (assuming infinite expanse post-process). You can probably use a stencil buffer to limit only the toon shading to your actors, but that makes having multiple toon-like materials on your actors very difficult, like toon metals for example. Another solution that I’ve seen, which is not very performant, but does a similar job to the post-process plus stencil buffer solution, is to duplicate your actor mesh and coat your actor with this mesh. Then apply your toon post-process material onto that duplicated mesh.

Outside of those extremely inadequate and hacky options, you have one last option, which is engine source edit. Unfortunately, the shader code in the engine is extremely jumbled and separated. The shading code is all over the place. There’s no one entry point to put your shading code. You literally have to (1) know the shading code along with a bit of the C++ side to introduce your shader into a material and (2) know how Unreal’s rendering path (deferred or forward) works so you can put the code in the right place.

Epic’s Fortnite has several toon-shaded characters like the Naruto, Dragonball, and Rick & Morty skins, but they’re definitely done with the directional light vector shading method. Note how shadows don’t cast onto these toon-shaded characters. Surely someone saw the inadequacies of the engine’s NPR?

One interesting game I saw is Ni no kuni: Cross Worlds, which seems to have casted shadows on its toon shading. Likely done with extensive engine code edit.

There are a lot of features that UE5 is focusing on and, sadly, it doesn’t seem like making NPR slightly easier to implement is even on the horizon :frowning_face:

1 Like