~connorbell/conemarching-ar

iOS app to render signed distance fields
Upated readme
Added icons, fixed some ui bugs
Commented out scenekit shadows render

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~connorbell/conemarching-ar
read/write
git@git.sr.ht:~connorbell/conemarching-ar

You can also use your local clone with git send-email.

#Lidar+Conemarcher

Prototype engine to render signed distance fields in Augmented Reality defined by Metal Function Pointers via a multi-pass "conemarching" algorithm.

image

#Building / Device Support

No dependencies, just build and run!

The device compatibility with Metal Function Pointers is unclear. It runs on my iPad Pro (3rd gen) but not on iPhone 12, so I suspect it's limited to M1 devices.

#Engine Architecture

ARSession provides color, smoothed depth, and the view+projection matrices to the conemarcher.

The conemarcher renders the distance field progressively over a number of passes, doubling the resolution each pass. Rays are advanced as far as the cone guarantees there won't be an intersection, filling in the details at higher resolutions.

The final pass removes the cone constraint and performs regular raymarching. The depth texture from ARSession is tested against the depth of the projected ray in order to rule out unnecessary computation. Rays are advanced by overestimating the minimum distance to a surface by a factor of 2 while validating that the bounding distance spheres between steps overlap (Ray-relaxing 😎).

#Distance Fields

image

Distance fields are defined as visible functions in DistanceFields.metal.

Each field requires an entry in DistanceFields.plist, referencing the function name, variables, and display name.

Four float4 uniforms can be defined for each entry, with their own name and range to be displayed in the UI.

#Post Fx

Similar to distance fields, the post fx functions are defined in PostFx.metal and referenced by an entry in PostFx.plist.

#Future

Raymarched shadows via planes detected from ARKit with Metal.

#Acknowledgements

MetalViewRecorder: Warren Moore

Ray-relaxing: Keinert et al. https://erleuchtet.org/~cupe/permanent/enhanced_sphere_tracing.pdf

Torus, Cube SDF primitives by Inigo Quilez https://iquilezles.org/www/articles/distfunctions/distfunctions.htm

Conemarching technique developed by fulcrum demo team http://www.fulcrum-demo.org/wp-content/uploads/2012/04/Cone_Marching_Mandelbox_by_Seven_Fulcrum_LongVersion.pdf

#License

Attribution-NonCommercial 3.0 Unported (CC BY-NC 3.0)