This is quite possibly a misunderstanding on my part. It looks like models are always shaded with flat polygons, and the interpolation setting has no effect. Regardless of the setting (Flat, Phong, Gouraud), all polygons are flat (see image below). This is using the “Lights” module, set to Default lighting. Shouldn’t Phong or Gouraud interpolation result in a less “faceted” appearance or am I mis-remembering how these work?
To clarify, Gouraud shading uses normals at the vertices to calculate lighting and then interpolates the colors across the triangle, Phong shading interpolates the normals and recalculates the lighting per-fragment across the triangle. So both require vertex normals. STL format, for example, does not save normals, so they need to be re-calculated for smooth rendeing.
In current Slicer versions, surface normal computation is enabled by default, but you can enable/disable it by adjusting segmentation representation conversion parameters:
Quick follow-up to this. It seems whenever I save models as PLY, even if I’ve computed surface normals before saving, when I reload the model files, the normals have been lost. Does Slicer save surface normals in PLY files?
VTK’s PLY reader reads point normals, but VTK’s PLY file writer does not write them.
I’ve submitted a merge request to VTK to add this feature:
Probably it can get into VTK in a couple of days, but I’m not sure when we’ll update Slicer’s VTK to include this update. If it is urgent then we can cherry-pick this feature (and then it’ll be available in the Slicer Preview Release the next day), otherwise it’ll be available in Slicer in a few months.
If I wanted to do a local build that would incorporate the VTK version with this change, how do I go about that? I tried changing _git_tag in External_VTK.cmake to the latest SHA but I get the following error (Windows):
Performing update step for 'VTK'
fatal: reference is not a tree: 21f9d5e14a695d9fc387aee86b28c36bbe19fdb5
CMake Error at D:/S/S4D/VTK-prefix/tmp/VTK-gitupdate.cmake:175 (execute_process):
execute_process failed command indexes:
The latest master VTK version does not contain some of the fixes that Slicer needs, so you need to backport the PBR fix into Slicer’s VTK. I’ll try to do this for the official Slicer release today or tomorrow.