How to add a sort of engraving type of text to a mesh in SceneKit?

i'm trying to figure out how to basically engrave some text into this ellipsoid mesh. so far the only thing i've learned that can sort of come close to what im looking for is SCNText but it floats above the ellipsoid and doesnt conform to the angular shape.


        let allocator = MTKMeshBufferAllocator(device: MTLCreateSystemDefaultDevice()!)
        let disc = MDLMesh.newEllipsoid(
            withRadii: vector_float3(Float(discDiameter/2), Float(discDiameter/2), Float(discThickness/2)),
            radialSegments: 64,
            verticalSegments: 64,
            geometryType: .triangles,
            inwardNormals: false,
            hemisphere: false,
            allocator: allocator
        )

        let discGeometry = SCNGeometry(mdlMesh: disc)
        let material = createIridescentMaterial()

        discGeometry.materials = [material]
Answered by Bill3D in 798210022

I tried to reply to the comment but character limit. I think "add normals" just literally adds the data for the normal vectors and puts them all at uniform value. It's just iterating through the vertices. You can sharpen or soften a custom mesh with it if you didn't want to create a SCNGeometrySource for normals. I wouldn't say programmatic normal maps are all that easy of a solution. It's just easier than writing your own boolean geometry routines.

Have you tried to apply the image to the model? I imagine the image will be shrunken at the top and bottom and ballooned out at the equator.

The best way to visualize this may still be to use Blender and create a mockup. See what the resulting maps look like for the look you want. Then that is what you would need to shoot for programmatically. I'm sure there are algorithms for this that can be adapted to Swift without reinventing the wheel.

Boolean mesh functions are a little involved and not part of the frameworks last I checked. Not unless you get into voxels. You might look into applying this as a map instead. Normal maps can give the appearance of depth. It's easier to do this in 3D modeling software such as Blender and import the results. You'll need to understand the relationship of the UV map to the 3D vertices to do this programmatically.

Accepted Answer

I tried to reply to the comment but character limit. I think "add normals" just literally adds the data for the normal vectors and puts them all at uniform value. It's just iterating through the vertices. You can sharpen or soften a custom mesh with it if you didn't want to create a SCNGeometrySource for normals. I wouldn't say programmatic normal maps are all that easy of a solution. It's just easier than writing your own boolean geometry routines.

Have you tried to apply the image to the model? I imagine the image will be shrunken at the top and bottom and ballooned out at the equator.

The best way to visualize this may still be to use Blender and create a mockup. See what the resulting maps look like for the look you want. Then that is what you would need to shoot for programmatically. I'm sure there are algorithms for this that can be adapted to Swift without reinventing the wheel.

How to add a sort of engraving type of text to a mesh in SceneKit?
 
 
Q