Skip to content

Turn scenes in to functions which one day may run on the GPU

License

Notifications You must be signed in to change notification settings

freemin7/SignedDistanceFields.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SignedDistanceFields.jl

SignedDistanceFields.jl provides primitive Signed Distance functions in 3 dimensions and ways to combine them. The resulting scene tree can be turned into a single Julia function which has all relevant information inlined and is in something approximating static single assigment form. This allows for faster execution then walking a tree with each call of the signed distance function of the total scene. In the future running these functions on the GPU or implementing scene graph specific optimization are possible.

A simple raymarching engine with a scene and some simple shaders are provided in the example folder.

Written in Julia

Getting Started

Build a scene tree by combining primitives

scene = SUnion((Trans(Sphere(5*sqrt(2),4),space(0.0,-10.0,0.0)),
    Trans(Sphere(5*sqrt(2),5),space(0.0,5.0,8.66)),
    Trans(Sphere(5*sqrt(2),6),space(0.0,5.0,-8.66)),
    Plane(space(1.0,0.0,0.0),2),
    RepQ(Trans(Sphere(0.5,1),space(2.5,2.5,2.5)),5.0),
    Trans(Sphere(10.5,3),space(0.0,0.0,0.0))))

Turn the scene in to a SingFunc struct which is an array of Julia Expresseion and an initial symbol.

SF = to_code(scene)

Decice whether you want to evaluate it for a certain value exec(SF,value) or if want to build a function func(SF,:Type). Please note due to historic reasons :Type is restricted to the space type provided by the package (which is SVector{3,Float64} )

Prerequisites

] add MacroTools, StaticArrays, LinearAlgebra, Images, ColorVectorSpace, Colors, Dates

Should get you all dependencies for the example.

Running the tests

We have no tests yet.

Deployment

` ?

Built With

  • Julia - tested and developed on 1.0.4
  • stubGPUentry - GPU depedencies would go here, right now it runs on the CPU

Contributing

Please read just open issues or make pull requests.

Versioning

We use SemVer for versioning.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the Zero-Clause BSD License - see the LICENSE.md file for details. If you hate this license open an issue.

Acknowledgments

  • Mason Protter for helping me with a few Julia snippets the night i wrote it
  • The general #helpdesk Slack channel from the Julia Slack
  • Inigo Quilez and his website with a few inspirational articles
  • Nicolau Leal Werneck for liking it which pushed me to spend the hours

About

Turn scenes in to functions which one day may run on the GPU

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages