glsl-sdf-box
GLSL SDF function for generating a sphere.
Last updated 6 years ago by hughsk .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install glsl-sdf-box 
SYNC missed versions from official npm registry.

glsl-sdf-box

stable

GLSL SDF function for generating a box. Determines the distance between a point and the surface of a box at the origin.

view demo

Originally sourced from Modeling with Distance Functions by Iñigo Quílez.

Usage

NPM

float box(vec3 position, vec3 dimensions)

Returns the signed distanced between position and a box at the origin with a given set of dimensions. For example, to draw a 2x2x2 box in a raytracing shader:

#pragma glslify: box = require('glsl-sdf-box')

vec2 doModel(vec3 p) {
  float dist   = box(p, vec3(2.0));
  float id     = 1.0;

  return vec2(dist, id);
}

Contributing

See stackgl/contributing for details.

License

MIT. See LICENSE.md for details.

Current Tags

  • 1.0.0                                ...           latest (6 years ago)

1 Versions

  • 1.0.0                                ...           6 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (11)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |