mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-03-04 06:34:48 +01:00
[Normal Light] Now function without surface input as long as the normal map is provided.
This commit is contained in:
parent
dbcdf8f27d
commit
57dfbc66dd
7 changed files with 49 additions and 45 deletions
|
@ -7,11 +7,6 @@
|
|||
function Node_Edge_Detect(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
||||
name = "Edge Detect";
|
||||
|
||||
shader = sh_edge_detect;
|
||||
uniform_dim = shader_get_uniform(shader, "dimension");
|
||||
uniform_filter = shader_get_uniform(shader, "filter");
|
||||
uniform_sam = shader_get_uniform(shader, "sampleMode");
|
||||
|
||||
newInput(0, nodeValue_Surface("Surface in self", self));
|
||||
|
||||
newInput(1, nodeValue_Enum_Scroll("Algorithm", self, 0, ["Sobel", "Prewitt", "Laplacian", "Neighbor max diff"] ));
|
||||
|
@ -41,31 +36,26 @@ function Node_Edge_Detect(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
|
|||
attribute_surface_depth();
|
||||
attribute_oversample();
|
||||
|
||||
static step = function() { #region
|
||||
static step = function() {
|
||||
__step_mask_modifier();
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static processData = function(_outSurf, _data, _output_index, _array_index) {
|
||||
var ft = _data[1];
|
||||
var ov = getAttribute("oversample");
|
||||
var surf = _data[0];
|
||||
var filt = _data[1];
|
||||
var over = getAttribute("oversample");
|
||||
|
||||
surface_set_target(_outSurf);
|
||||
DRAW_CLEAR
|
||||
BLEND_OVERRIDE
|
||||
|
||||
shader_set(shader);
|
||||
shader_set_uniform_f_array_safe(uniform_dim, [surface_get_width_safe(_data[0]), surface_get_height_safe(_data[0])]);
|
||||
shader_set_uniform_i(uniform_filter, ft);
|
||||
shader_set_uniform_i(uniform_sam, ov);
|
||||
draw_surface_safe(_data[0]);
|
||||
shader_reset();
|
||||
|
||||
BLEND_NORMAL
|
||||
surface_reset_target();
|
||||
surface_set_shader(_outSurf, sh_edge_detect);
|
||||
shader_set_dim("dimension", surf);
|
||||
shader_set_i("filter", filt);
|
||||
shader_set_i("sampleMode", over);
|
||||
|
||||
draw_surface_safe(surf);
|
||||
surface_reset_shader();
|
||||
|
||||
__process_mask_modifier(_data);
|
||||
_outSurf = mask_apply(_data[0], _outSurf, _data[3], _data[4]);
|
||||
_outSurf = channel_apply(_data[0], _outSurf, _data[6]);
|
||||
_outSurf = mask_apply(surf, _outSurf, _data[3], _data[4]);
|
||||
_outSurf = channel_apply(surf, _outSurf, _data[6]);
|
||||
|
||||
return _outSurf;
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ function Node_Normal_Light(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
|
|||
}
|
||||
|
||||
lights_renderer = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus) {
|
||||
PROCESSOR_OVERLAY_CHECK
|
||||
|
||||
var bs = ui(24);
|
||||
var bx = _x + ui(20);
|
||||
|
@ -202,8 +203,9 @@ function Node_Normal_Light(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
|
|||
|
||||
static processData = function(_outData, _data, _output_index, _array_index) {
|
||||
var _surf = _data[0];
|
||||
var _norm = _data[1];
|
||||
var _amb = _data[3];
|
||||
var _dim = surface_get_dimension(_surf);
|
||||
var _dim = is_surface(_surf)? surface_get_dimension(_surf) : surface_get_dimension(_norm);
|
||||
|
||||
if(getInputAmount()) {
|
||||
dynamic_input_inspecting = clamp(dynamic_input_inspecting, 0, getInputAmount() - 1);
|
||||
|
|
|
@ -12,11 +12,13 @@ function Node_Threshold(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
|
||||
newInput(1, nodeValue_Bool("Brightness", self, false));
|
||||
|
||||
newInput(2, nodeValue_Float("Brightness Threshold", self, 0.5))
|
||||
newInput(2, nodeValue_Float("Threshold", self, 0.5))
|
||||
.setInternalName("Brightness Threshold")
|
||||
.setDisplay(VALUE_DISPLAY.slider)
|
||||
.setMappable(13);
|
||||
|
||||
newInput(3, nodeValue_Float("Brightness Smoothness", self, 0))
|
||||
newInput(3, nodeValue_Float("Smoothness", self, 0))
|
||||
.setInternalName("Brightness Smoothness")
|
||||
.setDisplay(VALUE_DISPLAY.slider);
|
||||
|
||||
newInput(4, nodeValue_Surface("Mask", self));
|
||||
|
@ -29,11 +31,13 @@ function Node_Threshold(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
|
||||
newInput(7, nodeValue_Bool("Alpha", self, false));
|
||||
|
||||
newInput(8, nodeValue_Float("Alpha Threshold", self, 0.5))
|
||||
newInput(8, nodeValue_Float("Threshold", self, 0.5))
|
||||
.setInternalName("Alpha Threshold")
|
||||
.setDisplay(VALUE_DISPLAY.slider)
|
||||
.setMappable(14);
|
||||
|
||||
newInput(9, nodeValue_Float("Alpha Smoothness", self, 0))
|
||||
newInput(9, nodeValue_Float("Smoothness", self, 0))
|
||||
.setInternalName("Alpha Smoothness")
|
||||
.setDisplay(VALUE_DISPLAY.slider);
|
||||
|
||||
newInput(10, nodeValue_Toggle("Channel", self, 0b1111, { data: array_create(4, THEME.inspector_channel) }));
|
||||
|
@ -52,15 +56,19 @@ function Node_Threshold(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
|
||||
newInput(16, nodeValue_Int("Adaptive Radius", self, 4))
|
||||
|
||||
newInput(17, nodeValue_Bool("Brightness Invert", self, false));
|
||||
newInput(17, nodeValue_Bool("Invert", self, false))
|
||||
.setInternalName("Brightness Invert");
|
||||
|
||||
newInput(18, nodeValue_Bool("Alpha Invert", self, false));
|
||||
newInput(18, nodeValue_Bool("Invert", self, false))
|
||||
.setInternalName("Alpha Invert");
|
||||
|
||||
newInput(19, nodeValue_Bool("Apply to Alpha", self, false))
|
||||
|
||||
newOutput(0, nodeValue_Output("Surface Out", self, VALUE_TYPE.surface, noone));
|
||||
|
||||
input_display_list = [ 6, 10,
|
||||
["Surfaces", true], 0, 4, 5, 11, 12,
|
||||
["Brightness", true, 1], 15, 2, 13, 3, 16, 17,
|
||||
["Brightness", true, 1], 15, 2, 13, 3, 16, 17, 19,
|
||||
["Alpha", true, 7], 8, 14, 9, 18,
|
||||
];
|
||||
|
||||
|
@ -90,6 +98,7 @@ function Node_Threshold(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
|
||||
var _brightInv = _data[17];
|
||||
var _alhpaInv = _data[18];
|
||||
var _brightAlp = _data[19];
|
||||
|
||||
inputs[16].setVisible(_algo == 1);
|
||||
|
||||
|
@ -105,6 +114,7 @@ function Node_Threshold(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
|||
shader_set_f("brightSmooth", _brightSmt);
|
||||
shader_set_f("adaptiveRadius", _adap_size);
|
||||
shader_set_f("gaussianCoeff", __gaussian_get_kernel(_adap_size));
|
||||
shader_set_i("brightAlpha", _brightAlp);
|
||||
|
||||
shader_set_i("alpha", _alph);
|
||||
shader_set_i("alphaInvert", _alhpaInv);
|
||||
|
|
|
@ -238,12 +238,17 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
if(connect_type == CONNECT_TYPE.input) node.inputMap[$ internalName] = self;
|
||||
else if(connect_type == CONNECT_TYPE.output) node.outputMap[$ internalName] = self;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static updateName = function(_name) {
|
||||
name = _name;
|
||||
name_custom = true;
|
||||
|
||||
setInternalName(name);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
updateName(_name);
|
||||
|
@ -297,16 +302,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
|
||||
////- NAME
|
||||
|
||||
static getName = function() {
|
||||
if(name_custom) return name;
|
||||
return __txt_junction_name(instanceof(node), connect_type, index, name);
|
||||
}
|
||||
static getName = function() /*=>*/ {return name_custom? name : __txt_junction_name(instanceof(node), connect_type, index, name)};
|
||||
|
||||
static setName = function(_name) {
|
||||
INLINE
|
||||
name = _name;
|
||||
return self;
|
||||
}
|
||||
static setName = function(_name) /*=>*/ { name = _name; return self; }
|
||||
|
||||
////- VALUE
|
||||
|
||||
|
|
|
@ -804,7 +804,7 @@ function Panel_Animation() : PanelContent() constructor {
|
|||
var bar_line_w = TOTAL_FRAMES * timeline_scale + timeline_shift;
|
||||
var bar_int_x = min(bar_x + bar_w, bar_x + bar_line_w);
|
||||
|
||||
if(pHOVER && point_in_rectangle(mx, my, bar_x, 16, bar_x + bar_w, bar_y - 8)) {
|
||||
if(pHOVER && point_in_rectangle(mx, my, bar_x, ui(16), bar_x + bar_w, bar_y - ui(8))) {
|
||||
var sca = timeline_scale;
|
||||
|
||||
if(mouse_wheel_down()) timeline_scale = max(timeline_scale - 1 * SCROLL_SPEED, 1);
|
||||
|
@ -2150,7 +2150,7 @@ function Panel_Animation() : PanelContent() constructor {
|
|||
if(key_hover == noone && value_hovering != noone) {
|
||||
var _kx = (_fr + 1) * timeline_scale + timeline_shift;
|
||||
var _ky = value_hovering.y;
|
||||
draw_sprite_ui_uniform(THEME.add, 0, _kx, _ky, .5, COLORS._main_value_positive, .5);
|
||||
draw_sprite_ui_uniform(THEME.add, 0, _kx, _ky, .5, COLORS._main_value_positive, 1);
|
||||
|
||||
if(mouse_press(mb_left, pFOCUS)) {
|
||||
var _nk = new valueKey(_fr, variable_clone(value_hovering.getValue(_fr)), value_hovering);
|
||||
|
|
|
@ -7,6 +7,7 @@ uniform vec2 brightThreshold;
|
|||
uniform int brightThresholdUseSurf;
|
||||
uniform sampler2D brightThresholdSurf;
|
||||
uniform float brightSmooth;
|
||||
uniform int brightAlpha;
|
||||
|
||||
uniform int alpha;
|
||||
uniform int alphaInvert;
|
||||
|
@ -37,7 +38,8 @@ void main() {
|
|||
float vBright = brightSmooth == 0.? _step(bri, cbright) : smoothstep(bri - brightSmooth, bri + brightSmooth, cbright);
|
||||
if(brightInvert == 1) vBright = 1. - vBright;
|
||||
|
||||
col.rgb = vec3(vBright);
|
||||
if(brightAlpha == 0) col.rgb = vec3(vBright);
|
||||
else col = vec4(col.rgb, vBright);
|
||||
}
|
||||
|
||||
if(alpha == 1) {
|
||||
|
|
|
@ -11,6 +11,7 @@ uniform int brightThresholdUseSurf;
|
|||
uniform sampler2D brightThresholdSurf;
|
||||
uniform float brightSmooth;
|
||||
uniform float adaptiveRadius;
|
||||
uniform int brightAlpha;
|
||||
|
||||
uniform int alpha;
|
||||
uniform int alphaInvert;
|
||||
|
@ -54,7 +55,8 @@ void main() {
|
|||
float _res = brightSmooth == 0.? _step(bNeight, cbright) : smoothstep(bNeight - brightSmooth, bNeight + brightSmooth, cbright);
|
||||
if(brightInvert == 1) _res = 1. - _res;
|
||||
|
||||
col.rgb = vec3(_res);
|
||||
if(brightAlpha == 0) col.rgb = vec3(_res);
|
||||
else col = vec4(col.rgb, _res);
|
||||
}
|
||||
|
||||
if(alpha == 1) {
|
||||
|
|
Loading…
Add table
Reference in a new issue