OmniLight illuminating wrong side of mesh - Help

Godot Version

4.3

Question

I have a scene with a campfire surrounded by a bunch of other props. The omnilight from the campfire is casting light onto the wrong sides of the meshes.

I have strong reason to believe this is due to the toon shader I’m using as it’s only happening on meshes that are using that toon shader.

The shader in question can be found here: TRUE BoTW Toon Shader! - Godot Shaders

I also made a video demonstrating the error and a couple things I tried, here: https://youtu.be/Sq8OYxkgRDI

Any ideas will be greatly appreciated.

At a guess it’s something involving the normals. Maybe your normal map is backwards? It seems like that’s a highlight that should be on the lightward side of the object.

1 Like

Thanks for the idea. I tried flipping the normals (although I’m not sure I’m doing it right) and that didn’t help. It’s occurring on every mesh that’s using this shader though, even ones that aren’t using normal maps.

Do you have backface culling on?

nope, culling is disabled.

I wonder if it’s the backfaces inside the model leaking through.

How might I be able to check that? And is that likely to be happening on all the character meshes in the game too (since they all have this same issue as well)?

Well, the easy check is to try enabling backface culling on that rock in your sample image and see if that fixes the problem. If not, back to the drawing board.

Oh yeah, already tried that. Didn’t help unfortunately.

(btw I linked the original shader in this post since it has the same issue but I’ve made a lot of modifications to it here and this is the one that’s actually being used in that image: Toggleable Triplanar Toon Shader (Weird light issue, please help) - Godot Shaders —again both still have the same issue though)

My best suggestion at this point is play with the various color inputs (highlight, shadow…), setting them to something like full intensity magenta or full black to see if you can figure out which (if any) is driving that artifact. That ought to at least narrow down where to look.

I solved it! Just had to multiply by ATTENTUATION and clamp it to stop the shading from diffusing too much (to maintain the toon effect).

The last line in the shader light function is now:

DIFFUSE_LIGHT += ALBEDO * add2 * clamp(ATTENUATION, 0.5, 1.0);

EDIT: Did not solve it lol --clamping the attenuation just reintroduces the issue. Just multiplying by unclamped attenuation mostly solves the problem but sometimes the shadow trails off into too diffuse of a gradient for a toon shader so I’ll have to come up with a solution for that now

1 Like