Smooth out SCNGeometry using subdivisionLevel

468 Views Asked by At

We are working on an app similar to iPhone's Animoji app. We have created our own 3d model, which looks quite nice, the only issue is that there are edges around the eyes or nose of the model which are not smooth. Model has been prepared in Maya 3D software.

See the screenshot

screenshot

You can see the rough edges around eyes and around eye brows.

We are trying following code to smooth these edges:

let node = self.childNodes[0]
        let geometry = node.geometry
        
        let verticies = self.change(geometry: geometry!)
        geometry?.edgeCreasesSource = SCNGeometrySource(vertices: verticies)
        geometry?.subdivisionLevel = 0
        
        guard let element = geometry?.elements.first else {
            return
        }
        //print(element.debugDescription)
        
        geometry?.edgeCreasesElement = SCNGeometryElement(data: element.data, primitiveType: .line, primitiveCount: element.primitiveCount, bytesPerIndex: element.bytesPerIndex)
        

We are trying to set subdivisionLevel so that edges can be smoothed out. Is this the right approach? Or we need to do something else to get this fixed programmatically. 3d Designer has very smooth edges when we see it in Maya.

1

There are 1 best solutions below

0
On

Using subdivision level is the right approach to smooth out geometries. In the code snippet however, you're not setting any subdivision level that's higher than 0. If you're working with a small number of objects, it's a good idea to use SceneKit editor and set the subdivision level in the attributes inspector.