hiccup-sdftools for modeling signed distance functions with hiccup-like language

hiccup-sdf is set of open source tools made for creating, displaying and exporting 3d models made with SDFs.

It’s another iteration of my exploration of SDFs started with SDF-UI.

This project consists of three libraries:

  • hiccup-sdf - main library providing simple language for building models
  • display-sdf - utility for displaying SDFs
  • hiccup-sdf-to-obj - utility for exporting hiccup-sdf models to OBJs, for 3d printing or other uses

Modeling is done with language inspired by hiccup, adapted to use in javascript:

const { displayRaw } = require("display-sdf");
const { compileShader, glslHelpers } = require("hiccup-sdf");

const translatedSphere = (t, r) => [
  "translate",
  { t },
  [
    ["sphere", { r }]
  ]
];

const shape = [
  "repeatPolar",
  { r: 10 },
  [
    [
      "translate",
      { t: [0.5, 0, 0] },
      [
        [
          "intersection",
          {},
          [
            ["box", { s: [0.1, 0.1, 0.1] }],
            translatedSphere([0.15, 0, 0], 0.2)
          ]
        ]
      ]
    ]
  ]
];

const { inject, model } = compileShader(shape);
const shader = glslHelpers.createShaderFull(model, inject);

displayRaw(shader);

SDFs can be meshed using surface nets and hiccup-sdf-to-obj provides set of tools to help with that, and export 3d-printer ready models:

For more information and examples go to github: szymonkaliski/hiccup-sdf.

This project was developed in part at Laboratory, an artist residency for interactive arts: laboratoryspokane.com.

Szymon Kaliski © 2018