nodes: implemented more distortion nodes

This commit is contained in:
itsmattkc
2022-09-22 18:12:03 -07:00
parent f84cd8644d
commit b553d5afb7
20 changed files with 1051 additions and 3 deletions
+38
View File
@@ -0,0 +1,38 @@
uniform float evolution_in;
uniform float intensity_in;
uniform float frequency_in;
uniform vec2 position_in;
uniform bool stretch_in;
uniform vec2 resolution_in;
uniform sampler2D tex_in;
in vec2 ove_texcoord;
out vec4 frag_color;
void main(void) {
vec2 center = position_in/resolution_in;
vec2 adj_texcoord = ove_texcoord;
adj_texcoord -= 0.5;
if (!stretch_in) {
// Adjust by aspect ratio
float ar = (resolution_in.x/resolution_in.y);
if (resolution_in.x > resolution_in.y) {
adj_texcoord.y /= ar;
center.y /= ar;
} else {
adj_texcoord.x *= ar;
center.x *= ar;
}
}
adj_texcoord += 0.5;
center += 0.5;
adj_texcoord -= center;
float len = length(adj_texcoord);
vec2 uv = ove_texcoord + (adj_texcoord/len)*cos((frequency_in)*(len*12.0-evolution_in))*(intensity_in*0.0005);
frag_color = texture(tex_in, uv);
}
+29
View File
@@ -0,0 +1,29 @@
// Swirl effect parameters
uniform float radius_in;
uniform float angle_in;
uniform vec2 pos_in;
uniform vec2 resolution_in;
uniform sampler2D tex_in;
in vec2 ove_texcoord;
out vec4 frag_color;
void main(void) {
vec2 center = resolution_in*0.5 + pos_in;
vec2 uv = ove_texcoord;
vec2 tc = uv * resolution_in;
tc -= center;
float dist = length(tc);
if (dist < radius_in) {
float percent = (radius_in - dist) / radius_in;
float theta = percent * percent * -angle_in;
float s = sin(theta);
float c = cos(theta);
tc = vec2(dot(tc, vec2(c, -s)), dot(tc, vec2(s, c)));
}
tc += center;
frag_color = texture(tex_in, tc / resolution_in);
}
+61
View File
@@ -0,0 +1,61 @@
uniform float scale_in;
uniform vec2 position_in;
uniform vec2 resolution_in;
uniform bool mirrorx_in;
uniform bool mirrory_in;
uniform int anchor_in;
uniform sampler2D tex_in;
in vec2 ove_texcoord;
out vec4 frag_color;
#define TOP_LEFT 0
#define TOP_CENTER 1
#define TOP_RIGHT 2
#define MIDDLE_LEFT 3
#define MIDDLE_CENTER 4
#define MIDDLE_RIGHT 5
#define BOTTOM_LEFT 6
#define BOTTOM_CENTER 7
#define BOTTOM_RIGHT 8
void main(void) {
vec2 coord = ove_texcoord;
vec2 offset;
if (anchor_in == TOP_LEFT || anchor_in == TOP_CENTER || anchor_in == TOP_RIGHT) {
offset.y = 0.0;
} else if (anchor_in == MIDDLE_LEFT || anchor_in == MIDDLE_CENTER || anchor_in == MIDDLE_RIGHT) {
offset.y = 0.5;
} else if (anchor_in == BOTTOM_LEFT || anchor_in == BOTTOM_CENTER || anchor_in == BOTTOM_RIGHT) {
offset.y = 1.0;
}
if (anchor_in == TOP_LEFT || anchor_in == MIDDLE_LEFT || anchor_in == BOTTOM_LEFT) {
offset.x = 0.0;
} else if (anchor_in == TOP_CENTER || anchor_in == MIDDLE_CENTER || anchor_in == BOTTOM_CENTER) {
offset.x = 0.5;
} else if (anchor_in == TOP_RIGHT || anchor_in == MIDDLE_RIGHT || anchor_in == BOTTOM_RIGHT) {
offset.x = 1.0;
}
coord -= position_in/resolution_in;
coord -= offset;
coord /= scale_in;
coord += offset;
vec2 modcoord = mod(coord, 1.0);
if (mirrorx_in && mod(coord.x, 2.0) > 1.0) {
modcoord.x = 1.0 - modcoord.x;
}
if (mirrory_in && mod(coord.y, 2.0) > 1.0) {
modcoord.y = 1.0 - modcoord.y;
}
frag_color = vec4(texture(tex_in, modcoord));
}
+25
View File
@@ -0,0 +1,25 @@
uniform float frequency_in;
uniform float intensity_in;
uniform float evolution_in;
uniform bool vertical_in;
uniform sampler2D tex_in;
in vec2 ove_texcoord;
out vec4 frag_color;
void main(void) {
vec2 pos = ove_texcoord;
if (vertical_in) {
pos.x -= sin((ove_texcoord.y-(evolution_in*0.01))*frequency_in)*intensity_in*0.01;
} else {
pos.y -= sin((ove_texcoord.x-(evolution_in*0.01))*frequency_in)*intensity_in*0.01;
}
if (pos.x < 0.0 || pos.x >= 1.0 || pos.y < 0.0 || pos.y >= 1.0) {
discard;
} else {
frag_color = texture(tex_in, pos);
}
}