1.0.2 • Published 8 years ago

glsl-hypot v1.0.2

Weekly downloads
7
License
MIT
Repository
-
Last release
8 years ago

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.