After creating SDFs via three.js material and shader, (SDFs in the scene - raymarching )
I am now working on the triangulation of the SDFs to efficiently transfer SDFs into BufferGeometry.
Creating really sharp edges is a problem that has not yet been solved.
All attempts to change the extremely complicated triangulation algorithm have so far been unsuccessful.
Some examples can be seen in the question post .
(Is there a library for Javascript distance functions?)
The functions have changed somewhat since then.
More examples:
const sdf1 = sdSphere( );
const sdf2 = sdSphere( 0.6, { x: 2.0, y: 0.0, z: -0.5 } );
const sdf3 = sdTorus( );
SDF = opSmoothUnion( sdf1, sdf2, 0.6 );
SDF = opSmoothUnion( SDF, sdf3, 0.3 );
const sdf1 = sdSphere( 1.6, { x: 2.0, y: 0.0, z: -0.5 } );
const sdf2 = sdRoundBox( { x: 2.5, y: 0.4, z: 0.9 }, 0.0, { x: 0.0, y: -0.4, z: 0.0 } );
const sdf3 = sdTorus( 0.8, 0.3, { x: -0.8, y: -0.1, z: 0.0 } );
SDF = opSmoothSubtraction( sdf1, sdf2, 0.2 );
SDF = opSmoothSubtraction( SDF, sdf3, 0.2 );
const sdf1 = sdCapsule( 0.4 );
const sdf2 = sdRoundBox( { x: 2.5, y: 0.2, z: 1.2 } ) ;
SDF = opSmoothSubtraction( sdf1, sdf2, 0.2 );
const sdf1 = sdRoundBox( { x: 2, y: 0.2, z: 1 }, 0.05 );
const sdf2 = sdRoundBox( { x: 0.2, y: 2, z: 1 }, 0.05 );
const sdf3 = sdCapsule( 0.25, { x: 1, y: -1, z: 0 }, { x: 1, y: 1, z: 0 } );
const sdf4 = sdCapsule( 0.25, { x: -1, y: -1, z: 0 }, { x: -1, y: 1, z: 0 } );
const sdfA = opSmoothUnion( sdf1, sdf2, 0.05);
const sdfB = opUnion( sdf3, sdf4 );
SDF = opSmoothSubtraction( sdfB, sdfA, 0.05 );
UPDFATE
All attempts to create the sharp edges by running something in addition to the core algorithm must fail. I am now sure that I have to change the core of E. Hartmann’s algorithm to achieve the goal.
But before that, I will create a resource to generate SDFs meshes online. There is a lot of detailed work to be done.