Reputation: 401
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
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.
Upvotes: 0
Views: 485
Reputation: 147
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.
Upvotes: 1