google / draco

Draco is a library for compressing and decompressing 3D geometric meshes and point clouds. It is intended to improve the storage and transmission of 3D graphics.
https://google.github.io/draco/
Apache License 2.0
6.46k stars 960 forks source link

Normals problem #348

Closed Aeros-zz closed 6 years ago

Aeros-zz commented 6 years ago

Hi, I have been testing draco since a month, it's a good product, we like speed and compression size. I use DracoLoader for ThreeJs.

I still have one problem. I'm exporting obj file without normals to keep small file size for uncompression and decoding speed. Almost all meshes are rendered correctly, the normals are well computed. But I have problem with some meshes, as you can see in the screenshots (smooth, flat, wireframe).

Rendering without modification (smooth) causes normals problems, when I set 'flatShading' to true on the material the mesh is correctly rendered.

I tested OBJLoader2 from ThreeJs with the option 'useIndices' and the mesh was correctly rendered.

I found this issue Indexed Geometry when decoding #343 that will be interesting and getting closer to my problem.

Do you have an explanation, or are thinking of correcting this normals compute?

Does Draco decoder support per-vertex normals? If that is the case, are the normals computed by vertex or are they computed by face and copied for each vertex?

Best regards,

ondys commented 6 years ago

The image on the left looks like it is averaging normals across all faces which creates the undesired effect. What you probably want is to specify some crease angle that will average normals only from relatively flat areas.

Note that if the input encoded model does not have normals, Draco doesn't generate them either. If that's the case, the normals are most likely generated later on by three.js

Aeros-zz commented 6 years ago

Thank you.

What's the best location in the source code of draco or threejs to compute the normals? I would like to prevent threejs from overriding the normals I would compute.

Best regards,

ondys commented 6 years ago

Draco does not compute normals. If the input model that you compress contains normals, Draco is going to preserve them. If the input model has no normals, the decoded model will have no normals as well. In our example viewer we use THREE.js function |computeVertexNormals()| that is called on the decoded geometry.. there is a chance you may be using it in your code as well.

Aeros-zz commented 6 years ago

Thank you. The problem seems to come from threejs smooth normals computation. I assume that it implements something similar to this: https://stackoverflow.com/a/45496726

supermoos commented 6 years ago

@Aeros did you find a way to solve this? Encode normals to file before draco compression? Or is there a way to get the geometery.computeVertexNormals() from three.js to work with the draco compressed file similar to a non-draco compressed file?

Aeros-zz commented 6 years ago

Sorry for the late reply, a skiing accident... We decided finally to embedded the normals, we did not have time anymore to find another solution... It take more physical space (the double), the dowloading time is a little more longer, but the loading time remains very correct. If someone finds another way, it will be with pleasure...

FrankGalligan commented 6 years ago

Closing as this is an issue with three.js normal calculation.