Nice Ichinose! I stumbled trying to implement this in UE5 so thanks for the port. It seems like projects should transfer over fine. I still use the original specular in very small amounts, a little torn on it but sometimes it can add some nice subtle gradients in the original.
I’m no .ush expert but one thing I did using this shader recently is fighting off self-shadowing on characters while keeping a HQ environment shadow and mesh light colors with no self shadow interference. It relies on toon subsurface color to do the coloring on top of existing base color+like 0.05 emissive or so.
Sorry if it’s a little long and off topic as a whole, but I think the results are nice when used in a megasaturated 2000s-ambient style lighting setup, and somewhat relevant as a way to use this shader.
Guide:
- Make a copy of mesh that casts shadows on lighting channel 0 and set it to hidden shadow/not visible. I use enable dynamic inset on skel mesh, looks great on otherwise not so great CSM. (Not trying VSM yet)
- Original mesh on light channel 1 only.
- All point/spot lights now need to be split if shadows are desired. (!)
- Place two lights in the same location: One for channel 0 (environment, shadows), and one for channel 1 (character, no shadows).
- I’m using many movable lights for all this and it’s ok as long as one writes good enable/disable distance check functions since lights on the other side of the planet are adding up 0.02ms calls.
Now you’ll have really pretty colored lighting on meshes with subsurface colors as well as a HQ shadow with no self shadow artifacts on the mesh itself the good part about this is that you can tweak each light nicely to fit with your toon character and how it plays into the environment.
Double mesh hidden shadow is nothing new, but one can extend it to the environment as well:
Usually one would do sun-line trace+emissive modifier like in genshin impact to change the toon char brightness. This method is fine if used with good art direction and manual control, but for the sake of this setup, let’s try two directional shadowed lights (!)
Split the dir-light into two equally powered lights operating on channel 0 and 1+2, respectively. I know two shadowed dir-lights is a big yikes, but performance has been surprisingly fair and worth it compared to nasty csm shadows in my project.
- Directional light 1: Intensity 0.5, channel 0, shadows on.
- Directional light 2: Intensity 0.5, channel 1+2, shadows on.
- (One can switch ratios up slightly to alter shadow strengths between characters/environment. If you want slightly less intense player shadow, use lower intens for d1, like d1=0.4, d2=0.6)
Fully lit areas will be doubly lit than the player operating on channel 1 only, but with a good setup in the toon material and all the world materials one can get around this rather easily and it will blend together nicely.
The trick to the open world shadows is in channel 2 on large meshes. The player shadow will be equal in strength to the ground below if using either 0 only OR 0+2.
(Use channel 0+2 on landscape).
Mesh light channel settings:
- Channel 0: Shadows the environment (half), light passes through characters. Use on environment and hidden character shadow meshes. Not bad for small meshes like a fence if you don’t want aggressive shadows on a character’s legs
- Channel 1: Use only for characters to receive lights, disable shadow casting on c1 always unless you managed to make it look good - I couldn’t.
- Channel 2: Shadow both player and environment, by half.
- Channel 0+2: Fully lit mesh, strong shadow, player shadow.
Hope it’s helpful to anyone else who likes using this shader.