Why a flatshading:true dosen't work?

i’ve created a cylindergeometry,and i’ve created a lambertmaterial with flatshading:true,but the flatshading doesn’t work.wating for the help!

the faces color is always drawing smoothly

Have you set material.needsUpdate = true?

https://threejs.org/docs/#api/materials/Material.needsUpdate

i used ‘new THREE.MeshLambertMaterial({flatShading:true});’
did’n created and changed.thanks your attention anyway.

This whole topic about flat shading and MeshLambertMaterial has a long story. You can find all details here.

The tl;dr version is that that Material.flatShading achieves flat shading in the fragment shader. Since MeshLambertMaterial uses Gouraud Shading, the lighting equations are implement in the vertex shader. So the shading is calculated for each vertex and then the resulting color at each vertex is linearly interpolated over the fragments. Because of this, you can only achieve flat shading with MeshLambertMaterial if you prepare the geometry in a special way. When using Geometry, you can call .computeFlatVertexNormals() to solve the problem. The following demo shows this approach:

https://jsfiddle.net/rfhky0mn/

5 Likes