2016-12-27 00:02:07 +08:00
|
|
|
# glsl-util
|
2016-10-03 23:40:55 +08:00
|
|
|
|
2018-01-11 16:18:52 +08:00
|
|
|
utility functions of glsl.
|
|
|
|
these functions are dependent by [glslify](https://github.com/glslify/glslify).
|
2016-12-27 00:30:56 +08:00
|
|
|
|
2016-10-03 23:40:55 +08:00
|
|
|
## install
|
|
|
|
|
|
|
|
```
|
2016-12-27 00:02:07 +08:00
|
|
|
npm i git://github.com/ykob/glsl-util.git
|
2016-10-03 23:40:55 +08:00
|
|
|
```
|
|
|
|
|
2018-01-11 16:18:52 +08:00
|
|
|
## usage
|
2017-01-26 13:44:10 +08:00
|
|
|
|
2018-01-11 16:18:52 +08:00
|
|
|
### `convertHsvToRgb(vec3 hsv)`
|
2016-12-27 00:02:07 +08:00
|
|
|
|
2018-01-11 16:18:52 +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
|
|
|
|
|
2016-10-03 23:40:55 +08:00
|
|
|
```
|
2016-12-27 00:19:28 +08:00
|
|
|
#pragma glslify: convertHsvToRgb = require(glsl-util/convertHsvToRgb);
|
2018-01-11 16:18:52 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
### `convertRgbToHsv(vec3 rgb)`
|
|
|
|
|
|
|
|
convert RGB to HSV.
|
|
|
|
http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl
|
|
|
|
|
|
|
|
```
|
2016-12-27 00:19:28 +08:00
|
|
|
#pragma glslify: convertRgbToHsv = require(glsl-util/convertRgbToHsv);
|
|
|
|
```
|
|
|
|
|
2018-01-11 16:18:52 +08:00
|
|
|
### `random(vec2 p)`
|
|
|
|
|
|
|
|
calculate white noise.
|
2016-12-27 00:19:28 +08:00
|
|
|
|
|
|
|
```
|
|
|
|
#pragma glslify: random = require(glsl-util/random);
|
2016-10-03 23:40:55 +08:00
|
|
|
```
|
2017-01-26 13:44:10 +08:00
|
|
|
|
2018-01-11 16:18:52 +08:00
|
|
|
### `spherical(float radian1, float radian2, float radius)`
|
2017-01-26 13:44:10 +08:00
|
|
|
|
2018-01-11 16:18:52 +08:00
|
|
|
calculate Spherical coordinate.
|
2017-01-26 13:44:10 +08:00
|
|
|
|
|
|
|
```
|
|
|
|
#pragma glslify: polar = require(glsl-util/polar);
|
|
|
|
```
|
2017-01-30 14:48:18 +08:00
|
|
|
|
2018-01-11 16:18:52 +08:00
|
|
|
### `gaussianBlur(sampler2D texture, vec2 uv, float radius, vec2 resolution, vec2 direction)`
|
|
|
|
|
|
|
|
calculate the Gaussian blur.
|
2017-01-30 14:48:18 +08:00
|
|
|
|
|
|
|
```
|
|
|
|
#pragma glslify: gaussianBlur = require(glsl-util/gaussianBlur);
|
2018-01-11 16:18:52 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
### `lookAt(vec3 base, vec3 p1, vec3 p2, vec3 up)`
|
|
|
|
|
|
|
|
rotate a vector in any direction.
|
|
|
|
|
|
|
|
```
|
2018-01-11 16:30:13 +08:00
|
|
|
#pragma glslify: lookAt = require(glsl-util/lookAt);
|
2018-01-11 16:18:52 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
### `rotateAxisAngle(vec3 p, vec3 axis, float angle)`
|
|
|
|
|
|
|
|
rotate a vector by any axis and angle.
|
|
|
|
|
|
|
|
```
|
2018-01-11 16:30:13 +08:00
|
|
|
#pragma glslify: rotateAxisAngle = require(glsl-util/rotateAxisAngle);
|
2017-01-30 14:48:18 +08:00
|
|
|
```
|