[RESOLVED] Real-time shadow of hat not cast properly on face of character

Hello everyone,

This is my first time posting a question on the forum, and I hope you guys can help me out. I have been facing the following issue:

I made a 3D model in Blender for a character wearing a hat. The hat does not cast a correct shadow on the forehead. Here is a screenshot of the issue:

These artifacts also show up, it may has to do with the same problem (the pants, the blocks on the armor is due to a low shadow quality setting, as this model is made for a mobile game):

I was able to recreate the problem using a seperate cube as the head:
4997018--488222--block.jpg
When I make the cube small enough it does work.

Here is a wireframe of the hat mesh:

I have been trying to fix this by letting Unity generate a lightmap for my character model, but that doesn’t seem to fix the problem. I tried making changes to the model so the head doesn’t touch the head, but that also sadly doesn’t fix it. I also tried changing the Bias of the light, and setting it to 0 fixes this issue, but creates a lot of other artifacts in the scene that are not desirable.

This is the only light in the scene:
4997018--488213--lightsettings.jpg

I know this is a complicated issue that probably has to do with either my lighting setup or my 3D model, but does anyone know what the problem is and how I can fix this? I would be very grateful.

Cheers,
Jurrien

Yep. Basically you have to play with the bias until you get as close as you can get without other artifacts showing up. If you look at a lot of AAA games you’ll see this same problem show up (albeit much less obviously so).

For example, Fallout 76:

Notice the line of sunlight across his forehead? Or the lack of shadowing at the point the shirt color and jacket overlap? Fallout 76 has comically thick hats, in part so they fit on a large variety of heads & hair, but also to minimize that shadow biasing artifact.

But, okay, that’s Fallout 76. What about a really high quality single player game? Like Red Dead Redemption 2?

This is an official screenshot used for the game’s marketing. Notice anything odd on the woman’s forehead just below the hat where here hair is?

Or the ear in this image?

RDR2 uses state of the art shadow mapping, and still has the problem.

Technically the problem has been fixed in the past. Crysis 2 used a technique called screen space self-shadowing, and there’s a few assets on the store that do this, but they’re expensive to render.

2 Likes

Wow, this was not the kind of answer I expected at all, but that’s really, really interesting! The screenshots you posted really suprised me, especially the ones from Red Dead Redemption 2. Thanks, I’ll go tinker with the bias, and if that doesn’t work, I will look for some kind of graphics hack (maybe disable shadow casting on the head, but still make it cast on the rest of the scene, I think that will look good enough becase the lighting in my game won’t be that dramatic).

Thank you!

Alright, I got it working as I want! I decreased the bias to 0.02 (that works best for my situation). I fixed the other artifacts I had on the hat by adding some more geometry so shadows can be mapped better.

Here are my results:
4998377--488408--correcthat.jpg
As you can see, there is a small band that’s a little bit lighter, but I don’t want the bias to be 0.

1 Like