mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-25 06:26:42 +01:00
- [Blur, Contrast blur, Directional blur, Radial blur, Shape blur, Non-uniform blur, Slope blur, Zoom blur] Add gamma correction option.
This commit is contained in:
parent
14e9e0f82f
commit
8a9b5277ac
17 changed files with 90 additions and 23 deletions
|
@ -28,7 +28,7 @@ function __gaussian_get_kernel(size) {
|
||||||
return gau_array;
|
return gau_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
function surface_apply_gaussian(surface, size, bg = false, bg_c = c_white, sampleMode = 0, overColor = noone) {
|
function surface_apply_gaussian(surface, size, bg = false, bg_c = c_white, sampleMode = 0, overColor = noone, gamma = false) {
|
||||||
var format = surface_get_format(surface);
|
var format = surface_get_format(surface);
|
||||||
var _sw = surface_get_width_safe(surface);
|
var _sw = surface_get_width_safe(surface);
|
||||||
var _sh = surface_get_height_safe(surface);
|
var _sh = surface_get_height_safe(surface);
|
||||||
|
@ -51,6 +51,7 @@ function surface_apply_gaussian(surface, size, bg = false, bg_c = c_white, sampl
|
||||||
shader_set_i("sampleMode", sampleMode);
|
shader_set_i("sampleMode", sampleMode);
|
||||||
shader_set_i("size", size);
|
shader_set_i("size", size);
|
||||||
shader_set_i("horizontal", 1);
|
shader_set_i("horizontal", 1);
|
||||||
|
shader_set_i("gamma", gamma);
|
||||||
|
|
||||||
shader_set_i("overrideColor", overColor != noone);
|
shader_set_i("overrideColor", overColor != noone);
|
||||||
shader_set_f("overColor", colToVec4(overColor));
|
shader_set_f("overColor", colToVec4(overColor));
|
||||||
|
|
|
@ -25,11 +25,13 @@ function Node_Blur(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
||||||
|
|
||||||
__init_mask_modifier(5); // inputs 9, 10
|
__init_mask_modifier(5); // inputs 9, 10
|
||||||
|
|
||||||
|
inputs[| 11] = nodeValue("Gamma Correction", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
||||||
|
|
||||||
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
||||||
|
|
||||||
input_display_list = [ 7, 8,
|
input_display_list = [ 7, 8,
|
||||||
["Surfaces", true], 0, 5, 6, 9, 10,
|
["Surfaces", true], 0, 5, 6, 9, 10,
|
||||||
["Blur", false], 1, 3, 4,
|
["Blur", false], 1, 3, 4, 11,
|
||||||
];
|
];
|
||||||
|
|
||||||
attribute_surface_depth();
|
attribute_surface_depth();
|
||||||
|
@ -47,13 +49,14 @@ function Node_Blur(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
||||||
var _mask = _data[5];
|
var _mask = _data[5];
|
||||||
var _mix = _data[6];
|
var _mix = _data[6];
|
||||||
var _overc = _isovr? _data[4] : noone;
|
var _overc = _isovr? _data[4] : noone;
|
||||||
|
var _gam = _data[11];
|
||||||
|
|
||||||
inputs[| 4].setVisible(_isovr);
|
inputs[| 4].setVisible(_isovr);
|
||||||
|
|
||||||
surface_set_target(_outSurf);
|
surface_set_target(_outSurf);
|
||||||
draw_clear_alpha(_isovr? _overc : 0, 0);
|
draw_clear_alpha(_isovr? _overc : 0, 0);
|
||||||
BLEND_OVERRIDE;
|
BLEND_OVERRIDE;
|
||||||
draw_surface_safe(surface_apply_gaussian(_data[0], _size, false, c_white, _clamp, _overc), 0, 0);
|
draw_surface_safe(surface_apply_gaussian(_data[0], _size, false, c_white, _clamp, _overc, _gam), 0, 0);
|
||||||
BLEND_NORMAL;
|
BLEND_NORMAL;
|
||||||
surface_reset_target();
|
surface_reset_target();
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,11 @@ function Node_Blur_Contrast(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
||||||
|
|
||||||
__init_mask_modifier(3); // inputs 7, 8
|
__init_mask_modifier(3); // inputs 7, 8
|
||||||
|
|
||||||
|
inputs[| 9] = nodeValue("Gamma Correction", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
||||||
|
|
||||||
input_display_list = [ 5, 6,
|
input_display_list = [ 5, 6,
|
||||||
["Surfaces", true], 0, 3, 4, 7, 8,
|
["Surfaces", true], 0, 3, 4, 7, 8,
|
||||||
["Blur", false], 1, 2,
|
["Blur", false], 1, 2, 9,
|
||||||
]
|
]
|
||||||
|
|
||||||
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
||||||
|
@ -43,6 +45,7 @@ function Node_Blur_Contrast(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
||||||
var _tres = _data[2];
|
var _tres = _data[2];
|
||||||
var _mask = _data[3];
|
var _mask = _data[3];
|
||||||
var _mix = _data[4];
|
var _mix = _data[4];
|
||||||
|
var _gam = _data[9];
|
||||||
|
|
||||||
var ww = surface_get_width_safe(_surf);
|
var ww = surface_get_width_safe(_surf);
|
||||||
var hh = surface_get_height_safe(_surf);
|
var hh = surface_get_height_safe(_surf);
|
||||||
|
@ -51,6 +54,7 @@ function Node_Blur_Contrast(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
||||||
shader_set_f("dimension", [ ww, hh ]);
|
shader_set_f("dimension", [ ww, hh ]);
|
||||||
shader_set_f("size", _size);
|
shader_set_f("size", _size);
|
||||||
shader_set_f("treshold", _tres);
|
shader_set_f("treshold", _tres);
|
||||||
|
shader_set_i("gamma", _gam);
|
||||||
|
|
||||||
draw_surface_safe(_surf, 0, 0);
|
draw_surface_safe(_surf, 0, 0);
|
||||||
surface_reset_shader();
|
surface_reset_shader();
|
||||||
|
|
|
@ -34,9 +34,11 @@ function Node_Blur_Directional(_x, _y, _group = noone) : Node_Processor(_x, _y,
|
||||||
|
|
||||||
inputs[| 11] = nodeValue("Single direction", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
inputs[| 11] = nodeValue("Single direction", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
||||||
|
|
||||||
|
inputs[| 12] = nodeValue("Gamma Correction", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
||||||
|
|
||||||
input_display_list = [ 5, 6,
|
input_display_list = [ 5, 6,
|
||||||
["Surfaces", true], 0, 3, 4, 7, 8,
|
["Surfaces", true], 0, 3, 4, 7, 8,
|
||||||
["Blur", false], 1, 9, 2, 10, 11,
|
["Blur", false], 1, 9, 2, 10, 11, 12,
|
||||||
]
|
]
|
||||||
|
|
||||||
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
||||||
|
@ -71,6 +73,7 @@ function Node_Blur_Directional(_x, _y, _group = noone) : Node_Processor(_x, _y,
|
||||||
shader_set_f_map("strength", _data[ 1], _data[ 9], inputs[| 1]);
|
shader_set_f_map("strength", _data[ 1], _data[ 9], inputs[| 1]);
|
||||||
shader_set_f_map("direction", _data[ 2], _data[10], inputs[| 2]);
|
shader_set_f_map("direction", _data[ 2], _data[10], inputs[| 2]);
|
||||||
shader_set_i("scale", _data[11]);
|
shader_set_i("scale", _data[11]);
|
||||||
|
shader_set_i("gamma", _data[12]);
|
||||||
shader_set_i("sampleMode", struct_try_get(attributes, "oversample"));
|
shader_set_i("sampleMode", struct_try_get(attributes, "oversample"));
|
||||||
|
|
||||||
draw_surface_safe(_data[0], 0, 0);
|
draw_surface_safe(_data[0], 0, 0);
|
||||||
|
|
|
@ -33,11 +33,13 @@ function Node_Blur_Radial(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
inputs[| 11] = nodeValue("Gamma Correction", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
||||||
|
|
||||||
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
||||||
|
|
||||||
input_display_list = [ 6, 7,
|
input_display_list = [ 6, 7,
|
||||||
["Surfaces", true], 0, 4, 5, 8, 9,
|
["Surfaces", true], 0, 4, 5, 8, 9,
|
||||||
["Blur", false], 1, 10, 2,
|
["Blur", false], 1, 10, 2, 11,
|
||||||
];
|
];
|
||||||
|
|
||||||
attribute_surface_depth();
|
attribute_surface_depth();
|
||||||
|
@ -71,6 +73,7 @@ function Node_Blur_Radial(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
|
||||||
shader_set_f("dimension", surface_get_width_safe(_outSurf), surface_get_height_safe(_outSurf));
|
shader_set_f("dimension", surface_get_width_safe(_outSurf), surface_get_height_safe(_outSurf));
|
||||||
shader_set_f_map("strength", _data[1], _data[10], inputs[| 1]);
|
shader_set_f_map("strength", _data[1], _data[10], inputs[| 1]);
|
||||||
shader_set_f("center", _cen);
|
shader_set_f("center", _cen);
|
||||||
|
shader_set_f("gamma", _data[11]);
|
||||||
|
|
||||||
draw_surface_safe(_data[0]);
|
draw_surface_safe(_data[0]);
|
||||||
surface_reset_shader();
|
surface_reset_shader();
|
||||||
|
|
|
@ -22,9 +22,11 @@ function Node_Blur_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group
|
||||||
|
|
||||||
__init_mask_modifier(3); // inputs 7, 8
|
__init_mask_modifier(3); // inputs 7, 8
|
||||||
|
|
||||||
|
inputs[| 9] = nodeValue("Gamma Correction", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
||||||
|
|
||||||
input_display_list = [ 5, 6,
|
input_display_list = [ 5, 6,
|
||||||
["Surfaces", true], 0, 3, 4, 7, 8,
|
["Surfaces", true], 0, 3, 4, 7, 8,
|
||||||
["Blur", false], 7, 1, 2,
|
["Blur", false], 7, 1, 2, 9,
|
||||||
];
|
];
|
||||||
|
|
||||||
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
||||||
|
@ -43,6 +45,7 @@ function Node_Blur_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group
|
||||||
var _blur = _data[1];
|
var _blur = _data[1];
|
||||||
var _mask = _data[2];
|
var _mask = _data[2];
|
||||||
var _mode = _data[7];
|
var _mode = _data[7];
|
||||||
|
var _gam = _data[9];
|
||||||
|
|
||||||
surface_set_shader(_outSurf, sh_blur_shape);
|
surface_set_shader(_outSurf, sh_blur_shape);
|
||||||
shader_set_f("dimension", surface_get_dimension(_data[0]));
|
shader_set_f("dimension", surface_get_dimension(_data[0]));
|
||||||
|
@ -50,6 +53,8 @@ function Node_Blur_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group
|
||||||
var b = shader_set_surface("blurMask", _blur);
|
var b = shader_set_surface("blurMask", _blur);
|
||||||
shader_set_i("sampleMode", _samp);
|
shader_set_i("sampleMode", _samp);
|
||||||
shader_set_i("mode", _mode);
|
shader_set_i("mode", _mode);
|
||||||
|
shader_set_i("mode", _mode);
|
||||||
|
shader_set_i("gamma", _gam);
|
||||||
|
|
||||||
gpu_set_tex_filter_ext(b, true);
|
gpu_set_tex_filter_ext(b, true);
|
||||||
|
|
||||||
|
|
|
@ -36,9 +36,11 @@ function Node_Blur_Simple(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
|
||||||
|
|
||||||
inputs[| 15] = nodeValue("Use Gradient", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
inputs[| 15] = nodeValue("Use Gradient", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
||||||
|
|
||||||
|
inputs[| 16] = nodeValue("Gamma Correction", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
||||||
|
|
||||||
input_display_list = [ 8, 9,
|
input_display_list = [ 8, 9,
|
||||||
["Surfaces", true], 0, 6, 7, 10, 11,
|
["Surfaces", true], 0, 6, 7, 10, 11,
|
||||||
["Blur", false], 1, 3, 4, 5,
|
["Blur", false], 1, 3, 4, 5, 16,
|
||||||
["Effects", false, 15], 12, 13, 14,
|
["Effects", false, 15], 12, 13, 14,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -63,6 +65,7 @@ function Node_Blur_Simple(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
|
||||||
var _msk = _data[6];
|
var _msk = _data[6];
|
||||||
var _mix = _data[7];
|
var _mix = _data[7];
|
||||||
var _useGrd = _data[15];
|
var _useGrd = _data[15];
|
||||||
|
var _gam = _data[16];
|
||||||
|
|
||||||
inputs[| 5].setVisible(_isovr);
|
inputs[| 5].setVisible(_isovr);
|
||||||
|
|
||||||
|
@ -73,6 +76,7 @@ function Node_Blur_Simple(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
|
||||||
shader_set_f("dimension", surface_get_width_safe(_data[0]), surface_get_height_safe(_data[0]));
|
shader_set_f("dimension", surface_get_width_safe(_data[0]), surface_get_height_safe(_data[0]));
|
||||||
shader_set_f("size", _size);
|
shader_set_f("size", _size);
|
||||||
shader_set_i("sampleMode", _samp);
|
shader_set_i("sampleMode", _samp);
|
||||||
|
shader_set_i("gamma", _gam);
|
||||||
|
|
||||||
shader_set_i("overrideColor", _isovr);
|
shader_set_i("overrideColor", _isovr);
|
||||||
shader_set_color("overColor", _overc);
|
shader_set_color("overColor", _overc);
|
||||||
|
|
|
@ -31,9 +31,11 @@ function Node_Blur_Slope(_x, _y, _group = noone) : Node_Processor(_x, _y, _group
|
||||||
inputs[| 10] = nodeValue("Step", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.1)
|
inputs[| 10] = nodeValue("Step", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.1)
|
||||||
.setDisplay(VALUE_DISPLAY.slider, { range: [0, 1, 0.01] });
|
.setDisplay(VALUE_DISPLAY.slider, { range: [0, 1, 0.01] });
|
||||||
|
|
||||||
|
inputs[| 11] = nodeValue("Gamma Correction", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
||||||
|
|
||||||
input_display_list = [ 5, 6,
|
input_display_list = [ 5, 6,
|
||||||
["Surfaces", true], 0, 3, 4, 7, 8,
|
["Surfaces", true], 0, 3, 4, 7, 8,
|
||||||
["Blur", false], 2, 1, 9, 10,
|
["Blur", false], 2, 1, 9, 10, 11,
|
||||||
]
|
]
|
||||||
|
|
||||||
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
||||||
|
@ -57,6 +59,7 @@ function Node_Blur_Slope(_x, _y, _group = noone) : Node_Processor(_x, _y, _group
|
||||||
shader_set_surface("slopeMap", _data[2]);
|
shader_set_surface("slopeMap", _data[2]);
|
||||||
shader_set_f("slopeMapDim", surface_get_dimension(_data[2]));
|
shader_set_f("slopeMapDim", surface_get_dimension(_data[2]));
|
||||||
shader_set_i("sampleMode", struct_try_get(attributes, "oversample"));
|
shader_set_i("sampleMode", struct_try_get(attributes, "oversample"));
|
||||||
|
shader_set_i("gamma", _data[11]);
|
||||||
|
|
||||||
draw_surface_safe(_data[0], 0, 0);
|
draw_surface_safe(_data[0], 0, 0);
|
||||||
surface_reset_shader();
|
surface_reset_shader();
|
||||||
|
|
|
@ -37,11 +37,13 @@ function Node_Blur_Zoom(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
inputs[| 13] = nodeValue("Gamma Correction", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
||||||
|
|
||||||
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
||||||
|
|
||||||
input_display_list = [ 8, 9,
|
input_display_list = [ 8, 9,
|
||||||
["Surfaces", true], 0, 6, 7, 10, 11,
|
["Surfaces", true], 0, 6, 7, 10, 11,
|
||||||
["Blur", false], 1, 12, 2, 4, 5
|
["Blur", false], 1, 12, 2, 4, 5, 13
|
||||||
];
|
];
|
||||||
|
|
||||||
attribute_surface_depth();
|
attribute_surface_depth();
|
||||||
|
@ -74,6 +76,7 @@ function Node_Blur_Zoom(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
shader_set_f_map("strength", _data[1], _data[12], inputs[| 1]);
|
shader_set_f_map("strength", _data[1], _data[12], inputs[| 1]);
|
||||||
shader_set_i("blurMode", _data[4]);
|
shader_set_i("blurMode", _data[4]);
|
||||||
shader_set_i("sampleMode", _sam);
|
shader_set_i("sampleMode", _sam);
|
||||||
|
shader_set_i("gamma", _data[13]);
|
||||||
|
|
||||||
shader_set_i("useMask", is_surface(_data[5]));
|
shader_set_i("useMask", is_surface(_data[5]));
|
||||||
shader_set_surface("mask", _data[5]);
|
shader_set_surface("mask", _data[5]);
|
||||||
|
|
|
@ -8,6 +8,7 @@ uniform vec2 dimension;
|
||||||
uniform float size;
|
uniform float size;
|
||||||
uniform float treshold;
|
uniform float treshold;
|
||||||
uniform int direction;
|
uniform int direction;
|
||||||
|
uniform int gamma;
|
||||||
|
|
||||||
vec3 rgb2xyz( vec3 c ) { #region
|
vec3 rgb2xyz( vec3 c ) { #region
|
||||||
vec3 tmp;
|
vec3 tmp;
|
||||||
|
@ -55,10 +56,15 @@ void main() {
|
||||||
vec4 bcol = texture2D( gm_BaseTexture, pxs);
|
vec4 bcol = texture2D( gm_BaseTexture, pxs);
|
||||||
|
|
||||||
if(c.a == bcol.a && colorDifferent(c, bcol) <= treshold) {
|
if(c.a == bcol.a && colorDifferent(c, bcol) <= treshold) {
|
||||||
|
if(gamma == 1) bcol.rgb = pow(bcol.rgb, vec3(2.2));
|
||||||
|
|
||||||
col += bcol * amp;
|
col += bcol * amp;
|
||||||
div += amp;
|
div += amp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_FragColor = col / div;
|
vec4 res = col / div;
|
||||||
|
if(gamma == 1) res.rgb = pow(res.rgb, vec3(1. / 2.2));
|
||||||
|
|
||||||
|
gl_FragColor = res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ uniform int strengthUseSurf;
|
||||||
uniform sampler2D strengthSurf;
|
uniform sampler2D strengthSurf;
|
||||||
|
|
||||||
uniform int sampleMode;
|
uniform int sampleMode;
|
||||||
|
uniform int gamma;
|
||||||
|
|
||||||
vec4 sampleTexture(vec2 pos) { #region
|
vec4 sampleTexture(vec2 pos) { #region
|
||||||
if(pos.x >= 0. && pos.y >= 0. && pos.x <= 1. && pos.y <= 1.)
|
if(pos.x >= 0. && pos.y >= 0. && pos.x <= 1. && pos.y <= 1.)
|
||||||
|
@ -41,6 +42,8 @@ vec4 dirBlur(vec2 angle) { #region
|
||||||
if(scale == 0) {
|
if(scale == 0) {
|
||||||
for(float i = -1.0; i <= 1.0; i += delta) {
|
for(float i = -1.0; i <= 1.0; i += delta) {
|
||||||
vec4 col = sampleTexture( v_vTexcoord - angle * i);
|
vec4 col = sampleTexture( v_vTexcoord - angle * i);
|
||||||
|
if(gamma == 1) col.rgb = pow(col.rgb, vec3(2.2));
|
||||||
|
|
||||||
acc += col;
|
acc += col;
|
||||||
weight += col.a;
|
weight += col.a;
|
||||||
}
|
}
|
||||||
|
@ -50,6 +53,8 @@ vec4 dirBlur(vec2 angle) { #region
|
||||||
} else {
|
} else {
|
||||||
for(float i = 0.; i <= 1.0; i += delta) {
|
for(float i = 0.; i <= 1.0; i += delta) {
|
||||||
vec4 col = sampleTexture( v_vTexcoord - angle * i);
|
vec4 col = sampleTexture( v_vTexcoord - angle * i);
|
||||||
|
if(gamma == 1) col.rgb = pow(col.rgb, vec3(2.2));
|
||||||
|
|
||||||
acc += col ;
|
acc += col ;
|
||||||
weight += col.a;
|
weight += col.a;
|
||||||
}
|
}
|
||||||
|
@ -60,6 +65,7 @@ vec4 dirBlur(vec2 angle) { #region
|
||||||
acc += sampleTexture( v_vTexcoord );
|
acc += sampleTexture( v_vTexcoord );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(gamma == 1) acc.rgb = pow(acc.rgb, vec3(1. / 2.2));
|
||||||
return acc;
|
return acc;
|
||||||
} #endregion
|
} #endregion
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,8 @@ uniform int sampleMode;
|
||||||
uniform int overrideColor;
|
uniform int overrideColor;
|
||||||
uniform vec4 overColor;
|
uniform vec4 overColor;
|
||||||
|
|
||||||
|
uniform int gamma;
|
||||||
|
|
||||||
vec4 sampleTexture(vec2 pos) {
|
vec4 sampleTexture(vec2 pos) {
|
||||||
if(pos.x >= 0. && pos.y >= 0. && pos.x <= 1. && pos.y <= 1.)
|
if(pos.x >= 0. && pos.y >= 0. && pos.x <= 1. && pos.y <= 1.)
|
||||||
return texture2D(gm_BaseTexture, pos);
|
return texture2D(gm_BaseTexture, pos);
|
||||||
|
@ -37,8 +39,11 @@ float wgh = 0.;
|
||||||
|
|
||||||
vec4 sample(in vec2 pos, in int index) {
|
vec4 sample(in vec2 pos, in int index) {
|
||||||
vec4 col = sampleTexture( pos );
|
vec4 col = sampleTexture( pos );
|
||||||
|
if(gamma == 1) col.rgb = pow(col.rgb, vec3(2.2));
|
||||||
|
|
||||||
col.rgb *= weight[index] * col.a;
|
col.rgb *= weight[index] * col.a;
|
||||||
wgh += weight[index] * col.a;
|
wgh += weight[index] * col.a;
|
||||||
|
|
||||||
return col;
|
return col;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,6 +70,8 @@ void main() {
|
||||||
result.rgb /= wgh;
|
result.rgb /= wgh;
|
||||||
result.a = wgh;
|
result.a = wgh;
|
||||||
|
|
||||||
|
if(gamma == 1) result.rgb = pow(result.rgb, vec3(1. / 2.2));
|
||||||
|
|
||||||
gl_FragColor = result;
|
gl_FragColor = result;
|
||||||
if(overrideColor == 1) {
|
if(overrideColor == 1) {
|
||||||
gl_FragColor.rgb = overColor.rgb;
|
gl_FragColor.rgb = overColor.rgb;
|
||||||
|
|
|
@ -7,6 +7,7 @@ varying vec4 v_vColour;
|
||||||
uniform vec2 center;
|
uniform vec2 center;
|
||||||
uniform vec2 dimension;
|
uniform vec2 dimension;
|
||||||
uniform int sampleMode;
|
uniform int sampleMode;
|
||||||
|
uniform int gamma;
|
||||||
|
|
||||||
uniform vec2 strength;
|
uniform vec2 strength;
|
||||||
uniform int strengthUseSurf;
|
uniform int strengthUseSurf;
|
||||||
|
@ -62,6 +63,7 @@ vec4 texture2D_rsin( sampler2D texture, vec2 uv ) {
|
||||||
float w = sinc(a * PI * tx.x) * sinc(a * PI * tx.y);
|
float w = sinc(a * PI * tx.x) * sinc(a * PI * tx.y);
|
||||||
vec2 offset = vec2(float(x), float(y)) * tx;
|
vec2 offset = vec2(float(x), float(y)) * tx;
|
||||||
vec4 sample = texture2D_bilinear(texture, (p + offset + vec2(0.5)) / sampleDimension);
|
vec4 sample = texture2D_bilinear(texture, (p + offset + vec2(0.5)) / sampleDimension);
|
||||||
|
|
||||||
sum += w * sample;
|
sum += w * sample;
|
||||||
weights += w;
|
weights += w;
|
||||||
}
|
}
|
||||||
|
@ -132,17 +134,14 @@ void main() {
|
||||||
float ang = angle + i / 100.;
|
float ang = angle + i / 100.;
|
||||||
vec4 col = sampleTexture((pxCen + vec2(cos(ang), sin(ang)) * dist) / dimension);
|
vec4 col = sampleTexture((pxCen + vec2(cos(ang), sin(ang)) * dist) / dimension);
|
||||||
|
|
||||||
// float bright = (col.r + col.g + col.b) / 3. * col.a;
|
if(gamma == 1) col.rgb = pow(col.rgb, vec3(2.2));
|
||||||
|
|
||||||
clr += col;
|
clr += col;
|
||||||
weight += col.a;
|
weight += col.a;
|
||||||
|
|
||||||
// if(bright > maxBright) {
|
|
||||||
// maxBright = bright;
|
|
||||||
// res = col;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_FragColor = clr / weight;
|
vec4 res = clr / weight;
|
||||||
// gl_FragColor = res;
|
if(gamma == 1) res.rgb = pow(res.rgb, vec3(1. / 2.2));
|
||||||
|
|
||||||
|
gl_FragColor = res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ uniform sampler2D mask;
|
||||||
uniform int sampleMode;
|
uniform int sampleMode;
|
||||||
|
|
||||||
uniform int mode;
|
uniform int mode;
|
||||||
|
uniform int gamma;
|
||||||
|
|
||||||
float sampleMask() { #region
|
float sampleMask() { #region
|
||||||
if(useMask == 0) return 1.;
|
if(useMask == 0) return 1.;
|
||||||
|
@ -67,6 +68,8 @@ void main() {
|
||||||
vec4 c = sampleTexture((px + bPx) * tx);
|
vec4 c = sampleTexture((px + bPx) * tx);
|
||||||
float b = sampleBlurMask(bPx / blurMaskDimension + 0.5);
|
float b = sampleBlurMask(bPx / blurMaskDimension + 0.5);
|
||||||
|
|
||||||
|
if(gamma == 1) c.rgb = pow(c.rgb, vec3(2.2));
|
||||||
|
|
||||||
if(mode == 0) {
|
if(mode == 0) {
|
||||||
col += c * b;
|
col += c * b;
|
||||||
weight += b;
|
weight += b;
|
||||||
|
@ -78,5 +81,7 @@ void main() {
|
||||||
if(mode == 0) col /= weight;
|
if(mode == 0) col /= weight;
|
||||||
else if(mode == 1) col.a = 1.;
|
else if(mode == 1) col.a = 1.;
|
||||||
|
|
||||||
|
if(gamma == 1) col.rgb = pow(col.rgb, vec3(1. / 2.2));
|
||||||
|
|
||||||
gl_FragColor = col;
|
gl_FragColor = col;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ uniform vec2 dimension;
|
||||||
uniform int useMask;
|
uniform int useMask;
|
||||||
uniform sampler2D mask;
|
uniform sampler2D mask;
|
||||||
uniform int sampleMode;
|
uniform int sampleMode;
|
||||||
|
uniform int gamma;
|
||||||
|
|
||||||
uniform int overrideColor;
|
uniform int overrideColor;
|
||||||
uniform vec4 overColor;
|
uniform vec4 overColor;
|
||||||
|
@ -196,6 +197,8 @@ void main() { #region
|
||||||
if(abs(i + j) >= cel * 2.) continue;
|
if(abs(i + j) >= cel * 2.) continue;
|
||||||
|
|
||||||
vec4 sam = sampleTexture( v_vTexcoord + vec2(i, j) * texel );
|
vec4 sam = sampleTexture( v_vTexcoord + vec2(i, j) * texel );
|
||||||
|
if(gamma == 1) sam.rgb = pow(sam.rgb, vec3(2.2));
|
||||||
|
|
||||||
float wei = 1. - (abs(i) + abs(j)) / (realSize * 2.);
|
float wei = 1. - (abs(i) + abs(j)) / (realSize * 2.);
|
||||||
wei *= clamp(abs(i + j - floor(realSize) * 2.), 0., 1.);
|
wei *= clamp(abs(i + j - floor(realSize) * 2.), 0., 1.);
|
||||||
|
|
||||||
|
@ -206,6 +209,7 @@ void main() { #region
|
||||||
}
|
}
|
||||||
|
|
||||||
clr /= totalWeight;
|
clr /= totalWeight;
|
||||||
|
if(gamma == 1) clr.rgb = pow(clr.rgb, vec3(1. / 2.2));
|
||||||
|
|
||||||
if(overrideColor == 1) {
|
if(overrideColor == 1) {
|
||||||
clr.rgb = overColor.rgb;
|
clr.rgb = overColor.rgb;
|
||||||
|
|
|
@ -13,6 +13,7 @@ uniform int strengthUseSurf;
|
||||||
uniform sampler2D strengthSurf;
|
uniform sampler2D strengthSurf;
|
||||||
|
|
||||||
uniform int sampleMode;
|
uniform int sampleMode;
|
||||||
|
uniform int gamm;
|
||||||
|
|
||||||
vec2 tx;
|
vec2 tx;
|
||||||
vec2 txMap;
|
vec2 txMap;
|
||||||
|
@ -131,6 +132,8 @@ void main() {
|
||||||
|
|
||||||
float str = 1. - (i / str);
|
float str = 1. - (i / str);
|
||||||
vec4 c = sampleTexture(gm_BaseTexture, pos);
|
vec4 c = sampleTexture(gm_BaseTexture, pos);
|
||||||
|
if(gamma == 1) c.rgb = pow(c.rgb, vec3(2.2));
|
||||||
|
|
||||||
colr += c * str;
|
colr += c * str;
|
||||||
alpha += str;
|
alpha += str;
|
||||||
|
|
||||||
|
@ -138,5 +141,8 @@ void main() {
|
||||||
pos += slp * stepSize;
|
pos += slp * stepSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_FragColor = colr / alpha;
|
vec4 res = colr / alpha;
|
||||||
|
if(gamma == 1) res.rgb = pow(result.rgb, vec3(1. / 2.2));
|
||||||
|
|
||||||
|
gl_FragColor = res;
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ varying vec4 v_vColour;
|
||||||
uniform vec2 center;
|
uniform vec2 center;
|
||||||
uniform int sampleMode;
|
uniform int sampleMode;
|
||||||
uniform int blurMode;
|
uniform int blurMode;
|
||||||
|
uniform int gamma;
|
||||||
|
|
||||||
uniform vec2 strength;
|
uniform vec2 strength;
|
||||||
uniform int strengthUseSurf;
|
uniform int strengthUseSurf;
|
||||||
|
@ -81,10 +82,14 @@ void main() { #region
|
||||||
for(float i = 0.; i < nsamples * 2. + 1.; i++) {
|
for(float i = 0.; i < nsamples * 2. + 1.; i++) {
|
||||||
float scale = 1.0 + ((blrStart + i) * scale_factor);
|
float scale = 1.0 + ((blrStart + i) * scale_factor);
|
||||||
vec2 pos = uv * scale + center;
|
vec2 pos = uv * scale + center;
|
||||||
color += sampleTexture(pos);
|
|
||||||
|
vec4 col = sampleTexture(pos);
|
||||||
|
if(gamma == 1) col.rgb = pow(col.rgb, vec3(2.2));
|
||||||
|
color += col;
|
||||||
}
|
}
|
||||||
|
|
||||||
color /= nsamples * 2. + 1.;
|
color /= nsamples * 2. + 1.;
|
||||||
|
if(gamma == 1) color.rgb = pow(color.rgb, vec3(1. / 2.2));
|
||||||
|
|
||||||
gl_FragColor = color;
|
gl_FragColor = color;
|
||||||
} #endregion
|
} #endregion
|
Loading…
Reference in a new issue