moved all modules.
This commit is contained in:
6
src/convertHsvToRgb.glsl
Normal file
6
src/convertHsvToRgb.glsl
Normal file
@@ -0,0 +1,6 @@
|
||||
vec3 convertHsvToRgb(vec3 c) {
|
||||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
}
|
||||
#pragma glslify: export(convertHsvToRgb)
|
10
src/convertRgbToHsv.glsl
Normal file
10
src/convertRgbToHsv.glsl
Normal file
@@ -0,0 +1,10 @@
|
||||
vec3 convertRgbToHsv(vec3 c) {
|
||||
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
||||
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
||||
|
||||
float d = q.x - min(q.w, q.y);
|
||||
float e = 1.0e-10;
|
||||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
}
|
||||
#pragma glslify: export(convertRgbToHsv)
|
15
src/gaussianBlur.glsl
Normal file
15
src/gaussianBlur.glsl
Normal file
@@ -0,0 +1,15 @@
|
||||
vec4 gaussianBlur(sampler2D texture, vec2 uv, float radius, vec2 resolution, vec2 direction) {
|
||||
vec4 color = vec4(0.0);
|
||||
vec2 step = radius / resolution * direction;
|
||||
color += texture2D(texture, uv - 4.0 * step) * 0.02699548325659403;
|
||||
color += texture2D(texture, uv - 3.0 * step) * 0.06475879783294587;
|
||||
color += texture2D(texture, uv - 2.0 * step) * 0.12098536225957168;
|
||||
color += texture2D(texture, uv - 1.0 * step) * 0.17603266338214976;
|
||||
color += texture2D(texture, uv) * 0.19947114020071635;
|
||||
color += texture2D(texture, uv + 1.0 * step) * 0.17603266338214976;
|
||||
color += texture2D(texture, uv + 2.0 * step) * 0.12098536225957168;
|
||||
color += texture2D(texture, uv + 3.0 * step) * 0.06475879783294587;
|
||||
color += texture2D(texture, uv + 4.0 * step) * 0.02699548325659403;
|
||||
return color;
|
||||
}
|
||||
#pragma glslify: export(gaussianBlur)
|
10
src/lookAt.glsl
Normal file
10
src/lookAt.glsl
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma glslify: rotateAxisAngle = require(./rotateAxisAngle);
|
||||
|
||||
vec3 lookAt(vec3 base, vec3 p1, vec3 p2, vec3 up) {
|
||||
vec3 diff = normalize(p2 - p1);
|
||||
float d = dot(diff, up);
|
||||
vec3 c = cross(p1, p2);
|
||||
float a = acos(d);
|
||||
return rotateAxisAngle(base, c, a);
|
||||
}
|
||||
#pragma glslify: export(lookAt)
|
8
src/polar.glsl
Normal file
8
src/polar.glsl
Normal file
@@ -0,0 +1,8 @@
|
||||
vec3 spherical(float radian1, float radian2, float radius) {
|
||||
return vec3(
|
||||
cos(radian1) * cos(radian2) * radius,
|
||||
sin(radian1) * radius,
|
||||
cos(radian1) * sin(radian2) * radius
|
||||
);
|
||||
}
|
||||
#pragma glslify: export(spherical)
|
4
src/random.glsl
Normal file
4
src/random.glsl
Normal file
@@ -0,0 +1,4 @@
|
||||
float random(vec2 c){
|
||||
return fract(sin(dot(c.xy ,vec2(12.9898,78.233))) * 43758.5453);
|
||||
}
|
||||
#pragma glslify: export(random)
|
19
src/rotateAxisAngle.glsl
Normal file
19
src/rotateAxisAngle.glsl
Normal file
@@ -0,0 +1,19 @@
|
||||
vec3 rotateAxisAngle(vec3 p, vec3 axis, float angle){
|
||||
float c = cos(angle);
|
||||
float s = sin(angle);
|
||||
float t = 1.0 - c;
|
||||
vec3 a = normalize(axis);
|
||||
mat3 m = mat3(
|
||||
t * a.x * a.x + c,
|
||||
t * a.x * a.y + a.z * s,
|
||||
t * a.x * a.z - a.y * s,
|
||||
t * a.y * a.x - a.z * s,
|
||||
t * a.y * a.y + c,
|
||||
t * a.y * a.z + a.x * s,
|
||||
t * a.z * a.x + a.y * s,
|
||||
t * a.z * a.y - a.x * s,
|
||||
t * a.z * a.z + c
|
||||
);
|
||||
return m * p;
|
||||
}
|
||||
#pragma glslify: export(rotateAxisAngle)
|
Reference in New Issue
Block a user