mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-24 14:06:23 +01:00
3D shadow mapping fix and several other things.
This commit is contained in:
parent
67834398b4
commit
bb2bbd2fb4
20 changed files with 199 additions and 110 deletions
|
@ -296,8 +296,21 @@ event_inherited();
|
|||
}
|
||||
BLEND_NORMAL
|
||||
|
||||
var cc = COLORS._main_text_inner;
|
||||
|
||||
switch(name) {
|
||||
case "All" :
|
||||
case "New" :
|
||||
case "Favourites" :
|
||||
case "Action" :
|
||||
case "Custom" :
|
||||
case "Extra" :
|
||||
cc = COLORS._main_text_sub;
|
||||
break;
|
||||
}
|
||||
|
||||
if(i == ADD_NODE_PAGE) draw_set_text(f_p0b, fa_left, fa_center, COLORS._main_text_accent);
|
||||
else draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text_inner);
|
||||
else draw_set_text(f_p0, fa_left, fa_center, cc);
|
||||
|
||||
var _is_extra = name == "Extra";
|
||||
name = __txt(name);
|
||||
|
@ -314,7 +327,7 @@ event_inherited();
|
|||
draw_sprite_ext(s_patreon_supporter, 0, _cx, _cy, 1, 1, 0, _hov? COLORS._main_icon_dark : COLORS.panel_bg_clear, 1);
|
||||
gpu_set_colorwriteenable(1, 1, 1, 1);
|
||||
|
||||
draw_sprite_ext(s_patreon_supporter, 1, _cx, _cy, 1, 1, 0, i == ADD_NODE_PAGE? COLORS._main_text_accent : COLORS._main_text_inner, 1);
|
||||
draw_sprite_ext(s_patreon_supporter, 1, _cx, _cy, 1, 1, 0, i == ADD_NODE_PAGE? COLORS._main_text_accent : cc, 1);
|
||||
}
|
||||
|
||||
hh += hg;
|
||||
|
|
|
@ -22,8 +22,9 @@ if(!MOUSE_WRAPPING) {
|
|||
var _ady = slide_dy - mouse_my;
|
||||
|
||||
var _s = tb.slide_speed;
|
||||
if(key_mod_press(CTRL)) _s *= 10;
|
||||
if(key_mod_press(ALT)) _s /= 10;
|
||||
var sc = 10;
|
||||
if(key_mod_press(CTRL)) _s *= sc;
|
||||
if(key_mod_press(ALT)) _s /= sc;
|
||||
|
||||
var spd = (slide_da? _ady : _adx) * _s;
|
||||
var _val = value_snap(tb.slide_sv + spd, _s);
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
|
||||
METADATA = __getdefaultMetaData();
|
||||
APP_LOCATION = program_directory;
|
||||
if(string_pos("GameMakerStudio2\\Cache\\runtimes", APP_LOCATION))
|
||||
APP_LOCATION = working_directory;
|
||||
//print($"===================== WORKING DIRECTORIES =====================\n\t{working_directory}\n\t{DIRECTORY}");
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -246,8 +246,7 @@ function BBMOD_Quaternion(_x=0.0, _y=0.0, _z=0.0, _w=1.0) constructor
|
|||
_forward = new BBMOD_Vec3(_forward);
|
||||
_up = new BBMOD_Vec3(_up);
|
||||
|
||||
if (!_forward.Orthonormalize(_up))
|
||||
{
|
||||
if (!_forward.Orthonormalize(_up)) {
|
||||
X = 0.0;
|
||||
Y = 0.0;
|
||||
Z = 0.0;
|
||||
|
@ -257,7 +256,7 @@ function BBMOD_Quaternion(_x=0.0, _y=0.0, _z=0.0, _w=1.0) constructor
|
|||
|
||||
var _right = _up.Cross(_forward);
|
||||
var _w = sqrt(abs(1.0 + _right.X + _up.Y + _forward.Z)) * 0.5;
|
||||
var _w4Recip = 1.0 / (4.0 * _w);
|
||||
var _w4Recip = _w == 0? 0 : 1.0 / (4.0 * _w);
|
||||
|
||||
X = (_up.Z - _forward.Y) * _w4Recip;
|
||||
Y = (_forward.X - _right.Z) * _w4Recip;
|
||||
|
@ -309,7 +308,7 @@ function BBMOD_Quaternion(_x=0.0, _y=0.0, _z=0.0, _w=1.0) constructor
|
|||
/// @return {Struct.BBMOD_Quaternion} The created quaternion.
|
||||
static Inverse = function () {
|
||||
INLINE
|
||||
return Conjugate().Scale(1.0 / Length());
|
||||
return Length() == 0? new BBMOD_Quaternion() : Conjugate().Scale(1.0 / Length());
|
||||
};
|
||||
|
||||
/// @func Length()
|
||||
|
@ -412,6 +411,7 @@ function BBMOD_Quaternion(_x=0.0, _y=0.0, _z=0.0, _w=1.0) constructor
|
|||
static Normalize = function () {
|
||||
INLINE
|
||||
var _lengthSqr = LengthSqr();
|
||||
|
||||
if(_lengthSqr == 0)
|
||||
return new BBMOD_Quaternion();
|
||||
|
||||
|
@ -628,6 +628,8 @@ function BBMOD_Quaternion(_x=0.0, _y=0.0, _z=0.0, _w=1.0) constructor
|
|||
|
||||
_dest ??= matrix_build_identity();
|
||||
|
||||
if(is_nan(X)) return _dest;
|
||||
|
||||
var _norm = Normalize();
|
||||
|
||||
var _temp0, _temp1, _temp2;
|
||||
|
|
|
@ -1,26 +1,29 @@
|
|||
function colorFromRGBArray(arr) {
|
||||
function colorFromRGBArray(arr) { #region
|
||||
var r = round(real(arr[0]) * 255);
|
||||
var g = round(real(arr[1]) * 255);
|
||||
var b = round(real(arr[2]) * 255);
|
||||
return make_color_rgb(r, g, b);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
function color_get_alpha(color) {
|
||||
function color_get_alpha(color) { #region
|
||||
INLINE
|
||||
return (color & (0xFF << 24)) >> 24;
|
||||
}
|
||||
} #endregion
|
||||
|
||||
function colorArrayFromReal(clr) {
|
||||
function colorArrayFromReal(clr) { #region
|
||||
INLINE
|
||||
return [color_get_red(clr) / 255, color_get_green(clr) / 255, color_get_blue(clr) / 255 ];
|
||||
}
|
||||
} #endregion
|
||||
|
||||
function colorBrightness(clr, normalize = true) {
|
||||
function colorBrightness(clr, normalize = true) { #region
|
||||
INLINE
|
||||
var r2 = color_get_red(clr) / (normalize? 255 : 1);
|
||||
var g2 = color_get_green(clr) / (normalize? 255 : 1);
|
||||
var b2 = color_get_blue(clr) / (normalize? 255 : 1);
|
||||
return 0.299 * r2 + 0.587 * g2 + 0.224 * b2;
|
||||
}
|
||||
} #endregion
|
||||
|
||||
function colorMultiply(c1, c2) {
|
||||
function colorMultiply(c1, c2) { #region
|
||||
if(c1 * c2 == 0) return 0;
|
||||
if(c1 == c_white) return c2;
|
||||
if(c2 == c_white) return c1;
|
||||
|
@ -34,9 +37,9 @@ function colorMultiply(c1, c2) {
|
|||
var b2 = color_get_blue(c2);
|
||||
|
||||
return make_color_rgb((r1 * r2) / 255, (g1 * g2) / 255, (b1 * b2) / 255);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
function colorAdd(c1, c2) {
|
||||
function colorAdd(c1, c2) { #region
|
||||
if(c1 == 0) return c2;
|
||||
if(c2 == 0) return c1;
|
||||
|
||||
|
@ -49,9 +52,9 @@ function colorAdd(c1, c2) {
|
|||
var b2 = color_get_blue(c2);
|
||||
|
||||
return make_color_rgb(min(r1 + r2, 255), min(g1 + g2, 255), min(b1 + b2, 255));
|
||||
}
|
||||
} #endregion
|
||||
|
||||
function color_diff(c1, c2, fast = false, alpha = false) {
|
||||
function color_diff(c1, c2, fast = false, alpha = false) { #region
|
||||
var _c1_r = color_get_red(c1);
|
||||
var _c1_g = color_get_green(c1);
|
||||
var _c1_b = color_get_blue(c1);
|
||||
|
@ -74,13 +77,17 @@ function color_diff(c1, c2, fast = false, alpha = false) {
|
|||
|
||||
if(fast) return abs(_c1_r - _c2_r) + abs(_c1_g - _c2_g) + abs(_c1_b - _c2_b) + abs(_c1_a - _c2_a);
|
||||
return sqrt(sqr(_c1_r - _c2_r) + sqr(_c1_g - _c2_g) + sqr(_c1_b - _c2_b) + sqr(_c1_a - _c2_a));
|
||||
}
|
||||
} #endregion
|
||||
|
||||
function color_get_brightness(col) {
|
||||
function color_get_brightness(col) { #region
|
||||
INLINE
|
||||
|
||||
return (0.299 * color_get_red(col) + 0.587 * color_get_green(col) + 0.114 * color_get_blue(col)) / 255;
|
||||
}
|
||||
} #endregion
|
||||
|
||||
function color_rgb(col) { #region
|
||||
INLINE
|
||||
return [ color_get_red(col) / 255, color_get_green(col) / 255, color_get_blue(col) / 255 ];
|
||||
} #endregion
|
||||
|
||||
#region sorting functions
|
||||
function __valHSV(c, h, s, v) { return color_get_hue(c) * h + color_get_saturation(c) * s + color_get_value(c) * v; }
|
||||
|
|
|
@ -45,7 +45,9 @@ function __3dCamera_object() : __3dObject() constructor {
|
|||
function d3d_PolarToCart(camFx, camFy, camFz, camAx, camAy, camDist) {
|
||||
var pos = new __vec3();
|
||||
|
||||
if(camAy % 90 == 0) camAy += 0.01;
|
||||
if(camAy % 90 == 0) camAy += 0.1;
|
||||
if(camAx % 90 == 0) camAx += 0.1;
|
||||
|
||||
var radAx = degtorad(camAx);
|
||||
var radAy = degtorad(camAy);
|
||||
|
||||
|
|
|
@ -216,8 +216,10 @@ function __3dScene(camera, name = "New scene") constructor {
|
|||
shader_set_f("light_dir_color", lightDir_color);
|
||||
shader_set_f("light_dir_intensity", lightDir_intensity);
|
||||
shader_set_i("light_dir_shadow_active", lightDir_shadow);
|
||||
for( var i = 0, n = array_length(lightDir_shadowMap); i < n; i++ )
|
||||
shader_set_surface($"light_dir_shadowmap_{i}", lightDir_shadowMap[i], true);
|
||||
for( var i = 0, n = array_length(lightDir_shadowMap); i < n; i++ ) {
|
||||
var _sid = shader_set_surface($"light_dir_shadowmap_{i}", lightDir_shadowMap[i], true);
|
||||
gpu_set_tex_repeat_ext(_sid, false);
|
||||
}
|
||||
shader_set_f("light_dir_view", lightDir_viewMat);
|
||||
shader_set_f("light_dir_proj", lightDir_projMat);
|
||||
shader_set_f("light_dir_shadow_bias", lightDir_shadowBias);
|
||||
|
@ -230,8 +232,10 @@ function __3dScene(camera, name = "New scene") constructor {
|
|||
shader_set_f("light_pnt_intensity", lightPnt_intensity);
|
||||
shader_set_f("light_pnt_radius", lightPnt_radius);
|
||||
shader_set_i("light_pnt_shadow_active", lightPnt_shadow);
|
||||
for( var i = 0, n = array_length(lightPnt_shadowMap); i < n; i++ )
|
||||
shader_set_surface($"light_pnt_shadowmap_{i}", lightPnt_shadowMap[i], true, true);
|
||||
for( var i = 0, n = array_length(lightPnt_shadowMap); i < n; i++ ) {
|
||||
var _sid = shader_set_surface($"light_pnt_shadowmap_{i}", lightPnt_shadowMap[i], true, true);
|
||||
gpu_set_tex_repeat_ext(_sid, false);
|
||||
}
|
||||
shader_set_f("light_pnt_view", lightPnt_viewMat);
|
||||
shader_set_f("light_pnt_proj", lightPnt_projMat);
|
||||
shader_set_f("light_pnt_shadow_bias", lightPnt_shadowBias);
|
||||
|
|
|
@ -261,8 +261,7 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
|
|||
camera.up = camera.getUp()._multiply(-1);
|
||||
|
||||
var _for = camera.focus.subtract(camera.position);
|
||||
if(!_for.isZero())
|
||||
camera.rotation = new BBMOD_Quaternion().FromLookRotation(_for, camera.up.multiply(-1)).Mul(_qi1).Mul(_qi3);
|
||||
if(!_for.isZero()) camera.rotation = new BBMOD_Quaternion().FromLookRotation(_for, camera.up.multiply(-1)).Mul(_qi1).Mul(_qi3);
|
||||
|
||||
lookat.transform.position.set(_look);
|
||||
lookLine = new __3dGizmoLineDashed(camera.position, camera.focus, 0.25, c_gray, 1);
|
||||
|
|
|
@ -21,7 +21,30 @@ function Node_3D_Light_Directional(_x, _y, _group = noone) : Node_3D_Light(_x, _
|
|||
tool_settings = [];
|
||||
tool_attribute.context = 1;
|
||||
|
||||
static processData = function(_output, _data, _output_index, _array_index = 0) {
|
||||
//static drawOverlay3D = function(active, params, _mx, _my, _snx, _sny, _panel) { #region
|
||||
// var object = getObject(0);
|
||||
// var _outSurf = object.shadow_map;
|
||||
|
||||
// if(!is_surface(_outSurf)) return;
|
||||
|
||||
// var _w = _panel.w;
|
||||
// var _h = _panel.h - _panel.toolbar_height;
|
||||
// var _pw = surface_get_width_safe(_outSurf);
|
||||
// var _ph = surface_get_height_safe(_outSurf);
|
||||
// var _ps = min(128 / _ph, 160 / _pw);
|
||||
|
||||
// var _pws = _pw * _ps;
|
||||
// var _phs = _ph * _ps;
|
||||
|
||||
// var _px = _w - 16 - _pws;
|
||||
// var _py = _h - 16 - _phs;
|
||||
|
||||
// draw_surface_ext_safe(_outSurf, _px, _py, _ps, _ps);
|
||||
// draw_set_color(COLORS._main_icon);
|
||||
// draw_rectangle(_px, _py, _px + _pws, _py + _phs, true);
|
||||
//} #endregion
|
||||
|
||||
static processData = function(_output, _data, _output_index, _array_index = 0) { #region
|
||||
var _active = _data[in_d3d + 0];
|
||||
if(!_active) return noone;
|
||||
|
||||
|
@ -41,5 +64,5 @@ function Node_3D_Light_Directional(_x, _y, _group = noone) : Node_3D_Light(_x, _
|
|||
object.transform.rotation.FromEuler(_rot.x, _rot.y, _rot.z);
|
||||
|
||||
return object;
|
||||
}
|
||||
} #endregion
|
||||
}
|
|
@ -21,7 +21,7 @@ function Node_3D_Light_Point(_x, _y, _group = noone) : Node_3D_Light(_x, _y, _gr
|
|||
tool_settings = [];
|
||||
tool_attribute.context = 1;
|
||||
|
||||
static processData = function(_output, _data, _output_index, _array_index = 0) {
|
||||
static processData = function(_output, _data, _output_index, _array_index = 0) { #region
|
||||
var _active = _data[in_d3d + 0];
|
||||
if(!_active) return noone;
|
||||
|
||||
|
@ -39,10 +39,5 @@ function Node_3D_Light_Point(_x, _y, _group = noone) : Node_3D_Light(_x, _y, _gr
|
|||
object.shadow_bias = _shadow_bias;
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
//static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
||||
// var object = getObject(0);
|
||||
// draw_surface_stretched_safe(object.shadow_map, xx, yy, 96, 96);
|
||||
//}
|
||||
} #endregion
|
||||
}
|
|
@ -244,4 +244,6 @@ function __Node_Cache(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
|
||||
draw_set_alpha(1);
|
||||
} #endregion
|
||||
|
||||
static onDestroy = function() { enableNodeGroup(); }
|
||||
}
|
|
@ -38,7 +38,7 @@ function Node_Camera(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
|
|||
|
||||
temp_surface = [ noone, noone ];
|
||||
|
||||
static createNewInput = function() {
|
||||
static createNewInput = function() { #region
|
||||
var index = ds_list_size(inputs);
|
||||
var _s = floor((index - input_fix_len) / data_length);
|
||||
|
||||
|
@ -52,10 +52,9 @@ function Node_Camera(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
|
|||
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Empty", "Repeat", "Repeat X", "Repeat Y" ]);
|
||||
|
||||
array_append(input_display_list, [ index + 0, index + 1, index + 2 ]);
|
||||
}
|
||||
if(!LOADING && !APPENDING) createNewInput();
|
||||
} if(!LOADING && !APPENDING) createNewInput(); #endregion
|
||||
|
||||
static refreshDynamicInput = function() {
|
||||
static refreshDynamicInput = function() { #region
|
||||
var _in = ds_list_create();
|
||||
|
||||
for( var i = 0; i < input_fix_len; i++ )
|
||||
|
@ -86,18 +85,18 @@ function Node_Camera(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
|
|||
inputs = _in;
|
||||
|
||||
createNewInput();
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static onValueFromUpdate = function(index) {
|
||||
static onValueFromUpdate = function(index) { #region
|
||||
if(index < input_fix_len) return;
|
||||
if(LOADING || APPENDING) return;
|
||||
|
||||
refreshDynamicInput();
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static getPreviewValues = function() { return getInputData(0); }
|
||||
|
||||
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
||||
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
|
||||
if(array_length(current_data) == 0) return;
|
||||
|
||||
var _out = outputs[| 0].getValue();
|
||||
|
@ -117,9 +116,9 @@ function Node_Camera(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
|
|||
var y1 = y0 + _area[3] * 2 * _zoom * _s;
|
||||
|
||||
draw_rectangle_dashed(x0, y0, x1, y1);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static processData = function(_outSurf, _data, _output_index, _array_index) {
|
||||
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
|
||||
if(!is_surface(_data[0])) return;
|
||||
var _area = _data[1];
|
||||
var _zoom = _data[2];
|
||||
|
@ -223,5 +222,5 @@ function Node_Camera(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
|
|||
surface_reset_target();
|
||||
|
||||
return _outSurf;
|
||||
}
|
||||
} #endregion
|
||||
}
|
|
@ -595,19 +595,28 @@ function Node(_x, _y, _group = PANEL_GRAPH.getCurrentContext()) : __Node_Base(_x
|
|||
LOG_BLOCK_END();
|
||||
} #endregion
|
||||
|
||||
static cacheCheck = function() { #region
|
||||
INLINE
|
||||
|
||||
if(cache_group) cache_group.enableNodeGroup();
|
||||
if(group != noone) group.cacheCheck();
|
||||
} #endregion
|
||||
|
||||
static valueUpdate = function(index) { #region
|
||||
if(error_update_enabled && error_noti_update == noone)
|
||||
error_noti_update = noti_error(getFullName() + " node require manual execution.",, self);
|
||||
|
||||
onValueUpdate(index);
|
||||
if(cache_group) cache_group.enableNodeGroup();
|
||||
|
||||
if(is_dynamic_input) will_setHeight = true;
|
||||
cacheCheck();
|
||||
} #endregion
|
||||
|
||||
static valueFromUpdate = function(index) { #region
|
||||
onValueFromUpdate(index);
|
||||
if(cache_group) cache_group.enableNodeGroup();
|
||||
|
||||
if(is_dynamic_input) will_setHeight = true;
|
||||
cacheCheck();
|
||||
} #endregion
|
||||
|
||||
static onValueUpdate = function(index = 0) {}
|
||||
|
|
|
@ -741,6 +741,7 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
|
||||
if(render_process_id != 0) {
|
||||
var res = ProcIdExists(render_process_id);
|
||||
|
||||
if(res == 0) {
|
||||
var noti = log_message("EXPORT", $"Export {render_type} as {render_target}", THEME.noti_icon_tick, COLORS._main_value_positive, false);
|
||||
noti.path = filename_dir(render_target);
|
||||
|
@ -749,6 +750,9 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
|||
render_process_id = 0;
|
||||
|
||||
array_remove(RENDERING, node_id);
|
||||
} else {
|
||||
//var stdOut = ExecutedProcessReadFromStandardOutput(render_process_id);
|
||||
//print(stdOut);
|
||||
}
|
||||
}
|
||||
} #endregion
|
||||
|
|
|
@ -14,6 +14,10 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node(_x, _y, _group) con
|
|||
.setDisplay(VALUE_DISPLAY.enum_scroll, { data: [ "K-mean", "Frequency", "All colors" ], update_hover: false })
|
||||
.rejectArray();
|
||||
|
||||
inputs[| 4] = nodeValue("Color Space", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1)
|
||||
.setDisplay(VALUE_DISPLAY.enum_scroll, { data: [ "RGB", "HSV" ], update_hover: false })
|
||||
.rejectArray();
|
||||
|
||||
outputs[| 0] = nodeValue("Palette", self, JUNCTION_CONNECT.output, VALUE_TYPE.color, [ ])
|
||||
.setDisplay(VALUE_DISPLAY.palette);
|
||||
|
||||
|
@ -21,7 +25,7 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node(_x, _y, _group) con
|
|||
|
||||
input_display_list = [
|
||||
["Surfaces", true], 0,
|
||||
["Palette", false], 3, 1, 2,
|
||||
["Palette", false], 3, 4, 1, 2,
|
||||
]
|
||||
|
||||
current_palette = [];
|
||||
|
@ -29,7 +33,7 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node(_x, _y, _group) con
|
|||
|
||||
attribute_surface_depth();
|
||||
|
||||
function sortPalette(pal) {
|
||||
function sortPalette(pal) { #region
|
||||
array_sort(pal, function(c0, c1) {
|
||||
var r0 = color_get_red(c0) / 255;
|
||||
var r1 = color_get_red(c1) / 255;
|
||||
|
@ -56,23 +60,19 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node(_x, _y, _group) con
|
|||
|
||||
return s0 * v0 > s1 * v1;
|
||||
})
|
||||
}
|
||||
} #endregion
|
||||
|
||||
function extractKmean(_surfFull, _size, _seed) {
|
||||
var _surf = surface_create_valid(min(32, surface_get_width_safe(_surfFull)), min(32, surface_get_height_safe(_surfFull)), attrDepth());
|
||||
function extractKmean(_surfFull, _size, _seed) { #region
|
||||
var _space = getInputData(4);
|
||||
var _surf = surface_create_valid(min(32, surface_get_width_safe(_surfFull)), min(32, surface_get_height_safe(_surfFull)), attrDepth());
|
||||
_size = max(1, _size);
|
||||
|
||||
var ww = surface_get_width_safe(_surf);
|
||||
var hh = surface_get_height_safe(_surf);
|
||||
|
||||
surface_set_target(_surf);
|
||||
DRAW_CLEAR
|
||||
BLEND_OVERRIDE;
|
||||
gpu_set_texfilter(true);
|
||||
draw_surface_stretched_safe(_surfFull, 0, 0, ww, hh);
|
||||
gpu_set_texfilter(false);
|
||||
BLEND_NORMAL;
|
||||
surface_reset_target();
|
||||
surface_set_shader(_surf, noone);
|
||||
draw_surface_stretched_safe(_surfFull, 0, 0, ww, hh);
|
||||
surface_reset_shader();
|
||||
|
||||
var c_buffer = buffer_create(ww * hh * 4, buffer_fixed, 2);
|
||||
var colors = [];
|
||||
|
@ -82,14 +82,20 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node(_x, _y, _group) con
|
|||
|
||||
var _min = [ 1, 1, 1 ];
|
||||
var _max = [ 0, 0, 0 ];
|
||||
var a, b, c, col;
|
||||
|
||||
for( var i = 0; i < ww * hh; i++ ) {
|
||||
var b = buffer_read(c_buffer, buffer_u32);
|
||||
var c = b & ~(0b11111111 << 24);
|
||||
var a = b & (0b11111111 << 24);
|
||||
b = buffer_read(c_buffer, buffer_u32);
|
||||
c = b & ~(0b11111111 << 24);
|
||||
a = b & (0b11111111 << 24);
|
||||
if(a == 0) continue;
|
||||
|
||||
var col = [ color_get_hue(c) / 255, color_get_saturation(c) / 255, color_get_value(c) / 255, 0 ];
|
||||
switch(_space) {
|
||||
case 0 : col = [ color_get_red(c) / 255, color_get_green(c) / 255, color_get_blue(c) / 255, 0 ]; break;
|
||||
case 1 : col = [ color_get_hue(c) / 255, color_get_saturation(c) / 255, color_get_value(c) / 255, 0 ]; break;
|
||||
case 2 : col = [ color_get_hue(c) / 255, color_get_saturation(c) / 255, color_get_value(c) / 255, 0 ]; break;
|
||||
}
|
||||
|
||||
array_push(colors, col);
|
||||
for( var j = 0; j < 3; j++ ) {
|
||||
_min[j] = min(_min[j], col[j]);
|
||||
|
@ -155,6 +161,7 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node(_x, _y, _group) con
|
|||
}
|
||||
|
||||
var palette = [];
|
||||
var clr;
|
||||
|
||||
for( var i = 0; i < _size; i++ ) {
|
||||
var closet = 0;
|
||||
|
@ -171,18 +178,22 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node(_x, _y, _group) con
|
|||
}
|
||||
}
|
||||
|
||||
var clr = make_color_hsv(colors[closet][0] * 255, colors[closet][1] * 255, colors[closet][2] * 255);
|
||||
if(!array_exists(palette, clr))
|
||||
array_push(palette, clr);
|
||||
switch(_space) {
|
||||
case 0 : clr = make_color_rgb(colors[closet][0] * 255, colors[closet][1] * 255, colors[closet][2] * 255); break;
|
||||
case 1 : clr = make_color_hsv(colors[closet][0] * 255, colors[closet][1] * 255, colors[closet][2] * 255); break;
|
||||
case 2 : clr = make_color_hsv(colors[closet][0] * 255, colors[closet][1] * 255, colors[closet][2] * 255); break;
|
||||
}
|
||||
|
||||
array_push_unique(palette, clr);
|
||||
}
|
||||
|
||||
surface_free(_surf);
|
||||
sortPalette(palette);
|
||||
|
||||
return palette;
|
||||
}
|
||||
} #endregion
|
||||
|
||||
function extractAll(_surfFull) {
|
||||
function extractAll(_surfFull) { #region
|
||||
var ww = surface_get_width_safe(_surfFull);
|
||||
var hh = surface_get_height_safe(_surfFull);
|
||||
|
||||
|
@ -205,9 +216,9 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node(_x, _y, _group) con
|
|||
|
||||
buffer_delete(c_buffer);
|
||||
return palette;
|
||||
}
|
||||
} #endregion
|
||||
|
||||
function extractFrequence(_surfFull, _size) {
|
||||
function extractFrequence(_surfFull, _size) { #region
|
||||
var msize = 128;
|
||||
var _surf = surface_create_valid(min(msize, surface_get_width_safe(_surfFull)), min(msize, surface_get_height_safe(_surfFull)));
|
||||
_size = max(1, _size);
|
||||
|
@ -262,16 +273,17 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node(_x, _y, _group) con
|
|||
ds_priority_destroy(pr);
|
||||
ds_map_destroy(clrs);
|
||||
return palette;
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static step = function() {
|
||||
static step = function() { #region
|
||||
var _algo = getInputData(3);
|
||||
|
||||
inputs[| 1].setVisible(_algo != 2);
|
||||
inputs[| 2].setVisible(_algo == 0);
|
||||
}
|
||||
inputs[| 4].setVisible(_algo == 0);
|
||||
} #endregion
|
||||
|
||||
static extractPalette = function(_surf, _algo, _size, _seed) {
|
||||
static extractPalette = function(_surf, _algo, _size, _seed) { #region
|
||||
if(!is_surface(_surf)) return [];
|
||||
|
||||
switch(_algo) {
|
||||
|
@ -281,9 +293,9 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node(_x, _y, _group) con
|
|||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static extractPalettes = function() {
|
||||
static extractPalettes = function() { #region
|
||||
var _surf = getInputData(0);
|
||||
var _size = getInputData(1);
|
||||
var _seed = getInputData(2);
|
||||
|
@ -299,20 +311,18 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node(_x, _y, _group) con
|
|||
}
|
||||
|
||||
outputs[| 0].setValue(res);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static onInspector1Update = function() { extractPalettes(); triggerRender(); }
|
||||
static onValueUpdate = function() { extractPalettes(); }
|
||||
static onValueFromUpdate = function() { extractPalettes(); }
|
||||
static onValueUpdate = function() { extractPalettes(); }
|
||||
static onValueFromUpdate = function() { extractPalettes(); }
|
||||
|
||||
static update = function() {
|
||||
extractPalettes();
|
||||
}
|
||||
static update = function() { extractPalettes(); }
|
||||
|
||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
|
||||
var bbox = drawGetBbox(xx, yy, _s);
|
||||
if(bbox.h < 1) return;
|
||||
|
||||
drawPalette(outputs[| 0].getValue(), bbox.x0, bbox.y0, bbox.w, bbox.h);
|
||||
}
|
||||
} #endregion
|
||||
}
|
|
@ -92,6 +92,8 @@ function shader_set_surface(sampler, surface, linear = false, _repeat = false) {
|
|||
texture_set_stage(t, surface_get_texture(surface));
|
||||
gpu_set_tex_filter_ext(t, linear);
|
||||
gpu_set_tex_repeat_ext(t, _repeat);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
//function shader_set_surface_ext(sampler, surface, linear = false, _repeat = false) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
function string_hexadecimal(str){
|
||||
function string_hexadecimal(str) {
|
||||
static HEX = "0123456789ABCDEF";
|
||||
|
||||
var i = string_length(str);
|
||||
|
|
|
@ -307,8 +307,9 @@ function surface_size_lim(surface, width, height) {
|
|||
}
|
||||
|
||||
function surface_size_to(surface, width, height, format = noone, skipCheck = false) {
|
||||
if(!skipCheck && !is_surface(surface)) return surface;
|
||||
if(width < 1 && height < 1) return surface;
|
||||
if(!skipCheck && !is_surface(surface)) return surface;
|
||||
if(!is_numeric(width) || !is_numeric(height)) return surface;
|
||||
if(width < 1 && height < 1) return surface;
|
||||
|
||||
if(format != noone && format != surface_get_format(surface)) {
|
||||
surface_free(surface);
|
||||
|
|
|
@ -224,6 +224,15 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor {
|
|||
if(keyboard_check_pressed(vk_left)) onKey(vk_left);
|
||||
if(keyboard_check_pressed(vk_right)) onKey(vk_right);
|
||||
|
||||
if(input == TEXTBOX_INPUT.number) {
|
||||
var _inc = 1;
|
||||
if(key_mod_press(CTRL)) _inc *= 10;
|
||||
if(key_mod_press(ALT)) _inc /= 10;
|
||||
|
||||
if(KEYBOARD_PRESSED == vk_up || keyboard_check_pressed(vk_up)) { _input_text = string(toNumber(_input_text) + _inc); apply(); }
|
||||
if(KEYBOARD_PRESSED == vk_down || keyboard_check_pressed(vk_down)) { _input_text = string(toNumber(_input_text) - _inc); apply(); }
|
||||
}
|
||||
|
||||
if(keyboard_check_pressed(vk_home)) {
|
||||
if(key_mod_press(SHIFT)) {
|
||||
if(cursor_select == -1)
|
||||
|
|
|
@ -221,14 +221,17 @@ void main() {
|
|||
float v_lightDistance = screenSpace.z / screenSpace.w;
|
||||
vec2 lightMapPosition = (screenSpace.xy / screenSpace.w * 0.5) + 0.5;
|
||||
|
||||
light_map_depth = sampleDirShadowMap(shadow_map_index, lightMapPosition);
|
||||
shadow_map_index++;
|
||||
lightDistance = v_lightDistance;
|
||||
float shadowFactor = dot(normal, lightVector);
|
||||
float bias = mix(light_dir_shadow_bias[i], 0., shadowFactor);
|
||||
if(lightMapPosition.x >= 0. && lightMapPosition.x <= 1. && lightMapPosition.y >= 0. && lightMapPosition.y <= 1.) {
|
||||
light_map_depth = sampleDirShadowMap(shadow_map_index, lightMapPosition);
|
||||
|
||||
if(lightDistance > light_map_depth + bias)
|
||||
continue;
|
||||
shadow_map_index++;
|
||||
lightDistance = v_lightDistance;
|
||||
float shadowFactor = dot(normal, lightVector);
|
||||
float bias = mix(light_dir_shadow_bias[i], 0., shadowFactor);
|
||||
|
||||
if(lightDistance > light_map_depth + bias)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
vec3 light_phong = phongLight(normal, lightVector, viewDirection, light_dir_color[i].rgb);
|
||||
|
@ -264,14 +267,16 @@ void main() {
|
|||
float v_lightDistance = screenSpace.z / screenSpace.w;
|
||||
vec2 lightMapPosition = (screenSpace.xy / screenSpace.w * 0.5) + 0.5;
|
||||
|
||||
float shadowFactor = dot(normal, lightVector);
|
||||
float bias = mix(light_pnt_shadow_bias[i], 0., shadowFactor);
|
||||
if(lightMapPosition.x >= 0. && lightMapPosition.x <= 1. && lightMapPosition.y >= 0. && lightMapPosition.y <= 1.) {
|
||||
float shadowFactor = dot(normal, lightVector);
|
||||
float bias = mix(light_pnt_shadow_bias[i], 0., shadowFactor);
|
||||
|
||||
light_map_depth = samplePntShadowMap(shadow_map_index, lightMapPosition, side);
|
||||
shadow_map_index++;
|
||||
light_map_depth = samplePntShadowMap(shadow_map_index, lightMapPosition, side);
|
||||
shadow_map_index++;
|
||||
|
||||
if(v_lightDistance > light_map_depth + bias)
|
||||
continue;
|
||||
if(v_lightDistance > light_map_depth + bias)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
light_attenuation = 1. - pow(light_distance / light_pnt_radius[i], 2.);
|
||||
|
|
Loading…
Reference in a new issue