deleted

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

It’s definitely not due to a lack of interest in NPR among Unreal developers, my thread is the highest voted feature request in this section and the only place I’ve shilled it is a footnote in the thread for my shading model.

1 Like

These are the two things that have been making my life hell for the past two years. I think I saw something about ortho getting fixed in 5.2, and it looks like Strata might allow for custom shading models, so right now I’m just biding my time.

1st of all, you can achieve same result in UE with just Material, which has been done by VRM4U.

Shading model exists because it is the best performance you gonna get.
Techinically you can re-write shader in Materials, but performance goona be horribly worse.

You are right that Unity and Gobot’s rendering pipelines are more friendly for user modification (especially in runtime), but they have big limit if you really push them on complexity and performance.

For the NiloCat shader you posted, I don’t see any use of Gbuffer in sample code, so i assume it is done through forward shading, so you won’t want to use this if you have a big level or many light sources. It looks nice, but if you want to make it game production viable or scalable, you gotta do a lot more work yourself. Even for Genshin Impact, it doesn’t have real dynamic shadow for their toon shaded character. They use character-specific light source to fake it for optimization. Unreal Engine just gives a lot of optimization and high level features out of the box starting with deferred shading.

If you try to achieve a real production ready custom shader, it is more difficult in UE but it will be less work in total. You basically need to create your own shading model. It is definitely worse learning curve, but it isn’t rocket science and there is a good example that community has done good job in creating toon shading model. Toon Shading Models, Stylized Rendering Experiments

I won’t really blame UE for harder rendering pipeline customization. I think it is a fair tradeoff. You are basically complaining why a motorcycle cannot be moded as simple as a bicycle when you see a fancy modded bicycle.

I’ve looked into VRM4U on UE. Materials alone will not allow you to achieve high-quality, performant NPR.

There are several shading methods in VRM4U. The one that offers the best NPR results is one where you have two overlapping models, with one acting as a shell that renders the inside model via post-processing (like a looking glass with a filter). Considering that NPR will usually require an extra model for the outline using inverted hull (post-processing outlines are not as reliable), if you use this shading method from VRM4U, you’ll have 3 overlapping models in total.

If you use the shader performance inspector, you’ll see that this shading method is in the red for shader complexity. It can gets towards the white (extremely bad shader complexity) if you place the camera inside the model while looking out. Comparing this shading method with any of the custom-code UE solutions, you’ll see that the custom-code solutions are generally in the green for shader complexity.

On PC, Genshin Impact does have dynamic shadows. Try walking through shadow and you’ll see it being casted on the character dynamically. The game also has a non-dynamic shadow version of its toon shader on mobile, where shadows are just either on or off depending on light exposure. The casted shadows are blended into the directional light vector-based shadows seamlessly. Not something you can do easily, or at all, in UE.

Deferred shading has many downsides for NPR, because it gives you less control over lighting and shadows. This issue is made worse with UE’s lack of custom shader integration. If you review the code for any of the custom NPR UE shaders, you’ll see the code is scattered everywhere. Even in the code, custom shading wasn’t top priority.

And even worse, with newer versions of UE, the scattered code that you were able to integrate your NPR rendering code inside of will be moved around or even removed. This can break your NPR implementation, making maintainability extremely difficult. You may even need to re-implement your solution if old rendering functionality were lost upon version upgrades.

2 Likes

upvoted, not everyone is trying to make a quixel megascan remaster ultra realistic ‘insert old video game’ youtube video… Please epic :slight_smile:

Thats one of the biggest downsides I have when doing it myself. I quite understand how to achieve it but its not my area of interest. It would be really helpful if we had a shader or system that is robust and doesnt neccessarily break when updated. I dont feel confident enough to maintain a shader on my own and I am really interested in creating stylized projects mostly.

Like I said, that’s the tradeoff. Writing full shader with just Material won’t give you best performance. That’s why shading model exists in the first place. I don’t see what point you are trying to argue with here.
And YES, the performance of VRM4u NPR implementation is bad, but there are alway other implementations to go for better performance (even though will never be as good as shading model). Here is another example of pure BP based NPR utilizing SDF (【UE5卡通渲染(不改代码能不能做?)】 UE5卡通渲染(不改代码能不能做?)_哔哩哔哩_bilibili).

That’s actually not true. The Deferred shading still gives you full control over lights through GBuffer and, in some way, it is even more convinient since all lighting information are put together instead of calculating one lighting source at a time. The NPR algorithm, for sure will be more complex with using GBuffer in deferred shading (cuz you need to process all lighting information at once instead of accumulating individual calculation), if that’s what you are complaining about. Otherwise, deferred shading itself shouldn’t be any blocker for making good NPR.

Not gonna respond the rest of complains, but here is a quick summary of my points:

  • Don’t draw the conclusion of it is impossible with this and that without thorough research. Many impossibles you mentioned above are imprecise. Go explore the community and resources for solutions. For many NPR developers I keep track of, they constantly come up with new solutions/experiments for their own NPR in UE, which all have decent result.
  • I understand the eager of having better customization support for rendering pipeline, but if you are really keen in making your NPR project happening. The worse learning curve and techinical challenges shouldn’t stop you.
  • At least from my knowledge of the source code, it won’t be easy for Epic to make UE having custom rendering pipelien like Unity. Before that really happens (probably not any soon), creating custom shading model isn’t a bad choice to go. You can’t always rely on out-of-the-box stuff for a good project.

Anyway, I wish this thread drives more towards solutions intead of just more complains.

1 Like