glsl-combine-chamfer
Combine two signed distance fields with a chamfer-like join.
Last updated 6 years ago by hughsk .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install glsl-combine-chamfer 
SYNC missed versions from official npm registry.

glsl-combine-chamfer

stable

Combine two signed distance fields with a chamfer-like join.

view demo

This technique was derived from a great talk at NVScene by Johann Korndörfer.

Usage

NPM

float combine(float d1, float d2, float radius)

Given two distances d1 and d2, merge them together within the supplied radius.

uniform float iGlobalTime;

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

vec2 doModel(vec3 p) {
  vec3  off    = sin(0, iGlobalTime, 0);
  float dist1  = box(p, vec3(2.0));
  float dist2  = box(p + off, vec3(1.0));
  float radius = 0.5;

  float dist = combine(dist1, dist2, radius);

  return vec2(dist, 1.0);
}

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 (12)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |