glsl-util/README.md

46 lines
951 B
Markdown
Raw Normal View History

2016-12-27 00:02:07 +08:00
# glsl-util
2016-12-27 00:30:56 +08:00
utility functions for glsl.
## install
```
2016-12-27 00:02:07 +08:00
npm i git://github.com/ykob/glsl-util.git
```
2016-12-27 00:02:07 +08:00
## convertHsvToRgb and convertRgbToHsv
this function converts RGB to HSV. or is its opposite.
2016-12-27 00:02:07 +08:00
http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl
```
2016-12-27 00:19:28 +08:00
#pragma glslify: convertHsvToRgb = require(glsl-util/convertHsvToRgb);
#pragma glslify: convertRgbToHsv = require(glsl-util/convertRgbToHsv);
2017-01-30 14:48:18 +08:00
vec3 rgb = convertHsvToRgb(vec3 hsv);
vec3 hsv = convertRgbToHsv(vec3 rgb);
2016-12-27 00:19:28 +08:00
```
## random
```
#pragma glslify: random = require(glsl-util/random);
2017-01-30 14:48:18 +08:00
float p = random(vec2 c);
```
## polar
this function calculates polar coordinates.
```
#pragma glslify: polar = require(glsl-util/polar);
vec3 p = polar(float radian1, float radian2, float radius);
```
2017-01-30 14:48:18 +08:00
## gaussianBlur
```
#pragma glslify: gaussianBlur = require(glsl-util/gaussianBlur);
vec4 color = gaussianBlur(sampler2D texture, vec2 uv, float radius, vec2 resolution, vec2 direction);
```