Mappable 3

This commit is contained in:
Tanasart 2023-12-23 18:59:21 +07:00
parent b2123a3202
commit 5a65889e13
16 changed files with 352 additions and 124 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

View file

@ -1,36 +1,38 @@
function Node_Checker(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Checker";
shader = sh_checkerboard;
uniform_dim = shader_get_uniform(shader, "dimension");
uniform_pos = shader_get_uniform(shader, "position");
uniform_angle = shader_get_uniform(shader, "angle");
uniform_amount = shader_get_uniform(shader, "amount");
uniform_col1 = shader_get_uniform(shader, "col1");
uniform_col2 = shader_get_uniform(shader, "col2");
inputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF )
.setDisplay(VALUE_DISPLAY.vector);
inputs[| 1] = nodeValue("Amount", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 2)
.setDisplay(VALUE_DISPLAY.slider, { range: [1, 16, 0.1] });
.setDisplay(VALUE_DISPLAY.slider, { range: [1, 16, 0.1] })
.setMappable(6);
inputs[| 2] = nodeValue("Angle", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.rotation);
.setDisplay(VALUE_DISPLAY.rotation)
.setMappable(7);
inputs[| 3] = nodeValue("Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [0, 0] )
.setDisplay(VALUE_DISPLAY.vector)
.setUnitRef(function(index) { return getDimension(index); });
inputs[| 4] = nodeValue("Color 1", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white);
inputs[| 5] = nodeValue("Color 2", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_black);
//////////////////////////////////////////////////////////////////////////////////
inputs[| 6] = nodeValueMap("Amount map", self);
inputs[| 7] = nodeValueMap("Angle map", self);
//////////////////////////////////////////////////////////////////////////////////
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
input_display_list = [
["Output", true], 0,
["Pattern", false], 1, 2, 3,
["Pattern", false], 1, 6, 2, 7, 3,
["Render", false], 4, 5,
];
@ -45,28 +47,27 @@ function Node_Checker(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
inputs[| 2].drawOverlay(active, px, py, _s, _mx, _my, _snx, _sny);
}
static step = function() { #region
inputs[| 1].mappableStep();
inputs[| 2].mappableStep();
} #endregion
static processData = function(_outSurf, _data, _output_index, _array_index) {
var _dim = _data[0];
var _amo = _data[1];
var _ang = _data[2];
var _pos = _data[3];
var _col1 = _data[4];
var _col2 = _data[5];
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
surface_set_target(_outSurf);
shader_set(shader);
shader_set_uniform_f(uniform_dim, surface_get_width_safe(_outSurf), surface_get_height_safe(_outSurf));
shader_set_uniform_f(uniform_pos, _pos[0] / _dim[0], _pos[1] / _dim[1]);
shader_set_uniform_f(uniform_angle, degtorad(_ang));
shader_set_uniform_f(uniform_amount, _amo);
shader_set_uniform_f_array_safe(uniform_col1, colToVec4(_col1));
shader_set_uniform_f_array_safe(uniform_col2, colToVec4(_col2));
draw_sprite_ext(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1], 0, c_white, 1);
shader_reset();
surface_reset_target();
surface_set_shader(_outSurf, sh_checkerboard);
shader_set_f("dimension", surface_get_width_safe(_outSurf), surface_get_height_safe(_outSurf));
shader_set_f("position", _pos[0] / _dim[0], _pos[1] / _dim[1]);
shader_set_f_map("amount", _data[1], _data[6], inputs[| 1]);
shader_set_f_map("angle", _data[2], _data[7], inputs[| 2]);
shader_set_color("col1", _data[4]);
shader_set_color("col2", _data[5]);
draw_sprite_ext(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1], 0, c_white, 1);
surface_reset_shader();
return _outSurf;
}

View file

@ -48,6 +48,14 @@ function Node_Gabor_Noise(_x, _y, _group = noone) : Node_Shader_Generator(_x, _y
input_display_list = [
["Output", true], 0, 3,
["Noise", false], 1, 2, 4, 7, 5,
["Noise", false], 1, 2, 8, 4, 9, 7, 11, 5, 10,
];
static step = function() {
inputs[| 2].mappableStep();
inputs[| 4].mappableStep();
inputs[| 5].mappableStep();
inputs[| 7].mappableStep();
}
}

View file

