Light / shadow acting the wrong way on an imported mesh

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By s-traut

I’ve recently made a quick scene with some light tests, using GIProbes / directional light and some environment config.

And I’ve tried importing different mesh types into that scene, a voxel based one, which works perfectly fine, and another one with a more complex shape, and the shadows/lights looks wrong… It looks like the direction is wrong, maybe this is caused by my mesh itself, I don’t really know…

image showing the issue

HI,
the shadow is just right.
The shading looks wrong. I would guess the normals of the mesh are inverted.
This often happens if you mirror meshes in a 3D editors.

klaas | 2021-07-21 19:24

Yeah, you just need to flip the Normals of certain faces in your 3d modelling software. You can visualise them as red and blue in blender in the view settings.

Snail0259 | 2021-07-22 12:07

Thank you for your quick answer.
Here’s how my mesh looks like in blender, normals doesn’t seems to be wrong to me, or am I missing something?enter image description here

s-traut | 2021-07-22 14:09

Hi,
can you check the scaling? Some editors just invert the scale (-100%) to mirror.
Wich is technical correct but often results in odd behaviour in realtime rendering.

klaas | 2021-07-22 15:21

Blender scale export is 1:1
On my scene it’s also looking good, I don’t think the scaling is wrong

s-traut | 2021-07-22 16:04

How about checking it with a “normal shader”

make a new shader material:

shader_type spatial;
render_mode vertex_lighting, unshaded;

varying vec3 c;

void vertex() {
	c.rgb = ((WORLD_MATRIX * vec4(NORMAL.rgb,0.0)).xyz /2.0 + 0.5);
}

void fragment(){
	ALBEDO.rgb = abs(c);
}

This shows the “true” normals when rendering.
Compare it with a “normal” mesh thats looks alright with the same shader.

klaas | 2021-07-22 18:24

Thank for the advice, this helped me realize that it’s a problem with my scene and not the mesh itself, I’ve tried multiple obj files and they all have this shading problem at the same agnle…

I’m looking forward to find a solution, or maybe you guys can help me about this?
Thanks for the help!

Here how the two object normals renders with the shader

enter image description here

and here without the shader enter image description here

s-traut | 2021-07-24 13:19

:bust_in_silhouette: Reply From: s-traut

I find out the issue, it was really stupid, and cause by the Bias in the Shadow option of my directional light, the value was at -2 (???) And cause the shadow render to be totally messed up.

Thanks to everyone who helped!
enter image description here