• 3D
  • Problem with shadows

Hi, sorry if this is in the wrong section, but I ran into another little problem whilst working on my game. Would anyone happen to know how to fix shadows being choppy without having to turn on reverse cull facing? Enabling reverse cull facing on the lights does fix that problem, but it brings another one where the light bleeds onto the other side around the edges of the walls. This is the problem I have and am not sure how to fix:

If I enable reverse cull facing on the lights I get this problem instead:

My guess was that the model I made for the house could cause that issue since it's a single model with a complex collision, but I don't know nearly enough about this to really know what could cause it.

Thank you in advance for any help or suggestion :)

You could try tweaking the bias setting. Personally I'd go with the light bleed and make sure the wall sections have a baked or manually created faux-AO mapped to a rim of polygons at the bottom and top of each wall segment that would cover-up/hide the light bleed.

Oh I see, yeah that was my plan originally, but I thought the light bleed was bad in some way, but I could definitely try and simply hide it as you suggested or even simply making sure the walls are well inside each others where it could bleed without causing artifacting, I could maybe even try and connect the different rooms walls together as a module so I can adjust their height a little easier.

As for the baked ao map I'll look into it right away. I didn't know how to make it when I made that map so it would make sense why bleeding could happen around these locations.

Huge thank you! <3

Hmm for some reason now reverse culling won't affect anymore when I turn it back on. Welp, time for some more hours of debugging haha. This project's been quite a lot more work than I thought originally.

That doesn't look right. Godot shadows can be a little glitchy sometimes, but I've never seen it that bad. Can you explain more about your setup? What kind of lights you are using and anything special about the floor model?

I've made the scene as simple as I could, a spotlight that was set to 80 degree angle, shadow set to .01 bias since it was the best looking with reverse culling, (for some reason with an omniLight the 0.15 default looks fine without reverse on as long as shadow angle isn't too close to the surface.) As for the floor and walls, the whole model is made into a single mesh made on blender (the meshes themselves are still disconnected, but the whole thing is joined together.)

I am planning on redoing them with proper models since it was only for scaling purpose at the beginning, but since I'm at the point of making actual models for that project I thought I'd start working out the small bugs like that shadow problem.

@cybereality said: That doesn't look right. Godot shadows can be a little glitchy sometimes, but I've never seen it that bad. Can you explain more about your setup? What kind of lights you are using and anything special about the floor model?

Unity and Unreal both had that problem as well, but unless it also works that way on godot, on these engines it helps the shadows to have a proper UV map on the model. Could that be the case for godot too?

It could definitely be my models that are made on a way that doesn't work well with godot since I'm not at all great with blender haha.

I'm dumb.. I forgot to add a new spatial material when I reimported the model. Reverse Cull Face now works without a problem. It's still bleeding around the edges, but that I can work out relatively nicely by hiding it.

I just spent the last 2 hours messing with it, but I got it to work.

First, make sure you apply all transforms in Blender, and check that the normals are correct (you can do recalculate outside, that will fix it). Then you need to subdivide the mesh or add mesh loops. For my test I think I had about 4 quads per the height of the wall in even squares. So about 1 meter by 1 meter. For some reason, Godot bugs out with the shadows if you have a really huge single plane object (at least with spotlight shadows). But doing those things in Blender will fix it. And for the spot light, you do need reverse cull face on. Also, make the wall as thick as possible and that will remove the leak leaking at the corner.

Also, this is already fixed in Godot 4.0, but it may be some time before that is ready. https://godotengine.org/article/vulkan-progress-report-7

Huge thanks! Yeah my model is far from subdivided at all haha. It's quite literally just the plain model with cubes deformed a little bit in some places.

I mean it does makes sense since the area the shadow tries to apply on is technically stretched over the full quad, so if your quad is 10 meters by 10 meters, it would end up stretching the same shadow over that surface which could lead to the artifacting that I had. Once I get to work on proper models for walls and such I will make sure it has plenty of quads. Especially since the engine supports quite a lot of high-poly models before even having an effect on the framerate apparently haha. I was surprised to discover that when I made a 3k vertices flashlight and barely noticed a difference when having multiple of it in the same scene. Although I am only using materials and no textures currently, so that could be why.

Anyways, thanks again for the load of help! You two are the best <3

Just wanted to show the result so far :) I subdivided the current house model so there would be more or less 2 to 4 quad per meter and this is the result so far: Still not 100% perfect in some areas, but by making the flashlights reverse culling enabled and the room's light not reversed, it gives that result. I will keep trying out stuff until I get it worked out still, but I'm happy with this since I can hide most imperfection with models and such.

Thanks again! :)

PS. The table is messed up because the model itself is ugly haha. I need to redo that at some point. Just wanted to start placing stuff around :D

So about 1 meter by 1 meter. For some reason, Godot bugs out with the shadows if you have a really huge single plane object (at least with spotlight shadows). But doing those things in Blender will fix it. And for the spot light

Godot's primitive PlaneMesh and CubeMesh have subdivision options available in the inspector. You can increase those above the default values to fix issues related to shadow rendering when using large planes or cubes.

PS: I opened a pull request to improve the documentation around shadow bias configuration: https://github.com/godotengine/godot-docs/pull/5340

@Calinou said:

So about 1 meter by 1 meter. For some reason, Godot bugs out with the shadows if you have a really huge single plane object (at least with spotlight shadows). But doing those things in Blender will fix it. And for the spot light

Godot's primitive PlaneMesh and CubeMesh have subdivision options available in the inspector. You can increase those above the default values to fix issues related to shadow rendering when using large planes or cubes.

PS: I opened a pull request to improve the documentation around shadow bias configuration: https://github.com/godotengine/godot-docs/pull/5340

Huge thank you for that info! That would indeed help if it was a little better explained in the documentation. I got around the distance problem between the walls by adding a plane facing the opposite way in the blender model directly. It's not perfect, but so far at 0.05 Bias and 12288 Shadow Quality I get no distortion, the shadows look super crisp and pretty, and haven't had any other bleeding occure.

To make this a little more clear, my walls are setup a little weird compared to a regular wall. I made a simple wall in the form I wanted, then added a plane behind it 1-sided opposite to the face I want the wall on. Then in Godot when I place the wall and need one on both sides, I simply duplicate the wall and rotate it 180 since the blocker itself lands right on the same coordinate for both sides and the wall itself is offset a little from the origin.

A little picture to show what I mean on blender: That's my single wall setup that I duplicate and rotate by 180 to fix the light bleed problem.

The Result on Godot between the walls:

12288 Shadow Quality

Only power of 2 values are currently accepted for the directional shadow size and point light shadow atlas. Values specified in the Project Settings will be rounded up to the next power of 2 (which is 16384).

There's a pull request to allow using non-power-of-two sizes for the directional shadow size, but it's unlikely to work for the point light shadow atlas.

Oh I see, I thought simply doing 4096*3 would work, there seemed to be a little difference between both value, but that could just be the rendering updating and my brain being slow as usual haha.

To be fair 16k does work pretty well regardless. I just wanted to keep it as low as possible so that game could run as smooth on low specs as possible. I'll have to do a run of optimization at some point still, but thought I'd try and keep it simple from the beginning.

Anyways, thanks again for the info! It's nice to know that only power of 2 works currently.