Threejs lighting rendering

1. The object to be drawn is dark and not slippery

First of all, let's understand the principle and mechanism of rendering

normal vector problem

  The normal is the vector normal to the surface of the object we want to illuminate. Normals represent the orientation of the surface so they play a decisive role in modeling the interaction of light sources and objects. Every vertex has an associated normal vector.

  If a vertex is shared by multiple triangles, the normal vector of the shared vertex is equal to the sum of the normals of the shared vertex in different triangles. N=N1+N2;

  So if you don't do any processing and directly pass the point of the 3D object to BufferGeometry, then because the normal vector is synthesized, after the interpolation of the fragment shader, you will get this dark effect.

Solution:

geometry.computeFaceNormals();

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325721557&siteId=291194637