Question

Consider this simplistic house 3d model. It has a simple Cube unwrap applied with a few tiled textures.

enter image description here

When I add a point light in front of it, the house looks normal, but the surrounding ground (which is part of a large terrain mesh) is not lit.

enter image description here

Inside the house mesh, the lighting is applied funny, somehow relating to the vertices instead of calculating and adding color correctly. Notice how the lighting is not spread evenly, but you can actually see a polygon there:

enter image description here enter image description here

I think this is the reason why the huge terrain mesh is ignoring the light, because the polygons are very huge and there are only a few vertices. It seems the light needs a vertex nearby in order for it to show.

Here is a part of the huge terrain mesh without light: enter image description here

I add a light: enter image description here

Notice how the light placement is not directly next to a vertex: enter image description here

When I place the light close to a vertex, the effect suddenly becomes super intense enter image description here

When I place the light in the middle there is barely an effect enter image description here

How can I make my models have even light everywhere, regardless of the size of the model and the amount of vertices it has?

Was it helpful?

Solution 2

Found it eventually thanks to @WestLangley

I was using MeshLambertMaterial before, now I switched to a PhongMaterial and set material.perPixel to true.

Also don't forget to set material.needsUpdate to true if you are dynamically adding lights! (as was the case with me)

OTHER TIPS

You have to stop doing per-vertex lighting and start doing per-fragment lighting. You need a fragment shader that takes the position and normal of the point, as well as the light position/direction, and performs the various lighting calculations.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top