glsl-hypot

1.0.2 • Public • Published

glsl-hypot

The 2D hypot function for GLSL

glsl-hypot

Introduction

sqrt(x * x + y * y) is easy, but it's subject to overflow. This function returns the length of a vec2 while avoiding overflow/underflow. Most of the time, you're almost certainly fine without this.

Usage

#pragma glslify: hypot require(glsl-hypot) 
 
attribute vec3 position;
 
void main () {
  gl_FragColor = vec4(vec3(hypot(position.xy)), 1.0);
}

License

© 2016 Ricky Reusser. MIT License.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    3
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    3
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i glsl-hypot

Weekly Downloads

3

Version

1.0.2

License

MIT

Last publish

Collaborators

  • rreusser