unlimitedbacon / stl-thumb

Thumbnail generator for STL files
MIT License
1.09k stars 93 forks source link

No shaders in default? #59

Closed LeandroMarceddu closed 2 years ago

LeandroMarceddu commented 2 years ago

Hey

By default (in Windows 11), running a command like this:

./stl-thumb.exe D:\Projects\PlaterFlow\output\plater_main_1.stl plater.png

Returns the following plater.png: plater

Is this normal/correct? If not, what's going wrong here?

unlimitedbacon commented 2 years ago

Looks like an issue with that particular .stl file. I think the normals are reversed. You'll have to bring it into Blender or some other tool to fix it.

LeandroMarceddu commented 2 years ago

You seem to be on to something, I've tried using the tool do to individual STLs and this works flawless.

Opening MeshLab to view which are the normals that are inverted revealed none though. Below is a view with the normals enabled and this seems to be correct. image

I've included the STL which has been giving me these issues below. plater_main_1.zip

All the regular STLs (e.g the individual ones) seem to be working and rendering okay, it's just that when they get grouped together and saved into a single STL this seems to be breaking it.

LeandroMarceddu commented 2 years ago

So, I took it to Netfabb.

Unaltered it keeps giving me the same view as the first post. After performing the 'standard repair' by the (very old) netfabb basic, it renders to the proper view.

Analysing both files gives me this: Old: image Repaired STL: image Other than edge length I see no noteworthy alterations.

Tried looking into what alterations the 'repair' function brings but have not found any clue whatsoever. If you have any ideas.

Attached repaired STL file. plater_main_1 (repaired).zip

unlimitedbacon commented 2 years ago

Oh look, someone is printing a Voron.

Anyways I had a look at your file and I know what is going on. STL files optionally provide the normal vector for each face of the model (https://en.wikipedia.org/wiki/STL_(file_format)#The_facet_normal). Many programs simply ignore the normal vector if it is given in the file and calculate it on their own. For the sake of speed, stl-thumb uses the normals from the file if they are given and only calculates them if they are not.

Your file has the same normal vector for every face, [1.0, 0.0, 0.0], so each face receives the same shading. Whatever is generating your file should either provide valid normals or just use [0.0, 0.0, 0.0] to indicate that the receiving program should calculate them.

If I force calculating normals in stl-thumb then your file renders correctly. plater

LeandroMarceddu commented 2 years ago

Plater is on the generating end of the files so instead I'll look into forcing stl-thumb to calculate the normals :)

Thanks a lot!