@ -8,21 +8,41 @@ function Node_Shard_Noise(_x, _y, _group = noone) : Node_Shader_Generator(_x, _y
addShaderProp(SHADER_UNIFORM.float, "position");
inputs[| 2] = nodeValue("Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 4, 4 ])
.setDisplay(VALUE_DISPLAY.vector);
.setDisplay(VALUE_DISPLAY.vector)
.setMappable(6);
addShaderProp(SHADER_UNIFORM.float, "scale");
inputs[| 3] = nodeValue("Seed", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, irandom(99999));
addShaderProp(SHADER_UNIFORM.float, "seed");
inputs[| 4] = nodeValue("Sharpness", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 2, 0.01 ] });
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 2, 0.01 ] })
.setMappable(7);
addShaderProp(SHADER_UNIFORM.float, "sharpness");
inputs[| 5] = nodeValue("Progress", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
addShaderProp(SHADER_UNIFORM.float, "progress");
.setMappable(8);
addShaderProp(SHADER_UNIFORM.float, "progress")
//////////////////////////////////////////////////////////////////////////////////
inputs[| 6] = nodeValueMap("Scale map", self); addShaderProp();
inputs[| 7] = nodeValueMap("Sharpness map", self); addShaderProp();
inputs[| 8] = nodeValueMap("Progress map", self); addShaderProp();
//////////////////////////////////////////////////////////////////////////////////
input_display_list = [
["Output", true], 0, 3,
["Noise", false], 1, 2, 5, 4,
["Noise", false], 1, 2, 6, 5, 8, 4, 7,
];
static step = function() {
inputs[| 2].mappableStep();
inputs[| 4].mappableStep();
inputs[| 5].mappableStep();
}
}

View file

@ -8,21 +8,41 @@ function Node_Wavelet_Noise(_x, _y, _group = noone) : Node_Shader_Generator(_x,
addShaderProp(SHADER_UNIFORM.float, "position");
inputs[| 2] = nodeValue("Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 4, 4 ])
.setDisplay(VALUE_DISPLAY.vector);
.setDisplay(VALUE_DISPLAY.vector)
.setMappable(6);
addShaderProp(SHADER_UNIFORM.float, "scale");
inputs[| 3] = nodeValue("Seed", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, irandom(99999));
addShaderProp(SHADER_UNIFORM.float, "seed");
inputs[| 4] = nodeValue("Progress", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setMappable(7)
addShaderProp(SHADER_UNIFORM.float, "progress");
inputs[| 5] = nodeValue("Detail", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1.24)
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 2, 0.01 ] });
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 2, 0.01 ] })
.setMappable(8);
addShaderProp(SHADER_UNIFORM.float, "detail");
//////////////////////////////////////////////////////////////////////////////////
inputs[| 6] = nodeValueMap("Scale map", self); addShaderProp();
inputs[| 7] = nodeValueMap("Progress map", self); addShaderProp();
inputs[| 8] = nodeValueMap("Detail map", self); addShaderProp();
//////////////////////////////////////////////////////////////////////////////////
input_display_list = [
["Output", true], 0, 3,
["Noise", false], 1, 2, 4, 5,
["Noise", false], 1, 2, 6, 4, 7, 5, 8,
];
static step = function() {
inputs[| 2].mappableStep();
inputs[| 4].mappableStep();
inputs[| 5].mappableStep();
}
}

View file

