Socket
Book a DemoInstallSign in
Socket

glsl-combine-smooth

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

glsl-combine-smooth

Smoothly combine two signed distance fields.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

glsl-combine-smooth

stable

Smoothly combine two signed distance fields. A useful alternative to glsl-smooth-min that provides you with an explicit radius of influence and avoids distorting the distance fields.

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, smoothly merge them together within the supplied radius.

uniform float iGlobalTime;

#pragma glslify: combine = require('glsl-combine-smooth')
#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.

Keywords

ecosystem:stackgl

FAQs

Package last updated on 04 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts