- Home /
Directional Light seems to have no effect on MeshRenderer.
In my 2D project I have some GameObjects with MeshRenderer components generated by script. The renderer use a Sprite/Diffuse material. The other properties of the renderer are the following (although I've tried to change everything):
I also have a Directional Light in my scene which Baking is set to Realtime.
My problem is that the meshes are too dark. It seems that the Intensity and the Z position of the Directional Light has no effect on it. Objects with SpriteRenderers are affected by changing the Intensity. Also, my MeshRenderer objects are affected by Point Lights.
What am I doing wrong? How can the MeshRenderer be correctly used with Directional Lights?
Have you tried testing your scene with the mesh renderers already on the objects when you start? Have you tried changing the direction of the directional light? Lastly, I see a sprite mat on your object. have you tested it with a different $$anonymous$$at?
I didn't find any other material which makes the desired look. Changing the direction of the light did not help either.
I put a plane mesh in the scene and it was lit correctly. I found out that when I rotate it by 180 degress around the X or Y axis, the light has no effect on it, like on my generated meshes. I thought I need to rotate my meshes so I changed their normals by changing the orientation in the mesh triangles. This didn't help either, same effect.
Later I found out that the meshes start being lit when I move them closer to the camera. This is independent from the position of the light or any other objects. I am out of ideas for now..
Answer by barjed · Mar 29, 2015 at 07:33 PM
This might sound like a long shot but did you try rotating the directional light (try all three axes), so that it shines at an angle?
I think the default rotation of sprites is perpendicular to directional light's rotation, so that's why it might be affecting those.
Interesting, when the direction of the light is not perpendicular to the Z plane, parts of the meshes are lit - but the regular sprites get darker, of course.
This is confusing for me since in my original case it seems like the light comes side-on to the normal vector of the meshes and they are head-on when the light is parallel to the z plane. I thought the normals are calculated from the triangles which consist of vertices and each of my vertices are on the z plane so the normals should be perpendicular to it. Am I missing something important here?