glsl-util/README.md

71 lines
1.4 KiB
Markdown
Raw Permalink Normal View History

2016-12-27 00:02:07 +08:00
# glsl-util
2022-04-21 20:38:42 +08:00
Private GLSL utility functions created by @ykob
These functions are dependent on [glslify](https://github.com/glslify/glslify).
2016-12-27 00:30:56 +08:00
2022-04-21 20:38:42 +08:00
## Install
```
2022-04-20 19:24:45 +08:00
yarn add @ykob/glsl-util
```
2022-04-21 20:38:42 +08:00
## Usage
### `convertHsvToRgb(vec3 hsv)`
2016-12-27 00:02:07 +08:00
2022-04-21 20:38:42 +08:00
Convert HSV to RGB.
2016-12-27 00:02:07 +08:00
http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl
```
2022-04-21 20:38:42 +08:00
#pragma glslify: convertHsvToRgb = require(@ykob/glsl-util/src/convertHsvToRgb);
```
### `convertRgbToHsv(vec3 rgb)`
2022-04-21 20:38:42 +08:00
Convert RGB to HSV.
http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl
```
2022-04-21 20:38:42 +08:00
#pragma glslify: convertRgbToHsv = require(@ykob/glsl-util/src/convertRgbToHsv);
2016-12-27 00:19:28 +08:00
```
### `random(vec2 p)`
2022-04-21 20:38:42 +08:00
Calculate the white noise.
2016-12-27 00:19:28 +08:00
```
2022-04-21 20:38:42 +08:00
#pragma glslify: random = require(@ykob/glsl-util/src/random);
```
2019-07-08 14:33:04 +08:00
### `polar(float radian1, float radian2, float radius)`
2022-04-21 20:38:42 +08:00
Calculate the polar coordinates.
```
2022-04-21 20:38:42 +08:00
#pragma glslify: polar = require(@ykob/glsl-util/src/polar);
```
2017-01-30 14:48:18 +08:00
### `gaussianBlur(sampler2D texture, vec2 uv, float radius, vec2 resolution, vec2 direction)`
2022-04-21 20:38:42 +08:00
Calculate the Gaussian blur.
2017-01-30 14:48:18 +08:00
```
2022-04-21 20:38:42 +08:00
#pragma glslify: gaussianBlur = require(@ykob/glsl-util/src/gaussianBlur);
```
### `lookAt(vec3 base, vec3 p1, vec3 p2, vec3 up)`
2022-04-21 20:38:42 +08:00
Rotate a vector in any direction.
```
2022-04-21 20:38:42 +08:00
#pragma glslify: lookAt = require(@ykob/glsl-util/src/lookAt);
```
### `rotateAxisAngle(vec3 p, vec3 axis, float angle)`
2022-04-21 20:38:42 +08:00
Rotate a vector with axis and angle.
```
2022-04-21 20:38:42 +08:00
#pragma glslify: rotateAxisAngle = require(@ykob/glsl-util/src/rotateAxisAngle);
2017-01-30 14:48:18 +08:00
```