glsl-out-of-range
Functions to test if a point is outside ranges, namely useful for 3D/2D scenes that may have reversed bounds
Last updated 2 years ago by archmoj .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install glsl-out-of-range 
SYNC missed versions from official npm registry.

glsl-out-of-range

Tests if a point is outside ranges. It could be useful in vertex & fragment shaders to support reversed ranges (bounds) in 3D/2D scenes.

Function prototypes:

bool outOfRange(float a, float b, float p);

bool outOfRange(vec2 a, vec2 b, vec2 p);

bool outOfRange(vec3 a, vec3 b, vec3 p);

bool outOfRange(vec4 a, vec4 b, vec4 p);

Please note that in the case of vec4 input arguments, only 3 tests are made i.e. for xyz and not for w.

Example

#pragma glslify: outOfRange = require(glsl-out-of-range)

void main() {
  if (outOfRange(bounds[0], bounds[1], position)) discard;

  gl_FragColor = vec4(1.0, 0.5, 0.25, 1.0);
}

Usage

Install with npm:

npm install glsl-out-of-range

Then use with glslify.

API

#pragma glslify: outOfRange = require(glsl-out-of-range)

Creators

Github Twitter
Alex C. Johnson @alexcjohnson
Étienne Tétreault-Pinard @etpinard @etpinard
Mojtaba Samimi @archmoj

Copyright and license

Code and documentation copyright 2018 Plotly, Inc.

Code released under the MIT license.

Docs released under the Creative Commons license.

Current Tags

  • 1.0.4                                ...           latest (2 years ago)

5 Versions

  • 1.0.4                                ...           2 years ago
  • 1.0.3                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Downloads
Today 0
This Week 88
This Month 1,149
Last Day 88
Last Week 355
Last Month 1,393
Dependencies (0)
None
Dev Dependencies (1)

Copyright 2014 - 2016 © taobao.org |