@ -8,7 +8,8 @@ function Node_Perlin_Extra(_x, _y, _group = noone) : Node_Shader_Generator(_x, _
addShaderProp(SHADER_UNIFORM.float, "position");
inputs[| 2] = nodeValue("Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 4, 4 ])
.setDisplay(VALUE_DISPLAY.vector);
.setDisplay(VALUE_DISPLAY.vector)
.setMappable(13);
addShaderProp(SHADER_UNIFORM.float, "scale");
inputs[| 3] = nodeValue("Iteration", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 2);
@ -41,15 +42,27 @@ function Node_Perlin_Extra(_x, _y, _group = noone) : Node_Shader_Generator(_x, _
addShaderProp(SHADER_UNIFORM.integer, "type");
inputs[| 11] = nodeValue("Parameter A", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setDisplay(VALUE_DISPLAY.slider);
.setDisplay(VALUE_DISPLAY.slider)
.setMappable(14);
addShaderProp(SHADER_UNIFORM.float, "paramA");
inputs[| 12] = nodeValue("Parameter B", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1);
inputs[| 12] = nodeValue("Parameter B", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
.setMappable(15);
addShaderProp(SHADER_UNIFORM.float, "paramB");
//////////////////////////////////////////////////////////////////////////////////
inputs[| 13] = nodeValueMap("Scale map", self); addShaderProp();
inputs[| 14] = nodeValueMap("Parameter A map", self); addShaderProp();
inputs[| 15] = nodeValueMap("Parameter B map", self); addShaderProp();
//////////////////////////////////////////////////////////////////////////////////
input_display_list = [
["Output", true], 0, 5,
["Noise", false], 10, 1, 2, 3, 4, 11, 12,
["Noise", false], 10, 1, 2, 13, 3, 4, 11, 14, 12, 15,
["Render", false], 6, 7, 8, 9,
];
@ -67,5 +80,9 @@ function Node_Perlin_Extra(_x, _y, _group = noone) : Node_Shader_Generator(_x, _
inputs[| 11].setVisible(_typ > 0);
inputs[| 12].setVisible(false);
inputs[| 2].mappableStep();
inputs[| 11].mappableStep();
inputs[| 12].mappableStep();
} #endregion
}

View file

@ -1,34 +1,34 @@
function Node_Zigzag(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Zigzag";
shader = sh_zigzag;
uniform_pos = shader_get_uniform(shader, "position");
uniform_amo = shader_get_uniform(shader, "amount");
uniform_bnd = shader_get_uniform(shader, "blend");
uniform_col1 = shader_get_uniform(shader, "col1");
uniform_col2 = shader_get_uniform(shader, "col2");
inputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF )
.setDisplay(VALUE_DISPLAY.vector);
inputs[| 1] = nodeValue("Amount", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1)
.setDisplay(VALUE_DISPLAY.slider, { range: [1, 16, 0.1] });
.setDisplay(VALUE_DISPLAY.slider, { range: [1, 16, 0.1] })
.setMappable(6);
inputs[| 2] = nodeValue("Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [0, 0] )
.setDisplay(VALUE_DISPLAY.vector)
.setUnitRef(function(index) { return getDimension(index); });
inputs[| 3] = nodeValue("Color 1", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white);
inputs[| 4] = nodeValue("Color 2", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_black);
inputs[| 5] = nodeValue("Smooth", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
//////////////////////////////////////////////////////////////////////////////////
inputs[| 6] = nodeValueMap("Amount map", self);
//////////////////////////////////////////////////////////////////////////////////
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
input_display_list = [
["Output", false], 0,
["Pattern", false], 1, 2,
["Pattern", false], 1, 6, 2,
["Render", false], 3, 4, 5,
];
@ -38,9 +38,12 @@ function Node_Zigzag(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
inputs[| 2].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);
}
static step = function() { #region
inputs[| 1].mappableStep();
} #endregion
static processData = function(_outSurf, _data, _output_index, _array_index) {
var _dim = _data[0];
var _amo = _data[1];
var _pos = _data[2];
var _col1 = _data[3];
@ -48,18 +51,16 @@ function Node_Zigzag(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
var _bnd = _data[5];
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
surface_set_shader(_outSurf, sh_zigzag);
shader_set_f("position", _pos[0] / _dim[0], _pos[1] / _dim[1]);
shader_set_f_map("amount", _data[1], _data[6], inputs[| 1]);
shader_set_i("blend", _bnd);
shader_set_color("col1", _col1);
shader_set_color("col2", _col2);
surface_set_target(_outSurf);
DRAW_CLEAR
shader_set(shader);
shader_set_uniform_f(uniform_pos, _pos[0] / _dim[0], _pos[1] / _dim[1]);
shader_set_uniform_f(uniform_amo, _amo);
shader_set_uniform_f_array_safe(uniform_col1, colToVec4(_col1));
shader_set_uniform_f_array_safe(uniform_col2, colToVec4(_col2));
shader_set_uniform_i(uniform_bnd, _bnd);
draw_sprite_ext(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1], 0, c_white, 1);
shader_reset();
surface_reset_target();
draw_sprite_ext(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1], 0, c_white, 1);
surface_reset_shader();
return _outSurf;
}

View file

@ -6,17 +6,39 @@ varying vec4 v_vColour;
uniform vec2 dimension;
uniform vec2 position;
uniform float angle;
uniform float amount;
uniform vec4 col1, col2;
uniform vec2 amount;
uniform int amountUseSurf;
uniform sampler2D amountSurf;
uniform vec2 angle;
uniform int angleUseSurf;
uniform sampler2D angleSurf;
uniform vec4 col1;
uniform vec4 col2;
void main() {
#region params
float amo = amount.x;
if(amountUseSurf == 1) {
vec4 _vMap = texture2D( amountSurf, v_vTexcoord );
amo = mix(amount.x, amount.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
}
float ang = angle.x;
if(angleUseSurf == 1) {
vec4 _vMap = texture2D( angleSurf, v_vTexcoord );
ang = mix(angle.x, angle.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
}
ang = radians(ang);
#endregion
vec2 dimension_norm = dimension / dimension.y;
vec2 c = (v_vTexcoord - position) * dimension_norm;
float _x = c.x * cos(angle) - c.y * sin(angle);
float _y = c.x * sin(angle) + c.y * cos(angle);
float _a = 1. / amount;
vec2 c = (v_vTexcoord - position) * dimension_norm;
float _x = c.x * cos(ang) - c.y * sin(ang);
float _y = c.x * sin(ang) + c.y * cos(ang);
float _a = 1. / amo;
if(mod(floor(_x / _a) + floor(_y / _a), 2.) > 0.5)
gl_FragColor = vec4(col1.rgb, 1.);

View file

@ -7,17 +7,28 @@ varying vec4 v_vColour;
uniform float seed;
uniform float alignment;
uniform vec2 alignment;
uniform int alignmentUseSurf;
uniform sampler2D alignmentSurf;
float align;
uniform float sharpness;
uniform vec2 sharpness;
uniform int sharpnessUseSurf;
uniform sampler2D sharpnessSurf;
float sharp;
uniform float rotation;
uniform vec2 rotation;
uniform int rotationUseSurf;
uniform sampler2D rotationSurf;
float rot;
uniform vec2 scale;
uniform int scaleUseSurf;
uniform sampler2D scaleSurf;
uniform vec2 u_resolution;
uniform vec2 position;
uniform vec2 scale;
uniform vec2 augment;
vec2 hash(vec2 p) { return fract(sin(vec2(
@ -25,13 +36,13 @@ vec2 hash(vec2 p) { return fract(sin(vec2(
dot(p, vec2(269.8355, 183.3961)) * (437.5453123 + seed / 10000.)
)) * 43758.5453); }
vec3 gabor_wave(in vec2 p) {
vec3 gabor_wave(in vec2 p) { #region
vec2 ip = floor(p);
vec2 fp = fract(p);
float fa = sharpness;
float fr = alignment * 6.283185;
float rt = radians(rotation);
float fa = sharp;
float fr = align * 6.283185;
float rt = rot;
vec3 av = vec3(0.0, 0.0, 0.0);
vec3 at = vec3(0.0, 0.0, 0.0);
@ -54,12 +65,39 @@ vec3 gabor_wave(in vec2 p) {
}
return vec3( av.x, av.yz - av.x * at.yz / at.x ) / at.x;
}
} #endregion
void main() {
#region params
vec2 sca = scale;
if(scaleUseSurf == 1) {
vec4 _vMap = texture2D( scaleSurf, v_vTexcoord );
sca = vec2(mix(scale.x, scale.y, (_vMap.r + _vMap.g + _vMap.b) / 3.));
}
rot = rotation.x;
if(rotationUseSurf == 1) {
vec4 _vMap = texture2D( rotationSurf, v_vTexcoord );
rot = mix(rotation.x, rotation.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
}
rot = radians(rot);
align = alignment.x;
if(alignmentUseSurf == 1) {
vec4 _vMap = texture2D( alignmentSurf, v_vTexcoord );
align = mix(alignment.x, alignment.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
}
sharp = sharpness.x;
if(sharpnessUseSurf == 1) {
vec4 _vMap = texture2D( sharpnessSurf, v_vTexcoord );
sharp = mix(sharpness.x, sharpness.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
}
#endregion
vec2 pos = v_vTexcoord;
pos.x *= (u_resolution.x / u_resolution.y);
pos = (pos + position) * scale;
pos = (pos + position) * sca;
vec3 f = gabor_wave(pos);
vec3 col = vec3(0.5 + 0.5 * f.x);

View file

@ -5,11 +5,24 @@ varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform float seed;
uniform float progress;
uniform float sharpness;
uniform vec2 progress;
uniform int progressUseSurf;
uniform sampler2D progressSurf;
float prog;
uniform vec2 sharpness;
uniform int sharpnessUseSurf;
uniform sampler2D sharpnessSurf;
float sharp;
uniform vec2 scale;
uniform int scaleUseSurf;
uniform sampler2D scaleSurf;
uniform vec2 u_resolution;
uniform vec2 position;
uniform vec2 scale;
#define tau 6.283185307179586
@ -19,7 +32,7 @@ vec3 hash(vec3 p) { return fract(sin(vec3(
dot(p, vec3(615.2689, 264.1657, 278.1687)) * (962.6718165 + seed / 10000.)
)) * 43758.5453); }
float shard_noise(in vec3 p, in float sharpness) {
float shard_noise(in vec3 p, in float _sharp) {
vec3 ip = floor(p);
vec3 fp = fract(p);
@ -28,15 +41,14 @@ float shard_noise(in vec3 p, in float sharpness) {
for (int z = -1; z <= 1; z++)
for (int y = -1; y <= 1; y++)
for (int x = -1; x <= 1; x++) {
vec3 o = vec3(x, y, z);
vec3 o = vec3(x, y, z);
vec3 io = ip + o;
vec3 h = hash(io);
vec3 r = fp - (o + h);
vec3 h = hash(io);
vec3 r = fp - (o + h);
float w = exp2(-tau*dot(r, r));
// tanh deconstruction and optimization by @Xor
float s = sharpness * dot(r, hash(io + vec3(11, 31, 47)) - 0.5);
float s = _sharp * dot(r, hash(io + vec3(11, 31, 47)) - 0.5);
v += w * s * inversesqrt(1.0 + s * s);
t += w;
}
@ -45,12 +57,32 @@ float shard_noise(in vec3 p, in float sharpness) {
}
void main() {
#region params
vec2 sca = scale;
if(scaleUseSurf == 1) {
vec4 _vMap = texture2D( scaleSurf, v_vTexcoord );
sca = vec2(mix(scale.x, scale.y, (_vMap.r + _vMap.g + _vMap.b) / 3.));
}
prog = progress.x;
if(progressUseSurf == 1) {
vec4 _vMap = texture2D( progressSurf, v_vTexcoord );
prog = mix(progress.x, progress.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
}
sharp = sharpness.x;
if(sharpnessUseSurf == 1) {
vec4 _vMap = texture2D( sharpnessSurf, v_vTexcoord );
sharp = mix(sharpness.x, sharpness.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
}
#endregion
vec2 pos = v_vTexcoord;
pos.x *= (u_resolution.x / u_resolution.y);
pos = (pos + position) * scale / 16.;
pos = (pos + position) * sca / 16.;
float prog = progress / 100.;
prog /= 100.;
vec3 uv = vec3( pos + prog, prog * .5 );
gl_FragColor = vec4( vec3(shard_noise(16.0 * uv, pow(sharpness, 2.) * 20.)), 1. );
gl_FragColor = vec4( vec3(shard_noise(16.0 * uv, pow(sharp, 2.) * 20.)), 1. );
}

View file

@ -11,11 +11,20 @@ varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform float seed;
uniform float progress;
uniform float detail;
uniform vec2 u_resolution;
uniform vec2 position;
uniform vec2 scale;
uniform vec2 progress;
uniform int progressUseSurf;
uniform sampler2D progressSurf;
uniform vec2 detail;
uniform int detailUseSurf;
uniform sampler2D detailSurf;
uniform vec2 scale;
uniform int scaleUseSurf;
uniform sampler2D scaleSurf;
float WaveletNoise(vec2 p, float z, float k) {
float d = 0., s = 1., m = 0., a;
@ -36,12 +45,32 @@ float WaveletNoise(vec2 p, float z, float k) {
}
void main() {
#region params
vec2 sca = scale;
if(scaleUseSurf == 1) {
vec4 _vMap = texture2D( scaleSurf, v_vTexcoord );
sca = vec2(mix(scale.x, scale.y, (_vMap.r + _vMap.g + _vMap.b) / 3.));
}
float prog = progress.x;
if(progressUseSurf == 1) {
vec4 _vMap = texture2D( progressSurf, v_vTexcoord );
prog = mix(progress.x, progress.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
}
float detl = detail.x;
if(detailUseSurf == 1) {
vec4 _vMap = texture2D( detailSurf, v_vTexcoord );
detl = mix(detail.x, detail.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
}
#endregion
vec2 pos = v_vTexcoord - .5;
pos.x *= (u_resolution.x / u_resolution.y);
pos = (pos + position) * scale / 16.;
pos = (pos + position) * sca / 16.;
vec3 col = vec3(0.);
col += WaveletNoise(pos * 5., (2.9864 + progress), detail) * .5 + .5;
col += WaveletNoise(pos * 5., (2.9864 + prog), detl) * .5 + .5;
gl_FragColor = vec4(col, 1.0);
}

View file

@ -7,13 +7,24 @@ uniform int type;
uniform vec2 position;
uniform vec2 u_resolution;
uniform vec2 scale;
uniform int iteration;
uniform float seed;
uniform int tile;
uniform float paramA;
uniform float paramB;
uniform vec2 scale;
uniform int scaleUseSurf;
uniform sampler2D scaleSurf;
vec2 sca;
uniform vec2 paramA;
uniform int paramAUseSurf;
uniform sampler2D paramASurf;
float A;
uniform vec2 paramB;
uniform int paramBUseSurf;
uniform sampler2D paramBSurf;
float B;
uniform int colored;
uniform vec2 colorRanR;
@ -59,8 +70,8 @@ float noise (in vec2 st, in vec2 scale) { #region
vec2 f = fract(st);
vec2 u = f * f * (3.0 - 2.0 * f);
if(type == 4) {
u.x = smooth(f.x, 2. + paramA * 4.);
u.y = smooth(f.y, 2. + paramA * 4.);
u.x = smooth(f.x, 2. + A * 4.);
u.y = smooth(f.y, 2. + A * 4.);
}
float a = 0., b = 0., c = 0., d = 0.;
@ -93,7 +104,7 @@ float _perlin(in vec2 st) { #region
float n = 0., m = 0.;
vec2 pos = st;
vec2 sc = scale;
vec2 sc = sca;
float it = float(iteration);
if(type == 3) it *= 3.;
@ -104,7 +115,7 @@ float _perlin(in vec2 st) { #region
if(type == 3) {
m += _n * amp;
if(mod(i, 3.) == 2.) {
n += smoothstep(0.5 - paramA, 0.5 + paramA, m) * amp;
n += smoothstep(0.5 - A, 0.5 + A, m) * amp;
m = 0.;
sc /= 1.5;
@ -116,11 +127,11 @@ float _perlin(in vec2 st) { #region
pos *= 1.5;
}
} else if(type == 4) {
n += smooth(_n, 1. + paramA * 5. * i / it) * amp;
n += smooth(_n, 1. + A * 5. * i / it) * amp;
} else if(type == 5) {
n = max(n, _n);
sc *= 1. + paramA * 0.1;
pos *= 1. + paramA * 0.1;
sc *= 1. + A * 0.1;
pos *= 1. + A * 0.1;
} else
n += _n * amp;
@ -129,12 +140,12 @@ float _perlin(in vec2 st) { #region
if(type == 1) {
sc *= 2.;
amp *= .5;
pos *= 1. + _n + paramA;
pos *= 1. + _n + A;
} else if(type == 2) {
sc *= 2.;
amp *= .5;
pos += random2(vec2(n), seed) / sc;
pos *= (2. + paramA);
pos *= (2. + A);
} else if(type == 3) {
} else if(type == 5) {
} else {
@ -150,10 +161,10 @@ float _perlin(in vec2 st) { #region
float perlin(in vec2 st) { #region
if(type == 6) {
float p1 = _perlin(st - vec2(1., 0.) / scale * (1. + paramA));
float p2 = _perlin(st - vec2(0., 1.) / scale * (1. + paramA));
float p3 = _perlin(st - vec2(-1., 0.) / scale * (1. + paramA));
float p4 = _perlin(st - vec2(0., -1.) / scale * (1. + paramA));
float p1 = _perlin(st - vec2( 1., 0.) / sca * (1. + A));
float p2 = _perlin(st - vec2( 0., 1.) / sca * (1. + A));
float p3 = _perlin(st - vec2(-1., 0.) / sca * (1. + A));
float p4 = _perlin(st - vec2( 0., -1.) / sca * (1. + A));
return abs(p1 - p3) + abs(p2 - p4);
}
@ -161,19 +172,39 @@ float perlin(in vec2 st) { #region
} #endregion
void main() { #region
#region params
sca = scale;
if(scaleUseSurf == 1) {
vec4 _vMap = texture2D( scaleSurf, v_vTexcoord );
sca = vec2(mix(scale.x, scale.y, (_vMap.r + _vMap.g + _vMap.b) / 3.));
}
A = paramA.x;
if(paramAUseSurf == 1) {
vec4 _vMap = texture2D( paramASurf, v_vTexcoord );
A = mix(paramA.x, paramA.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
}
B = paramB.x;
if(paramBUseSurf == 1) {
vec4 _vMap = texture2D( paramBSurf, v_vTexcoord );
B = mix(paramB.x, paramB.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
}
#endregion
if(colored == 0) {
vec2 pos = (v_vTexcoord + position) * scale;
vec2 pos = (v_vTexcoord + position) * sca;
gl_FragColor = vec4(vec3(perlin(pos)), 1.0);
} else if(colored == 1) {
float randR = colorRanR[0] + perlin((v_vTexcoord + position) * scale) * (colorRanR[1] - colorRanR[0]);
float randG = colorRanG[0] + perlin((v_vTexcoord + position + vec2(1.7227, 4.55529)) * scale) * (colorRanG[1] - colorRanG[0]);
float randB = colorRanB[0] + perlin((v_vTexcoord + position + vec2(6.9950, 6.82063)) * scale) * (colorRanB[1] - colorRanB[0]);
float randR = colorRanR[0] + perlin((v_vTexcoord + position ) * sca) * (colorRanR[1] - colorRanR[0]);
float randG = colorRanG[0] + perlin((v_vTexcoord + position + vec2(1.7227, 4.55529)) * sca) * (colorRanG[1] - colorRanG[0]);
float randB = colorRanB[0] + perlin((v_vTexcoord + position + vec2(6.9950, 6.82063)) * sca) * (colorRanB[1] - colorRanB[0]);
gl_FragColor = vec4(randR, randG, randB, 1.0);
} else if(colored == 2) {
float randH = colorRanR[0] + perlin((v_vTexcoord + position) * scale) * (colorRanR[1] - colorRanR[0]);
float randS = colorRanG[0] + perlin((v_vTexcoord + position + vec2(1.7227, 4.55529)) * scale) * (colorRanG[1] - colorRanG[0]);
float randV = colorRanB[0] + perlin((v_vTexcoord + position + vec2(6.9950, 6.82063)) * scale) * (colorRanB[1] - colorRanB[0]);
float randH = colorRanR[0] + perlin((v_vTexcoord + position ) * sca) * (colorRanR[1] - colorRanR[0]);
float randS = colorRanG[0] + perlin((v_vTexcoord + position + vec2(1.7227, 4.55529)) * sca) * (colorRanG[1] - colorRanG[0]);
float randV = colorRanB[0] + perlin((v_vTexcoord + position + vec2(6.9950, 6.82063)) * sca) * (colorRanB[1] - colorRanB[0]);
gl_FragColor = vec4(hsv2rgb(vec3(randH, randS, randV)), 1.0);
}

View file

@ -5,20 +5,29 @@ varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec2 position;
uniform float amount;
uniform int blend;
uniform vec2 amount;
uniform int amountUseSurf;
uniform sampler2D amountSurf;
uniform vec4 col1, col2;
void main() {
float amo = amount.x;
if(amountUseSurf == 1) {
vec4 _vMap = texture2D( amountSurf, v_vTexcoord );
amo = mix(amount.x, amount.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
}
vec2 pos = v_vTexcoord - position;
float _cell = 1. / (amount * 2.);
float _cell = 1. / (amo * 2.);
float _xind = floor(pos.x / _cell);
float _yind = floor(pos.y / _cell);
float _xcell = fract(pos.x * amount * 2.);
float _ycell = fract(pos.y * amount * 2.);
float _xcell = fract(pos.x * amo * 2.);
float _ycell = fract(pos.y * amo * 2.);
float _x = _xcell;
float _y = _ycell;