From 8a9b5277accb8ea7c95e2ea560271023c708a8fd Mon Sep 17 00:00:00 2001 From: Tanasart Date: Thu, 13 Jun 2024 14:21:07 +0700 Subject: [PATCH] - [Blur, Contrast blur, Directional blur, Radial blur, Shape blur, Non-uniform blur, Slope blur, Zoom blur] Add gamma correction option. --- scripts/blurSurface/blurSurface.gml | 3 ++- scripts/node_blur/node_blur.gml | 7 +++++-- .../node_blur_contrast/node_blur_contrast.gml | 6 +++++- .../node_blur_directional.gml | 5 ++++- scripts/node_blur_radial/node_blur_radial.gml | 5 ++++- scripts/node_blur_shape/node_blur_shape.gml | 7 ++++++- scripts/node_blur_simple/node_blur_simple.gml | 6 +++++- scripts/node_blur_slope/node_blur_slope.gml | 5 ++++- scripts/node_blur_zoom/node_blur_zoom.gml | 5 ++++- .../sh_blur_box_contrast.fsh | 10 ++++++++-- .../sh_blur_directional/sh_blur_directional.fsh | 6 ++++++ shaders/sh_blur_gaussian/sh_blur_gaussian.fsh | 7 +++++++ shaders/sh_blur_radial/sh_blur_radial.fsh | 17 ++++++++--------- shaders/sh_blur_shape/sh_blur_shape.fsh | 5 +++++ shaders/sh_blur_simple/sh_blur_simple.fsh | 4 ++++ shaders/sh_blur_slope/sh_blur_slope.fsh | 8 +++++++- shaders/sh_blur_zoom/sh_blur_zoom.fsh | 7 ++++++- 17 files changed, 90 insertions(+), 23 deletions(-) diff --git a/scripts/blurSurface/blurSurface.gml b/scripts/blurSurface/blurSurface.gml index 59f0c3bcd..0a307e693 100644 --- a/scripts/blurSurface/blurSurface.gml +++ b/scripts/blurSurface/blurSurface.gml @@ -28,7 +28,7 @@ function __gaussian_get_kernel(size) { 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 _sw = surface_get_width_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("size", size); shader_set_i("horizontal", 1); + shader_set_i("gamma", gamma); shader_set_i("overrideColor", overColor != noone); shader_set_f("overColor", colToVec4(overColor)); diff --git a/scripts/node_blur/node_blur.gml b/scripts/node_blur/node_blur.gml index bd38197d1..0593c04d8 100644 --- a/scripts/node_blur/node_blur.gml +++ b/scripts/node_blur/node_blur.gml @@ -25,11 +25,13 @@ function Node_Blur(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons __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); input_display_list = [ 7, 8, ["Surfaces", true], 0, 5, 6, 9, 10, - ["Blur", false], 1, 3, 4, + ["Blur", false], 1, 3, 4, 11, ]; 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 _mix = _data[6]; var _overc = _isovr? _data[4] : noone; + var _gam = _data[11]; inputs[| 4].setVisible(_isovr); surface_set_target(_outSurf); draw_clear_alpha(_isovr? _overc : 0, 0); 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; surface_reset_target(); diff --git a/scripts/node_blur_contrast/node_blur_contrast.gml b/scripts/node_blur_contrast/node_blur_contrast.gml index bc6b7e945..74a962427 100644 --- a/scripts/node_blur_contrast/node_blur_contrast.gml +++ b/scripts/node_blur_contrast/node_blur_contrast.gml @@ -22,9 +22,11 @@ function Node_Blur_Contrast(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr __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, ["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); @@ -43,6 +45,7 @@ function Node_Blur_Contrast(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr var _tres = _data[2]; var _mask = _data[3]; var _mix = _data[4]; + var _gam = _data[9]; var ww = surface_get_width_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("size", _size); shader_set_f("treshold", _tres); + shader_set_i("gamma", _gam); draw_surface_safe(_surf, 0, 0); surface_reset_shader(); diff --git a/scripts/node_blur_directional/node_blur_directional.gml b/scripts/node_blur_directional/node_blur_directional.gml index 1de403f06..7971811c9 100644 --- a/scripts/node_blur_directional/node_blur_directional.gml +++ b/scripts/node_blur_directional/node_blur_directional.gml @@ -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[| 12] = nodeValue("Gamma Correction", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false); + input_display_list = [ 5, 6, ["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); @@ -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("direction", _data[ 2], _data[10], inputs[| 2]); shader_set_i("scale", _data[11]); + shader_set_i("gamma", _data[12]); shader_set_i("sampleMode", struct_try_get(attributes, "oversample")); draw_surface_safe(_data[0], 0, 0); diff --git a/scripts/node_blur_radial/node_blur_radial.gml b/scripts/node_blur_radial/node_blur_radial.gml index d43d7bdd9..b1b284d88 100644 --- a/scripts/node_blur_radial/node_blur_radial.gml +++ b/scripts/node_blur_radial/node_blur_radial.gml @@ -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); input_display_list = [ 6, 7, ["Surfaces", true], 0, 4, 5, 8, 9, - ["Blur", false], 1, 10, 2, + ["Blur", false], 1, 10, 2, 11, ]; 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_map("strength", _data[1], _data[10], inputs[| 1]); shader_set_f("center", _cen); + shader_set_f("gamma", _data[11]); draw_surface_safe(_data[0]); surface_reset_shader(); diff --git a/scripts/node_blur_shape/node_blur_shape.gml b/scripts/node_blur_shape/node_blur_shape.gml index 428d09c66..5e1b05404 100644 --- a/scripts/node_blur_shape/node_blur_shape.gml +++ b/scripts/node_blur_shape/node_blur_shape.gml @@ -22,9 +22,11 @@ function Node_Blur_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group __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, ["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); @@ -43,6 +45,7 @@ function Node_Blur_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group var _blur = _data[1]; var _mask = _data[2]; var _mode = _data[7]; + var _gam = _data[9]; surface_set_shader(_outSurf, sh_blur_shape); 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); shader_set_i("sampleMode", _samp); shader_set_i("mode", _mode); + shader_set_i("mode", _mode); + shader_set_i("gamma", _gam); gpu_set_tex_filter_ext(b, true); diff --git a/scripts/node_blur_simple/node_blur_simple.gml b/scripts/node_blur_simple/node_blur_simple.gml index a12995519..0a2f3ed39 100644 --- a/scripts/node_blur_simple/node_blur_simple.gml +++ b/scripts/node_blur_simple/node_blur_simple.gml @@ -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[| 16] = nodeValue("Gamma Correction", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false); + input_display_list = [ 8, 9, ["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, ]; @@ -63,6 +65,7 @@ function Node_Blur_Simple(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou var _msk = _data[6]; var _mix = _data[7]; var _useGrd = _data[15]; + var _gam = _data[16]; 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("size", _size); shader_set_i("sampleMode", _samp); + shader_set_i("gamma", _gam); shader_set_i("overrideColor", _isovr); shader_set_color("overColor", _overc); diff --git a/scripts/node_blur_slope/node_blur_slope.gml b/scripts/node_blur_slope/node_blur_slope.gml index ad487d6c0..9464cfd3e 100644 --- a/scripts/node_blur_slope/node_blur_slope.gml +++ b/scripts/node_blur_slope/node_blur_slope.gml @@ -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) .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, ["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); @@ -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_f("slopeMapDim", surface_get_dimension(_data[2])); shader_set_i("sampleMode", struct_try_get(attributes, "oversample")); + shader_set_i("gamma", _data[11]); draw_surface_safe(_data[0], 0, 0); surface_reset_shader(); diff --git a/scripts/node_blur_zoom/node_blur_zoom.gml b/scripts/node_blur_zoom/node_blur_zoom.gml index 44ef36d9b..f32d801f6 100644 --- a/scripts/node_blur_zoom/node_blur_zoom.gml +++ b/scripts/node_blur_zoom/node_blur_zoom.gml @@ -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); input_display_list = [ 8, 9, ["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(); @@ -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_i("blurMode", _data[4]); shader_set_i("sampleMode", _sam); + shader_set_i("gamma", _data[13]); shader_set_i("useMask", is_surface(_data[5])); shader_set_surface("mask", _data[5]); diff --git a/shaders/sh_blur_box_contrast/sh_blur_box_contrast.fsh b/shaders/sh_blur_box_contrast/sh_blur_box_contrast.fsh index cc20b33c8..0e214c221 100644 --- a/shaders/sh_blur_box_contrast/sh_blur_box_contrast.fsh +++ b/shaders/sh_blur_box_contrast/sh_blur_box_contrast.fsh @@ -8,6 +8,7 @@ uniform vec2 dimension; uniform float size; uniform float treshold; uniform int direction; +uniform int gamma; vec3 rgb2xyz( vec3 c ) { #region vec3 tmp; @@ -53,12 +54,17 @@ void main() { float amp = 1. - dist / sz2; vec2 pxs = v_vTexcoord + vec2( i, j ) * tx; vec4 bcol = texture2D( gm_BaseTexture, pxs); - + if(c.a == bcol.a && colorDifferent(c, bcol) <= treshold) { + if(gamma == 1) bcol.rgb = pow(bcol.rgb, vec3(2.2)); + col += bcol * 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; } diff --git a/shaders/sh_blur_directional/sh_blur_directional.fsh b/shaders/sh_blur_directional/sh_blur_directional.fsh index 942eca7a2..6b3a94f7c 100644 --- a/shaders/sh_blur_directional/sh_blur_directional.fsh +++ b/shaders/sh_blur_directional/sh_blur_directional.fsh @@ -13,6 +13,7 @@ uniform int strengthUseSurf; uniform sampler2D strengthSurf; uniform int sampleMode; +uniform int gamma; vec4 sampleTexture(vec2 pos) { #region 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) { for(float i = -1.0; i <= 1.0; i += delta) { vec4 col = sampleTexture( v_vTexcoord - angle * i); + if(gamma == 1) col.rgb = pow(col.rgb, vec3(2.2)); + acc += col; weight += col.a; } @@ -50,6 +53,8 @@ vec4 dirBlur(vec2 angle) { #region } else { for(float i = 0.; i <= 1.0; i += delta) { vec4 col = sampleTexture( v_vTexcoord - angle * i); + if(gamma == 1) col.rgb = pow(col.rgb, vec3(2.2)); + acc += col ; weight += col.a; } @@ -60,6 +65,7 @@ vec4 dirBlur(vec2 angle) { #region acc += sampleTexture( v_vTexcoord ); } + if(gamma == 1) acc.rgb = pow(acc.rgb, vec3(1. / 2.2)); return acc; } #endregion diff --git a/shaders/sh_blur_gaussian/sh_blur_gaussian.fsh b/shaders/sh_blur_gaussian/sh_blur_gaussian.fsh index b4439b635..424908cb6 100644 --- a/shaders/sh_blur_gaussian/sh_blur_gaussian.fsh +++ b/shaders/sh_blur_gaussian/sh_blur_gaussian.fsh @@ -14,6 +14,8 @@ uniform int sampleMode; uniform int overrideColor; uniform vec4 overColor; +uniform int gamma; + vec4 sampleTexture(vec2 pos) { if(pos.x >= 0. && pos.y >= 0. && pos.x <= 1. && pos.y <= 1.) return texture2D(gm_BaseTexture, pos); @@ -37,8 +39,11 @@ float wgh = 0.; vec4 sample(in vec2 pos, in int index) { vec4 col = sampleTexture( pos ); + if(gamma == 1) col.rgb = pow(col.rgb, vec3(2.2)); + col.rgb *= weight[index] * col.a; wgh += weight[index] * col.a; + return col; } @@ -65,6 +70,8 @@ void main() { result.rgb /= wgh; result.a = wgh; + if(gamma == 1) result.rgb = pow(result.rgb, vec3(1. / 2.2)); + gl_FragColor = result; if(overrideColor == 1) { gl_FragColor.rgb = overColor.rgb; diff --git a/shaders/sh_blur_radial/sh_blur_radial.fsh b/shaders/sh_blur_radial/sh_blur_radial.fsh index cb6c6a938..cfeef9c81 100644 --- a/shaders/sh_blur_radial/sh_blur_radial.fsh +++ b/shaders/sh_blur_radial/sh_blur_radial.fsh @@ -6,7 +6,8 @@ varying vec4 v_vColour; uniform vec2 center; uniform vec2 dimension; -uniform int sampleMode; +uniform int sampleMode; +uniform int gamma; uniform vec2 strength; 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); vec2 offset = vec2(float(x), float(y)) * tx; vec4 sample = texture2D_bilinear(texture, (p + offset + vec2(0.5)) / sampleDimension); + sum += w * sample; weights += w; } @@ -132,17 +134,14 @@ void main() { float ang = angle + i / 100.; 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; weight += col.a; - - // if(bright > maxBright) { - // maxBright = bright; - // res = col; - // } } - gl_FragColor = clr / weight; - // gl_FragColor = res; + vec4 res = clr / weight; + if(gamma == 1) res.rgb = pow(res.rgb, vec3(1. / 2.2)); + + gl_FragColor = res; } diff --git a/shaders/sh_blur_shape/sh_blur_shape.fsh b/shaders/sh_blur_shape/sh_blur_shape.fsh index a8235e3a2..e3001831a 100644 --- a/shaders/sh_blur_shape/sh_blur_shape.fsh +++ b/shaders/sh_blur_shape/sh_blur_shape.fsh @@ -11,6 +11,7 @@ uniform sampler2D mask; uniform int sampleMode; uniform int mode; +uniform int gamma; float sampleMask() { #region if(useMask == 0) return 1.; @@ -67,6 +68,8 @@ void main() { vec4 c = sampleTexture((px + bPx) * tx); float b = sampleBlurMask(bPx / blurMaskDimension + 0.5); + if(gamma == 1) c.rgb = pow(c.rgb, vec3(2.2)); + if(mode == 0) { col += c * b; weight += b; @@ -78,5 +81,7 @@ void main() { if(mode == 0) col /= weight; else if(mode == 1) col.a = 1.; + if(gamma == 1) col.rgb = pow(col.rgb, vec3(1. / 2.2)); + gl_FragColor = col; } diff --git a/shaders/sh_blur_simple/sh_blur_simple.fsh b/shaders/sh_blur_simple/sh_blur_simple.fsh index c9f0338e2..86213bd78 100644 --- a/shaders/sh_blur_simple/sh_blur_simple.fsh +++ b/shaders/sh_blur_simple/sh_blur_simple.fsh @@ -7,6 +7,7 @@ uniform vec2 dimension; uniform int useMask; uniform sampler2D mask; uniform int sampleMode; +uniform int gamma; uniform int overrideColor; uniform vec4 overColor; @@ -196,6 +197,8 @@ void main() { #region if(abs(i + j) >= cel * 2.) continue; 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.); wei *= clamp(abs(i + j - floor(realSize) * 2.), 0., 1.); @@ -206,6 +209,7 @@ void main() { #region } clr /= totalWeight; + if(gamma == 1) clr.rgb = pow(clr.rgb, vec3(1. / 2.2)); if(overrideColor == 1) { clr.rgb = overColor.rgb; diff --git a/shaders/sh_blur_slope/sh_blur_slope.fsh b/shaders/sh_blur_slope/sh_blur_slope.fsh index dc3e4552c..54083c9be 100644 --- a/shaders/sh_blur_slope/sh_blur_slope.fsh +++ b/shaders/sh_blur_slope/sh_blur_slope.fsh @@ -13,6 +13,7 @@ uniform int strengthUseSurf; uniform sampler2D strengthSurf; uniform int sampleMode; +uniform int gamm; vec2 tx; vec2 txMap; @@ -131,6 +132,8 @@ void main() { float str = 1. - (i / str); vec4 c = sampleTexture(gm_BaseTexture, pos); + if(gamma == 1) c.rgb = pow(c.rgb, vec3(2.2)); + colr += c * str; alpha += str; @@ -138,5 +141,8 @@ void main() { 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; } \ No newline at end of file diff --git a/shaders/sh_blur_zoom/sh_blur_zoom.fsh b/shaders/sh_blur_zoom/sh_blur_zoom.fsh index 3bdb4c4ca..bcfb6ac4f 100644 --- a/shaders/sh_blur_zoom/sh_blur_zoom.fsh +++ b/shaders/sh_blur_zoom/sh_blur_zoom.fsh @@ -7,6 +7,7 @@ varying vec4 v_vColour; uniform vec2 center; uniform int sampleMode; uniform int blurMode; +uniform int gamma; uniform vec2 strength; uniform int strengthUseSurf; @@ -81,10 +82,14 @@ void main() { #region for(float i = 0.; i < nsamples * 2. + 1.; i++) { float scale = 1.0 + ((blrStart + i) * scale_factor); 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.; + if(gamma == 1) color.rgb = pow(color.rgb, vec3(1. / 2.2)); gl_FragColor = color; } #endregion \ No newline at end of file