glow
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 80 KiB |
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 80 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
|
@ -11,8 +11,9 @@ function __gaussian_get_kernel(size) {
|
|||
if(struct_has(GAUSSIAN_COEFF, size)) return GAUSSIAN_COEFF[$ size];
|
||||
|
||||
var gau_array = array_create(size);
|
||||
var we = 0;
|
||||
var b = 0.3 * ((size - 1) * 0.5 - 1) + 0.8;
|
||||
var we = 0;
|
||||
var b = 0.3 * ((size - 1) * 0.5 - 1) + 0.8;
|
||||
|
||||
for(var i = 0; i < size; i++) {
|
||||
var _x = i * .5;
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ function Node_Glow(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
|||
inputs[| 2] = nodeValue("Size", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 3)
|
||||
.setDisplay(VALUE_DISPLAY.slider, { range: [1, 16, 1] });
|
||||
|
||||
inputs[| 3] = nodeValue("Strength", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.5)
|
||||
.setDisplay(VALUE_DISPLAY.slider);
|
||||
inputs[| 3] = nodeValue("Strength", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
|
||||
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 4, 0.01 ]});
|
||||
|
||||
inputs[| 4] = nodeValue("Color", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white);
|
||||
|
||||
|
@ -24,54 +24,42 @@ function Node_Glow(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
|||
|
||||
__init_mask_modifier(5); // inputs 8, 9,
|
||||
|
||||
inputs[| 10] = nodeValue("Mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
||||
.setDisplay(VALUE_DISPLAY.enum_button, [ "Greyscale", "Alpha" ]);
|
||||
|
||||
inputs[| 11] = nodeValue("Draw original", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
|
||||
|
||||
input_display_list = [ 7,
|
||||
["Surfaces", true], 0, 5, 6, 8, 9,
|
||||
["Glow", false], 1, 2, 3, 4,
|
||||
["Glow", false], 10, 2, 3,
|
||||
["Render", false], 4, 11,
|
||||
]
|
||||
|
||||
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
||||
|
||||
surface_blur_init();
|
||||
attribute_surface_depth();
|
||||
|
||||
static step = function() { #region
|
||||
__step_mask_modifier();
|
||||
} #endregion
|
||||
static step = function() { __step_mask_modifier(); }
|
||||
|
||||
static processData = function(_outSurf, _data, _output_index, _array_index) {
|
||||
var _border = _data[1];
|
||||
var _size = _data[2];
|
||||
var _stre = _data[3];
|
||||
var cl = _data[4];
|
||||
var pass1 = surface_create_valid(surface_get_width_safe(_outSurf), surface_get_height_safe(_outSurf), attrDepth());
|
||||
var _border = _data[1];
|
||||
var _size = _data[2];
|
||||
var _strength = _data[3];
|
||||
var _color = _data[4];
|
||||
var _mode = _data[10];
|
||||
var _render = _data[11];
|
||||
|
||||
surface_set_target(pass1);
|
||||
draw_clear_alpha(c_black, 1);
|
||||
shader_set(sh_outline_only);
|
||||
shader_set_f("dimension", [ surface_get_width_safe(_outSurf), surface_get_height_safe(_outSurf) ]);
|
||||
shader_set_f("borderSize", _size + _border);
|
||||
shader_set_f("borderColor", [ 1., 1., 1., 1. ]);
|
||||
|
||||
if(is_surface(_data[0])) draw_surface_safe(_data[0], 0, 0);
|
||||
shader_reset();
|
||||
surface_reset_target();
|
||||
|
||||
var s = surface_apply_gaussian(pass1, _size, false, c_black, 1, noone);
|
||||
|
||||
surface_set_shader(_outSurf, sh_lum2alpha);
|
||||
shader_set_color("color", cl);
|
||||
shader_set_f("intensity", _stre);
|
||||
draw_surface_ext_safe(s, 0, 0, 1, 1, 0, c_white, 1);
|
||||
shader_reset();
|
||||
|
||||
BLEND_ALPHA_MULP
|
||||
draw_surface_safe(_data[0], 0, 0);
|
||||
BLEND_NORMAL
|
||||
|
||||
surface_reset_target();
|
||||
|
||||
surface_free(pass1);
|
||||
surface_free(s);
|
||||
surface_set_shader(_outSurf, sh_glow);
|
||||
shader_set_dim("dimension", _data[0]);
|
||||
shader_set_i("mode", _mode);
|
||||
shader_set_f("border", _border);
|
||||
shader_set_f("size", _size);
|
||||
shader_set_f("strength", _strength);
|
||||
shader_set_color("color", _color);
|
||||
shader_set_i("render", _render);
|
||||
|
||||
draw_surface_safe(_data[0]);
|
||||
surface_reset_shader();
|
||||
|
||||
__process_mask_modifier(_data);
|
||||
_outSurf = mask_apply(_data[0], _outSurf, _data[5], _data[6]);
|
||||
|
|
|
@ -38,6 +38,7 @@ function Node_Smear(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
|
|||
inputs[| 12] = nodeValue("Modulate strength", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false)
|
||||
|
||||
inputs[| 13] = nodeValue("Spread", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
||||
.setDisplay(VALUE_DISPLAY.slider, { range : [ 0, 30, 1 ] });
|
||||
|
||||
input_display_list = [ 5, 6,
|
||||
["Surfaces", true], 0, 3, 4, 7, 8,
|
||||
|
|
|
@ -1,9 +1,66 @@
|
|||
//
|
||||
// Simple passthrough fragment shader
|
||||
//
|
||||
#define TAU 6.283185307179586
|
||||
|
||||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
||||
uniform vec2 dimension;
|
||||
uniform int mode;
|
||||
uniform float border;
|
||||
uniform float size;
|
||||
uniform float strength;
|
||||
uniform vec4 color;
|
||||
|
||||
uniform int render;
|
||||
|
||||
float bright(in vec4 col) { return dot(col.rgb, vec3(0.2126, 0.7152, 0.0722)) * col.a; }
|
||||
vec4 sample(vec2 pos) { return texture2D( gm_BaseTexture, pos ); }
|
||||
|
||||
float round(float val) { return fract(val) > 0.5? ceil(val) : floor(val); }
|
||||
vec2 round(vec2 val) { return vec2(round(val.x), round(val.y)); }
|
||||
|
||||
void main() {
|
||||
gl_FragColor = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord );
|
||||
vec2 tx = 1. / dimension;
|
||||
vec2 px = round(v_vTexcoord * dimension);
|
||||
|
||||
vec4 base = sample(v_vTexcoord);
|
||||
|
||||
if(render == 1) {
|
||||
gl_FragColor = base;
|
||||
} else {
|
||||
if(mode == 0) gl_FragColor = vec4(0., 0., 0., 1.);
|
||||
if(mode == 1) gl_FragColor = vec4(0., 0., 0., 0.);
|
||||
}
|
||||
|
||||
if(mode == 0 && base.rgb == vec3(1.)) return;
|
||||
if(mode == 1 && base.a == 1.) return;
|
||||
|
||||
float dist = 0.;
|
||||
float astp = max(64., size * 4.);
|
||||
|
||||
for(float i = 1.; i < size; i++)
|
||||
for(float j = 0.; j <= astp; j++) {
|
||||
float angle = j / astp * TAU;
|
||||
vec2 smPos = v_vTexcoord + vec2(cos(angle), sin(angle)) * i * tx;
|
||||
//vec2 smPx = round(smPos * dimension);
|
||||
//if(i < 4. && distance(px, smPx) > i) continue;
|
||||
|
||||
vec4 samp = sample(smPos);
|
||||
|
||||
if((mode == 0 && bright(samp) > bright(base)) || (mode == 1 && samp.a > base.a)) {
|
||||
dist = i;
|
||||
i = size;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(dist > 0.) {
|
||||
vec4 cc = color;
|
||||
float str = (1. - dist / size) * strength;
|
||||
|
||||
if(mode == 0) cc.rgb *= str;
|
||||
if(mode == 1) cc.a *= str;
|
||||
|
||||
if(render == 1) gl_FragColor = base + cc;
|
||||
else gl_FragColor = cc;
|
||||
}
|
||||
}
|
||||
|
|