Skip to content

Latest commit

 

History

History
50 lines (34 loc) · 1.77 KB

README.md

File metadata and controls

50 lines (34 loc) · 1.77 KB

MiniSDF

Proof of concept RVSDG based compiler for a simple SignedDistanceField language.

Crates

tree-sitter-minisdf: The tree-sitter grammar and parser, if you get strange tree-sitter errors, change into that directory and call ´tree-sitter generate´

minisdf-ast: AST implementation for MiniSDF. Can either be parsed from a file (using tree-sitter), or generated by a program.

minisdf-optimizer: The RVSDG based optimizer / middle-end. Takes an AST and builds a RVSDG representation using basic lowlevel-ish operations.

minisdf-backend-spirv: simple SPIR-V backend based on rspirv.

msdfc: MiniSdf Compiler: Simple library that accepts a miniSDF compiler source file, or AST, and generates, if possible, a SPIR-V Binary.

Example

The following example defines a field that subtracts smoothed-box from a unit box that repeats in the domain 4³.

The offset of the subtracted box is set by an external offset parameter. Which can be animated through the calling shader.

field myfield(offset: vec3){
    sub(){
        repeat(4.0, 4.0, 4.0){
            box(vec3(1.0, 1.0, 1.0))
        }
    }{
        translate(offset){
            smooth(0.25){
                box(vec3(1.0, 1.0, 2.0))
            }
        }
    }
}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.