Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rreusser/glsl-hypot
The 2D hypot function for GLSL
https://github.com/rreusser/glsl-hypot
Last synced: 7 days ago
JSON representation
The 2D hypot function for GLSL
- Host: GitHub
- URL: https://github.com/rreusser/glsl-hypot
- Owner: rreusser
- Created: 2016-09-20T04:08:25.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-09-20T18:57:27.000Z (over 8 years ago)
- Last Synced: 2024-10-26T12:13:44.223Z (2 months ago)
- Language: GLSL
- Size: 1.95 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# glsl-hypot
> The 2D hypot function for GLSL
[![glsl-hypot](https://nodei.co/npm/glsl-hypot.png?mini=true)](https://nodei.co/npm/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
``` glsl
#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.