- [Slope blur] Fix slope sampling artifact.

This commit is contained in:
Tanasart 2024-05-02 17:02:17 +07:00
parent bb0199e349
commit 3b91c72df9
4 changed files with 24 additions and 16 deletions

View file

@ -18,11 +18,13 @@ function Node_Bend(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
inputs[| 5] = nodeValue("Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1);
inputs[| 6] = nodeValue("Shift", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.);
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
input_display_list = [ 1,
["Surfaces", false], 0,
["Bend", false], 2, 3, 4, 5,
["Bend", false], 2, 3, 4, 5, 6,
]
mesh = [];
@ -46,6 +48,7 @@ function Node_Bend(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
var _typ = getInputData(2);
inputs[| 5].setVisible(_typ == 1);
inputs[| 6].setVisible(_typ == 1);
} #endregion
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
@ -54,6 +57,7 @@ function Node_Bend(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
var _axs = _data[3];
var _amo = _data[4];
var _sca = _data[5];
var _shf = _data[6];
var _sw = surface_get_width_safe(_surf);
var _sh = surface_get_height_safe(_surf);
@ -212,15 +216,15 @@ function Node_Bend(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
var u3 = x3 / _sw, v3 = y3 / _sh;
if(_axs == 0) {
x0 += sin(v0 * pi * _sca) * _amo * _sh / 2;
x1 += sin(v1 * pi * _sca) * _amo * _sh / 2;
x2 += sin(v2 * pi * _sca) * _amo * _sh / 2;
x3 += sin(v3 * pi * _sca) * _amo * _sh / 2;
x0 += sin(v0 * pi * _sca - _shf * pi * 2) * _amo * _sh / 2;
x1 += sin(v1 * pi * _sca - _shf * pi * 2) * _amo * _sh / 2;
x2 += sin(v2 * pi * _sca - _shf * pi * 2) * _amo * _sh / 2;
x3 += sin(v3 * pi * _sca - _shf * pi * 2) * _amo * _sh / 2;
} else {
y0 += sin(u0 * pi * _sca) * _amo * _sw / 2;
y1 += sin(u1 * pi * _sca) * _amo * _sw / 2;
y2 += sin(u2 * pi * _sca) * _amo * _sw / 2;
y3 += sin(u3 * pi * _sca) * _amo * _sw / 2;
y0 += sin(u0 * pi * _sca - _shf * pi * 2) * _amo * _sw / 2;
y1 += sin(u1 * pi * _sca - _shf * pi * 2) * _amo * _sw / 2;
y2 += sin(u2 * pi * _sca - _shf * pi * 2) * _amo * _sw / 2;
y3 += sin(u3 * pi * _sca - _shf * pi * 2) * _amo * _sw / 2;
}
_minx = _minx == undefined? min(x0, x1, x2, x3) : min(_minx, x0, x1, x2, x3);

View file

@ -33,7 +33,7 @@ function Node_Equation(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
name = "Equation";
color = COLORS.node_blend_number;
w = 96;
setDimension(96, 48);
ast = [];
inputs[| 0] = nodeValue("Equation", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "");
@ -167,7 +167,7 @@ function Node_Equation(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
var str = getInputData(0);
var bbox = drawGetBbox(xx, yy, _s);
var ss = string_scale(str, bbox.w, bbox.h);
var ss = string_scale(str, bbox.w - 10 * _s, bbox.h);
draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0);
} #endregion

View file

@ -2396,8 +2396,10 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
static drawName = function(_s, _mx, _my) { #region
var _draw_cc = hover_in_graph? COLORS._main_text : COLORS._main_text_sub;
var _draw_cc = COLORS._main_text;
var _draw_aa = hover_in_graph? 1 : 0.8;
draw_set_text(f_p1, fa_left, fa_center, _draw_cc);
draw_set_alpha(_draw_aa);
if(type == VALUE_TYPE.action) {
var tx = x;
@ -2415,6 +2417,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
draw_text_int(tx, y, name);
}
draw_set_alpha(1);
} #endregion
static drawConnections = function(params = {}) { #region

View file

@ -78,10 +78,10 @@ vec4 sampleTexture(sampler2D texture, vec2 pos) { #region
float sampleBright(vec2 pos) { vec4 c = sampleTexture(slopeMap, pos); return (c.r + c.g + c.b) / 3.; }
vec2 sampleSlope(vec2 pos) { #region
float h0 = sampleBright(pos + vec2(-txMap.x, 0.));
float h1 = sampleBright(pos + vec2( txMap.x, 0.));
float h2 = sampleBright(pos + vec2(0., -txMap.y));
float h3 = sampleBright(pos + vec2(0., txMap.y));
float h0 = sampleBright(clamp(pos + vec2(-txMap.x, 0.), 0., 1.));
float h1 = sampleBright(clamp(pos + vec2( txMap.x, 0.), 0., 1.));
float h2 = sampleBright(clamp(pos + vec2(0., -txMap.y), 0., 1.));
float h3 = sampleBright(clamp(pos + vec2(0., txMap.y), 0., 1.));
return vec2(h1 - h0, h3 - h2);
} #endregion