Skip to content

rreusser/glsl-hypot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

glsl-hypot

The 2D hypot function for GLSL

glsl-hypot

Introduction

sqrt(x * x + y * y) is easy, but it's subject to overflow and underflow in an environment with already limited precision. This function returns the length of a vec2 while avoiding overflow/underflow. Most of the time though, 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.

About

The 2D hypot function for GLSL

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages