Smooth shading not working even with explicit flatShading: false
See original GitHub issueDescribe the bug
According to docs, smooth shading is the default. Unfortunately, I cannot set it up.
To Reproduce
I just started with three.js, but to my understanding it should be fairly straightforward. Shade smooth is the default, and also can be explicitly defined by material({ flatShading: false })
I created a non-indexed geometry procedurally using BufferGeometry like below. Note I have called computeVertexNormals(true) (the true comes from some stackoverflow answer, but it doesn’t help so idk)
Is it somehow related to the fact it’s non-indexed?
Live example
https://jsfiddle.net/high_byte/e6chLudk/
Code
geometry.setAttribute("position", new THREE.BufferAttribute(positions, 3));
geometry.computeVertexNormals(true);
var material = new THREE.MeshLambertMaterial({
color: 0xdf5000,
flatShading: true,
side: THREE.DoubleSide,
});
mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
Smooth Shading option not working - Blender Stack Exchange
When you activate smooth shading on disconnected faces, Blender treats each one individually and it looks like flat shading because each ...
Read more >Smooth shading in THREE.js with varying triangle orientation
I am just using a simple phong material: let material = new THREE.MeshPhongMaterial({ color: new THREE.Color('#FFAA44'), side: THREE.DoubleSide, ...
Read more >Flatshading not working - Questions - three.js forum
Material.flatShading is always false by default. So setting it explicitly to false make no difference.
Read more >Standard material has flat shading when loading GLTF at ...
Describe the bug Shading appears flat, no lighting effects, when using the MRTK/Standard material with meshes that have had normals ...
Read more >Geometry Shader - LearnOpenGL
A geometry shader takes as input a set of vertices that form a single ... Now that you (sort of) know how geometry...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, in a non-indexed geometry every triangle has unique vertices from every other triangle. This basically ~makes smooth shading impossible~ causes
computeVertexNormals()
to compute flat normals, not smooth ones. Try usingBufferGeometryUtils.mergeVertices( geometry )
first, then computing vertex normals. If you are having trouble with that, please use the forum or stack overflow.@donmccurdy
nit. I think that should be rewritten like so: