mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-25 14:36:13 +01:00
rm combine
This commit is contained in:
parent
63bbf10ba2
commit
d4546ee7fe
15 changed files with 223 additions and 109 deletions
|
@ -985,6 +985,7 @@
|
||||||
{"name":"node_random_tile","order":8,"path":"scripts/node_random_tile/node_random_tile.yy",},
|
{"name":"node_random_tile","order":8,"path":"scripts/node_random_tile/node_random_tile.yy",},
|
||||||
{"name":"node_random","order":5,"path":"scripts/node_random/node_random.yy",},
|
{"name":"node_random","order":5,"path":"scripts/node_random/node_random.yy",},
|
||||||
{"name":"node_rate_remap","order":3,"path":"scripts/node_rate_remap/node_rate_remap.yy",},
|
{"name":"node_rate_remap","order":3,"path":"scripts/node_rate_remap/node_rate_remap.yy",},
|
||||||
|
{"name":"node_raymarching","order":5,"path":"scripts/node_raymarching/node_raymarching.yy",},
|
||||||
{"name":"node_rd","order":4,"path":"scripts/node_rd/node_rd.yy",},
|
{"name":"node_rd","order":4,"path":"scripts/node_rd/node_rd.yy",},
|
||||||
{"name":"node_region_fill","order":1,"path":"scripts/node_region_fill/node_region_fill.yy",},
|
{"name":"node_region_fill","order":1,"path":"scripts/node_region_fill/node_region_fill.yy",},
|
||||||
{"name":"node_registry","order":11,"path":"scripts/node_registry/node_registry.yy",},
|
{"name":"node_registry","order":11,"path":"scripts/node_registry/node_registry.yy",},
|
||||||
|
|
|
@ -1412,6 +1412,7 @@
|
||||||
{"id":{"name":"node_random_tile","path":"scripts/node_random_tile/node_random_tile.yy",},},
|
{"id":{"name":"node_random_tile","path":"scripts/node_random_tile/node_random_tile.yy",},},
|
||||||
{"id":{"name":"node_random","path":"scripts/node_random/node_random.yy",},},
|
{"id":{"name":"node_random","path":"scripts/node_random/node_random.yy",},},
|
||||||
{"id":{"name":"node_rate_remap","path":"scripts/node_rate_remap/node_rate_remap.yy",},},
|
{"id":{"name":"node_rate_remap","path":"scripts/node_rate_remap/node_rate_remap.yy",},},
|
||||||
|
{"id":{"name":"node_raymarching","path":"scripts/node_raymarching/node_raymarching.yy",},},
|
||||||
{"id":{"name":"node_rd","path":"scripts/node_rd/node_rd.yy",},},
|
{"id":{"name":"node_rd","path":"scripts/node_rd/node_rd.yy",},},
|
||||||
{"id":{"name":"node_region_fill","path":"scripts/node_region_fill/node_region_fill.yy",},},
|
{"id":{"name":"node_region_fill","path":"scripts/node_region_fill/node_region_fill.yy",},},
|
||||||
{"id":{"name":"node_registry","path":"scripts/node_registry/node_registry.yy",},},
|
{"id":{"name":"node_registry","path":"scripts/node_registry/node_registry.yy",},},
|
||||||
|
|
Binary file not shown.
|
@ -1,6 +1,6 @@
|
||||||
function Node_3D(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
function Node_3D(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
||||||
name = "3D";
|
name = "3D";
|
||||||
is_3D = true;
|
is_3D = NODE_3D.polygon;
|
||||||
surface_depth_disable(false);
|
surface_depth_disable(false);
|
||||||
|
|
||||||
mesh_prev_surface = surface_create(64, 64);
|
mesh_prev_surface = surface_create(64, 64);
|
||||||
|
|
|
@ -60,10 +60,7 @@ function Node_3D_Object(_x, _y, _group = noone) : Node_3D(_x, _y, _group) constr
|
||||||
tools = tool_quate;
|
tools = tool_quate;
|
||||||
|
|
||||||
tool_axis_edit = new scrollBox([ "local", "global" ], function(val) { tool_attribute.context = val; });
|
tool_axis_edit = new scrollBox([ "local", "global" ], function(val) { tool_attribute.context = val; });
|
||||||
// tool_axis_edit.font = f_p2;
|
tool_attribute.context = 0;
|
||||||
// tool_axis_edit.arrow_spr = THEME.arrow;
|
|
||||||
// tool_axis_edit.arrow_ind = 3;
|
|
||||||
tool_attribute.context = 0;
|
|
||||||
tool_settings = [
|
tool_settings = [
|
||||||
[ "Axis", tool_axis_edit, "context", tool_attribute ],
|
[ "Axis", tool_axis_edit, "context", tool_attribute ],
|
||||||
];
|
];
|
||||||
|
|
|
@ -43,7 +43,7 @@ function RM_Object() constructor {
|
||||||
triplanar = [];
|
triplanar = [];
|
||||||
|
|
||||||
opmap = -1;
|
opmap = -1;
|
||||||
oparg = [];
|
oparg = -1;
|
||||||
|
|
||||||
uniformKeys = [ "shape", "size", "radius", "thickness", "crop", "angle", "height", "radRange", "sizeUni", "elongate", "rounded", "corner", "size2D", "sides",
|
uniformKeys = [ "shape", "size", "radius", "thickness", "crop", "angle", "height", "radRange", "sizeUni", "elongate", "rounded", "corner", "size2D", "sides",
|
||||||
"waveAmp", "waveInt", "waveShift",
|
"waveAmp", "waveInt", "waveShift",
|
||||||
|
@ -74,7 +74,7 @@ function RM_Object() constructor {
|
||||||
if(shapeAmount <= 0) return;
|
if(shapeAmount <= 0) return;
|
||||||
|
|
||||||
shader_set_i("operations", opmap);
|
shader_set_i("operations", opmap);
|
||||||
shader_set_i("opArgument", oparg);
|
shader_set_f("opArgument", oparg);
|
||||||
shader_set_i("opLength", array_safe_length(opmap));
|
shader_set_i("opLength", array_safe_length(opmap));
|
||||||
|
|
||||||
shader_set_i("shape", shape);
|
shader_set_i("shape", shape);
|
||||||
|
@ -119,6 +119,9 @@ function RM_Object() constructor {
|
||||||
shader_set_f("textureScale", textureScale);
|
shader_set_f("textureScale", textureScale);
|
||||||
shader_set_f("triplanar", triplanar);
|
shader_set_f("triplanar", triplanar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static serialize = function() { return ""};
|
||||||
|
static deserialize = function() { };
|
||||||
}
|
}
|
||||||
|
|
||||||
function RM_Operation(type, left, right) : RM_Object() constructor {
|
function RM_Operation(type, left, right) : RM_Object() constructor {
|
||||||
|
@ -170,8 +173,10 @@ function RM_Operation(type, left, right) : RM_Object() constructor {
|
||||||
_a.flatten_index = array_length(_nodes);
|
_a.flatten_index = array_length(_nodes);
|
||||||
array_push(_nodes, _a);
|
array_push(_nodes, _a);
|
||||||
}
|
}
|
||||||
|
|
||||||
opmap = [];
|
opmap = [];
|
||||||
|
oparg = [];
|
||||||
|
|
||||||
for (var i = 0, n = array_length(_arr); i < n; i++) {
|
for (var i = 0, n = array_length(_arr); i < n; i++) {
|
||||||
var _a = _arr[i];
|
var _a = _arr[i];
|
||||||
|
|
||||||
|
@ -202,4 +207,39 @@ function RM_Operation(type, left, right) : RM_Object() constructor {
|
||||||
|
|
||||||
function RM_Shape() : RM_Object() constructor {
|
function RM_Shape() : RM_Object() constructor {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function RM_Environment() constructor {
|
||||||
|
surface = noone;
|
||||||
|
bgEnv = noone;
|
||||||
|
|
||||||
|
projection = 0;
|
||||||
|
fov = 0;
|
||||||
|
orthoScale = 1;
|
||||||
|
viewRange = [ 0, 1 ];
|
||||||
|
depthInt = 0;
|
||||||
|
|
||||||
|
bgColor = c_black;
|
||||||
|
bgDraw = false;
|
||||||
|
ambInten = 0;
|
||||||
|
light = [ 1, 0.5, 0 ];
|
||||||
|
|
||||||
|
static apply = function() {
|
||||||
|
|
||||||
|
shader_set_surface($"texture0", surface);
|
||||||
|
|
||||||
|
shader_set_i("ortho", projection);
|
||||||
|
shader_set_f("fov", fov);
|
||||||
|
shader_set_f("orthoScale", orthoScale);
|
||||||
|
shader_set_f("viewRange", viewRange);
|
||||||
|
shader_set_f("depthInt", depthInt);
|
||||||
|
|
||||||
|
shader_set_i("drawBg", bgColor);
|
||||||
|
shader_set_color("background", bgDraw);
|
||||||
|
shader_set_f("ambientIntns", ambInten);
|
||||||
|
shader_set_f("lightPosition", light);
|
||||||
|
|
||||||
|
shader_set_i("useEnv", is_surface(bgEnv));
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -15,6 +15,12 @@ enum DYNA_INPUT_COND {
|
||||||
zero = 1 << 1,
|
zero = 1 << 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum NODE_3D {
|
||||||
|
none,
|
||||||
|
polygon,
|
||||||
|
sdf,
|
||||||
|
}
|
||||||
|
|
||||||
function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
|
function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
|
||||||
|
|
||||||
#region ---- main & active ----
|
#region ---- main & active ----
|
||||||
|
@ -286,7 +292,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ---- 3d ----
|
#region ---- 3d ----
|
||||||
is_3D = false;
|
is_3D = NODE_3D.none;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ---- cache ----
|
#region ---- cache ----
|
||||||
|
@ -512,7 +518,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
|
||||||
will_setHeight = false;
|
will_setHeight = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_3D) USE_DEPTH = true;
|
if(is_3D == NODE_3D.polygon) USE_DEPTH = true;
|
||||||
if(is_simulation) PROJECT.animator.is_simulating = true;
|
if(is_simulation) PROJECT.animator.is_simulating = true;
|
||||||
} #endregion
|
} #endregion
|
||||||
|
|
||||||
|
|
|
@ -601,7 +601,7 @@ function valueAnimator(_val, _prop, _sep_axis = false) constructor {
|
||||||
if(prop.type == VALUE_TYPE.struct) {
|
if(prop.type == VALUE_TYPE.struct) {
|
||||||
val = json_stringify(val);
|
val = json_stringify(val);
|
||||||
|
|
||||||
} else if(is_struct(val)) {
|
} else if(is_struct(val) && struct_has(val, "serialize")) {
|
||||||
val = val.serialize();
|
val = val.serialize();
|
||||||
|
|
||||||
} else if(!sep_axis && typeArray(prop.display_type) && is_array(val)) {
|
} else if(!sep_axis && typeArray(prop.display_type) && is_array(val)) {
|
||||||
|
|
6
scripts/node_raymarching/node_raymarching.gml
Normal file
6
scripts/node_raymarching/node_raymarching.gml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
function Node_RM(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
||||||
|
name = "RM";
|
||||||
|
is_3D = NODE_3D.sdf;
|
||||||
|
batch_output = true;
|
||||||
|
|
||||||
|
}
|
13
scripts/node_raymarching/node_raymarching.yy
Normal file
13
scripts/node_raymarching/node_raymarching.yy
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"$GMScript":"",
|
||||||
|
"%Name":"node_raymarching",
|
||||||
|
"isCompatibility":false,
|
||||||
|
"isDnD":false,
|
||||||
|
"name":"node_raymarching",
|
||||||
|
"parent":{
|
||||||
|
"name":"raymarching",
|
||||||
|
"path":"folders/nodes/data/3D/raymarching.yy",
|
||||||
|
},
|
||||||
|
"resourceType":"GMScript",
|
||||||
|
"resourceVersion":"2.0",
|
||||||
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
function Node_RM_Combine(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
function Node_RM_Combine(_x, _y, _group = noone) : Node_RM(_x, _y, _group) constructor {
|
||||||
name = "RM Combine";
|
name = "RM Combine";
|
||||||
batch_output = true;
|
|
||||||
|
|
||||||
inputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF)
|
inputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF)
|
||||||
.setDisplay(VALUE_DISPLAY.vector);
|
.setDisplay(VALUE_DISPLAY.vector);
|
||||||
|
@ -42,10 +41,10 @@ function Node_RM_Combine(_x, _y, _group = noone) : Node_Processor(_x, _y, _group
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
inputs[| 13] = nodeValue("Shape 1", self, JUNCTION_CONNECT.input, VALUE_TYPE.struct, {})
|
inputs[| 13] = nodeValue("Shape 1", self, JUNCTION_CONNECT.input, VALUE_TYPE.sdf, {})
|
||||||
.setVisible(true, true);
|
.setVisible(true, true);
|
||||||
|
|
||||||
inputs[| 14] = nodeValue("Shape 2", self, JUNCTION_CONNECT.input, VALUE_TYPE.struct, {})
|
inputs[| 14] = nodeValue("Shape 2", self, JUNCTION_CONNECT.input, VALUE_TYPE.sdf, {})
|
||||||
.setVisible(true, true);
|
.setVisible(true, true);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -58,23 +57,25 @@ function Node_RM_Combine(_x, _y, _group = noone) : Node_Processor(_x, _y, _group
|
||||||
|
|
||||||
outputs[| 0] = nodeValue("Surface Out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
outputs[| 0] = nodeValue("Surface Out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
||||||
|
|
||||||
outputs[| 1] = nodeValue("Shape Data", self, JUNCTION_CONNECT.output, VALUE_TYPE.struct, noone);
|
outputs[| 1] = nodeValue("Shape Data", self, JUNCTION_CONNECT.output, VALUE_TYPE.sdf, noone);
|
||||||
|
|
||||||
input_display_list = [ 0,
|
input_display_list = [ 0,
|
||||||
["Combine", false], 15, 13, 14,
|
["Combine", false], 15, 16, 13, 14,
|
||||||
["Camera", false], 11, 12, 1, 2, 3, 4, 5,
|
["Camera", false], 11, 12, 1, 2, 3, 4, 5,
|
||||||
["Render", false], 6, 7, 8, 10, 9,
|
["Render", false], 6, 7, 8, 10, 9,
|
||||||
]
|
]
|
||||||
|
|
||||||
object = noone;
|
|
||||||
temp_surface = [ 0, 0 ];
|
temp_surface = [ 0, 0 ];
|
||||||
|
environ = new RM_Environment();
|
||||||
|
object = noone;
|
||||||
|
|
||||||
|
static drawOverlay3D = function(active, params, _mx, _my, _snx, _sny, _panel) {}
|
||||||
|
|
||||||
static step = function() {
|
static step = function() {
|
||||||
var _type = getSingleValue(15);
|
var _type = getSingleValue(15);
|
||||||
|
|
||||||
inputs[| 16].setVisible(_type > 0);
|
inputs[| 16].setVisible(_type > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static processData = function(_outSurf, _data, _output_index, _array_index = 0) {
|
static processData = function(_outSurf, _data, _output_index, _array_index = 0) {
|
||||||
var _dim = _data[0];
|
var _dim = _data[0];
|
||||||
|
|
||||||
|
@ -85,7 +86,7 @@ function Node_RM_Combine(_x, _y, _group = noone) : Node_Processor(_x, _y, _group
|
||||||
var _dep = _data[5];
|
var _dep = _data[5];
|
||||||
|
|
||||||
var _bgd = _data[6];
|
var _bgd = _data[6];
|
||||||
var _bgc = _data[7];
|
var _enc = _data[7];
|
||||||
var _amb = _data[8];
|
var _amb = _data[8];
|
||||||
var _lig = _data[9];
|
var _lig = _data[9];
|
||||||
var _env = _data[10];
|
var _env = _data[10];
|
||||||
|
@ -121,27 +122,28 @@ function Node_RM_Combine(_x, _y, _group = noone) : Node_Processor(_x, _y, _group
|
||||||
object.flatten();
|
object.flatten();
|
||||||
object.setTexture(temp_surface[1]);
|
object.setTexture(temp_surface[1]);
|
||||||
|
|
||||||
|
environ.surface = temp_surface[0];
|
||||||
|
environ.bgEnv = _env;
|
||||||
|
|
||||||
|
environ.projection = _ort;
|
||||||
|
environ.fov = _fov;
|
||||||
|
environ.orthoScale = _ort;
|
||||||
|
environ.viewRange = _vrn;
|
||||||
|
environ.depthInt = _dep;
|
||||||
|
|
||||||
|
environ.bgColor = _enc;
|
||||||
|
environ.bgDraw = _bgd;
|
||||||
|
environ.ambInten = _amb;
|
||||||
|
environ.light = _lig;
|
||||||
|
|
||||||
gpu_set_texfilter(true);
|
gpu_set_texfilter(true);
|
||||||
surface_set_shader(_outSurf, sh_rm_primitive);
|
surface_set_shader(_outSurf, sh_rm_primitive);
|
||||||
|
|
||||||
shader_set_surface($"texture0", temp_surface[0]);
|
|
||||||
|
|
||||||
shader_set_f("camRotation", _crt);
|
shader_set_f("camRotation", _crt);
|
||||||
shader_set_f("camScale", _csa);
|
shader_set_f("camScale", _csa);
|
||||||
|
shader_set_f("camRatio", _dim[0] / _dim[1]);
|
||||||
|
|
||||||
shader_set_i("ortho", _pro);
|
environ.apply();
|
||||||
shader_set_f("fov", _fov);
|
|
||||||
shader_set_f("orthoScale", _ort);
|
|
||||||
shader_set_f("viewRange", _vrn);
|
|
||||||
shader_set_f("depthInt", _dep);
|
|
||||||
|
|
||||||
shader_set_i("drawBg", _bgd);
|
|
||||||
shader_set_color("background", _bgc);
|
|
||||||
shader_set_f("ambientIntns", _amb);
|
|
||||||
shader_set_f("lightPosition", _lig);
|
|
||||||
|
|
||||||
shader_set_i("useEnv", is_surface(_env));
|
|
||||||
|
|
||||||
object.apply();
|
object.apply();
|
||||||
|
|
||||||
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1]);
|
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1]);
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
function Node_RM_Primitive(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
function Node_RM_Primitive(_x, _y, _group = noone) : Node_RM(_x, _y, _group) constructor {
|
||||||
name = "RM Primitive";
|
name = "RM Primitive";
|
||||||
batch_output = true;
|
|
||||||
|
|
||||||
inputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF)
|
inputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF)
|
||||||
.setDisplay(VALUE_DISPLAY.vector);
|
.setDisplay(VALUE_DISPLAY.vector);
|
||||||
|
@ -155,7 +154,7 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
|
||||||
|
|
||||||
outputs[| 0] = nodeValue("Surface Out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
outputs[| 0] = nodeValue("Surface Out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
||||||
|
|
||||||
outputs[| 1] = nodeValue("Shape Data", self, JUNCTION_CONNECT.output, VALUE_TYPE.struct, noone);
|
outputs[| 1] = nodeValue("Shape Data", self, JUNCTION_CONNECT.output, VALUE_TYPE.sdf, noone);
|
||||||
|
|
||||||
input_display_list = [ 0,
|
input_display_list = [ 0,
|
||||||
["Primitive", false], 1, 21, 22, 23, 24, 25, 26, 27, 28, 39, 40, 41,
|
["Primitive", false], 1, 21, 22, 23, 24, 25, 26, 27, 28, 39, 40, 41,
|
||||||
|
@ -170,9 +169,12 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
|
||||||
];
|
];
|
||||||
|
|
||||||
temp_surface = [ 0, 0 ];
|
temp_surface = [ 0, 0 ];
|
||||||
object = new RM_Shape();
|
environ = new RM_Environment();
|
||||||
|
object = new RM_Shape();
|
||||||
|
|
||||||
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {}
|
static drawOverlay3D = function(active, params, _mx, _my, _snx, _sny, _panel) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static step = function() {
|
static step = function() {
|
||||||
var _shp = getSingleValue( 1);
|
var _shp = getSingleValue( 1);
|
||||||
|
@ -426,27 +428,28 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
|
||||||
|
|
||||||
object.setTexture(temp_surface[1]);
|
object.setTexture(temp_surface[1]);
|
||||||
|
|
||||||
|
environ.surface = temp_surface[0];
|
||||||
|
environ.bgEnv = bgEnv;
|
||||||
|
|
||||||
|
environ.projection = _ort;
|
||||||
|
environ.fov = _fov;
|
||||||
|
environ.orthoScale = _ortS;
|
||||||
|
environ.viewRange = _rng;
|
||||||
|
environ.depthInt = _dpi;
|
||||||
|
|
||||||
|
environ.bgColor = _bgd;
|
||||||
|
environ.bgDraw = _bgc;
|
||||||
|
environ.ambInten = _ambI;
|
||||||
|
environ.light = _lPos;
|
||||||
|
|
||||||
gpu_set_texfilter(true);
|
gpu_set_texfilter(true);
|
||||||
surface_set_shader(_outSurf, sh_rm_primitive);
|
surface_set_shader(_outSurf, sh_rm_primitive);
|
||||||
|
|
||||||
shader_set_surface($"texture0", temp_surface[0]);
|
|
||||||
|
|
||||||
shader_set_f("camRotation", _crt);
|
shader_set_f("camRotation", _crt);
|
||||||
shader_set_f("camScale", _csa);
|
shader_set_f("camScale", _csa);
|
||||||
|
shader_set_f("camRatio", _dim[0] / _dim[1]);
|
||||||
|
|
||||||
shader_set_i("ortho", _ort);
|
environ.apply();
|
||||||
shader_set_f("fov", _fov);
|
|
||||||
shader_set_f("orthoScale", _ortS);
|
|
||||||
shader_set_f("viewRange", _rng);
|
|
||||||
shader_set_f("depthInt", _dpi);
|
|
||||||
|
|
||||||
shader_set_i("drawBg", _bgd);
|
|
||||||
shader_set_color("background", _bgc);
|
|
||||||
shader_set_f("ambientIntns", _ambI);
|
|
||||||
shader_set_f("lightPosition", _lPos);
|
|
||||||
|
|
||||||
shader_set_i("useEnv", is_surface(bgEnv));
|
|
||||||
|
|
||||||
object.apply();
|
object.apply();
|
||||||
|
|
||||||
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1]);
|
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1]);
|
||||||
|
|
|
@ -54,10 +54,9 @@ enum VALUE_TYPE {
|
||||||
|
|
||||||
dynaSurface = 31,
|
dynaSurface = 31,
|
||||||
PCXnode = 32,
|
PCXnode = 32,
|
||||||
|
audioBit = 33,
|
||||||
audioBit = 33,
|
fdomain = 34,
|
||||||
|
sdf = 35,
|
||||||
fdomain = 34,
|
|
||||||
|
|
||||||
action = 99,
|
action = 99,
|
||||||
}
|
}
|
||||||
|
@ -186,6 +185,7 @@ function value_color(i) { #region
|
||||||
#c2c2d1, //PCX
|
#c2c2d1, //PCX
|
||||||
#8fde5d, //audiobit
|
#8fde5d, //audiobit
|
||||||
#4da6ff, //flipfluid
|
#4da6ff, //flipfluid
|
||||||
|
#c1007c, //3D SDF
|
||||||
];
|
];
|
||||||
static JUNCTION_COLORS_LENGTH = array_length(JUNCTION_COLORS);
|
static JUNCTION_COLORS_LENGTH = array_length(JUNCTION_COLORS);
|
||||||
|
|
||||||
|
@ -234,6 +234,7 @@ function value_color_bg_array(i) { #region
|
||||||
#bd4882, //dynaSurf
|
#bd4882, //dynaSurf
|
||||||
#83839b, //PCX
|
#83839b, //PCX
|
||||||
#3ca370, //audiobit
|
#3ca370, //audiobit
|
||||||
|
#c1007c, //3D SDF
|
||||||
];
|
];
|
||||||
|
|
||||||
if(i == 99) return $5dde8f;
|
if(i == 99) return $5dde8f;
|
||||||
|
@ -282,6 +283,7 @@ function value_bit(i) { #region
|
||||||
case VALUE_TYPE.PCXnode : return 1 << 34;
|
case VALUE_TYPE.PCXnode : return 1 << 34;
|
||||||
case VALUE_TYPE.audioBit : return 1 << 35;
|
case VALUE_TYPE.audioBit : return 1 << 35;
|
||||||
case VALUE_TYPE.fdomain : return 1 << 36;
|
case VALUE_TYPE.fdomain : return 1 << 36;
|
||||||
|
case VALUE_TYPE.sdf : return 1 << 37;
|
||||||
|
|
||||||
case VALUE_TYPE.any : return ~0 & ~(1 << 32);
|
case VALUE_TYPE.any : return ~0 & ~(1 << 32);
|
||||||
}
|
}
|
||||||
|
@ -355,10 +357,9 @@ function value_type_from_string(str) { #region
|
||||||
|
|
||||||
case "dynaSurface" : return VALUE_TYPE.dynaSurface;
|
case "dynaSurface" : return VALUE_TYPE.dynaSurface;
|
||||||
case "PCXnode" : return VALUE_TYPE.PCXnode;
|
case "PCXnode" : return VALUE_TYPE.PCXnode;
|
||||||
|
case "audioBit" : return VALUE_TYPE.audioBit;
|
||||||
case "audioBit" : return VALUE_TYPE.audioBit;
|
case "fDomain" : return VALUE_TYPE.fdomain;
|
||||||
|
case "sdf" : return VALUE_TYPE.sdf;
|
||||||
case "fDomain" : return VALUE_TYPE.fdomain;
|
|
||||||
|
|
||||||
case "action" : return VALUE_TYPE.action;
|
case "action" : return VALUE_TYPE.action;
|
||||||
}
|
}
|
||||||
|
|
|
@ -943,14 +943,10 @@ function Panel_Preview() : PanelContent() constructor {
|
||||||
} #endregion
|
} #endregion
|
||||||
} #endregion
|
} #endregion
|
||||||
|
|
||||||
function draw3D() { #region
|
function draw3DPolygon(_node) { #region
|
||||||
var _prev_node = getNodePreview();
|
_node.previewing = 1;
|
||||||
if(_prev_node == noone) return;
|
|
||||||
if(!_prev_node.is_3D) return;
|
|
||||||
|
|
||||||
_prev_node.previewing = 1;
|
d3_scene_preview = struct_has(_node, "scene")? _node.scene : d3_scene;
|
||||||
|
|
||||||
d3_scene_preview = struct_has(_prev_node, "scene")? _prev_node.scene : d3_scene;
|
|
||||||
d3_scene_preview.camera = d3_view_camera;
|
d3_scene_preview.camera = d3_view_camera;
|
||||||
|
|
||||||
#region view
|
#region view
|
||||||
|
@ -1002,7 +998,7 @@ function Panel_Preview() : PanelContent() constructor {
|
||||||
if(d3_scene_preview == d3_scene) {
|
if(d3_scene_preview == d3_scene) {
|
||||||
d3_scene_light0.shadow_map_scale = d3_view_camera.focus_dist * 2;
|
d3_scene_light0.shadow_map_scale = d3_view_camera.focus_dist * 2;
|
||||||
|
|
||||||
var _prev_obj = _prev_node.getPreviewObject();
|
var _prev_obj = _node.getPreviewObject();
|
||||||
if(_prev_obj != noone) {
|
if(_prev_obj != noone) {
|
||||||
d3_scene_light0.submitShadow(d3_scene_preview, _prev_obj);
|
d3_scene_light0.submitShadow(d3_scene_preview, _prev_obj);
|
||||||
_prev_obj.submitShadow(d3_scene_preview, _prev_obj);
|
_prev_obj.submitShadow(d3_scene_preview, _prev_obj);
|
||||||
|
@ -1016,7 +1012,7 @@ function Panel_Preview() : PanelContent() constructor {
|
||||||
d3_surface_outline = surface_verify(d3_surface_outline, w, h);
|
d3_surface_outline = surface_verify(d3_surface_outline, w, h);
|
||||||
|
|
||||||
#region defer
|
#region defer
|
||||||
var _prev_obj = _prev_node.getPreviewObject();
|
var _prev_obj = _node.getPreviewObject();
|
||||||
if(_prev_obj) d3_deferData = d3_scene_preview.deferPass(_prev_obj, w, h, d3_deferData);
|
if(_prev_obj) d3_deferData = d3_scene_preview.deferPass(_prev_obj, w, h, d3_deferData);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -1057,7 +1053,7 @@ function Panel_Preview() : PanelContent() constructor {
|
||||||
d3_scene_preview.reset();
|
d3_scene_preview.reset();
|
||||||
gpu_set_cullmode(cull_counterclockwise);
|
gpu_set_cullmode(cull_counterclockwise);
|
||||||
|
|
||||||
var _prev_obj = _prev_node.getPreviewObjects();
|
var _prev_obj = _node.getPreviewObjects();
|
||||||
|
|
||||||
if(d3_scene_preview == d3_scene) {
|
if(d3_scene_preview == d3_scene) {
|
||||||
if(d3_scene_light_enabled) {
|
if(d3_scene_light_enabled) {
|
||||||
|
@ -1108,7 +1104,7 @@ function Panel_Preview() : PanelContent() constructor {
|
||||||
#region outline
|
#region outline
|
||||||
var inspect_node = PANEL_INSPECTOR.getInspecting();
|
var inspect_node = PANEL_INSPECTOR.getInspecting();
|
||||||
|
|
||||||
if(inspect_node && inspect_node.is_3D) {
|
if(inspect_node && inspect_node.is_3D == NODE_3D.polygon) {
|
||||||
var _inspect_obj = inspect_node.getPreviewObjectOutline();
|
var _inspect_obj = inspect_node.getPreviewObjectOutline();
|
||||||
|
|
||||||
surface_set_target(d3_surface_outline);
|
surface_set_target(d3_surface_outline);
|
||||||
|
@ -1134,6 +1130,45 @@ function Panel_Preview() : PanelContent() constructor {
|
||||||
d3_scene_preview.camera.resetCamera();
|
d3_scene_preview.camera.resetCamera();
|
||||||
} #endregion
|
} #endregion
|
||||||
|
|
||||||
|
function draw3DSdf(_node) { #region
|
||||||
|
_node.previewing = 1;
|
||||||
|
|
||||||
|
var _env = _node.environ;
|
||||||
|
var _obj = _node.object;
|
||||||
|
|
||||||
|
draw_clear(bg_color);
|
||||||
|
|
||||||
|
gpu_set_texfilter(true);
|
||||||
|
shader_set(sh_rm_primitive);
|
||||||
|
var zm = 4 / d3_view_camera.focus_dist;
|
||||||
|
|
||||||
|
shader_set_f("camRotation", [ d3_view_camera.focus_angle_y, -d3_view_camera.focus_angle_x, 0 ]);
|
||||||
|
shader_set_f("camScale", zm);
|
||||||
|
shader_set_f("camRatio", w / h);
|
||||||
|
|
||||||
|
_env.apply();
|
||||||
|
_obj.apply();
|
||||||
|
|
||||||
|
shader_set_i("drawBg", 0);
|
||||||
|
shader_set_f("viewRange", [ d3_view_camera.view_near, d3_view_camera.view_far ]);
|
||||||
|
shader_set_f("depthInt", 0);
|
||||||
|
|
||||||
|
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, w, h);
|
||||||
|
shader_reset();
|
||||||
|
gpu_set_texfilter(false);
|
||||||
|
|
||||||
|
} #endregion
|
||||||
|
|
||||||
|
function draw3D() { #region
|
||||||
|
var _node = getNodePreview();
|
||||||
|
if(_node == noone) return;
|
||||||
|
|
||||||
|
switch(_node.is_3D) {
|
||||||
|
case NODE_3D.polygon : draw3DPolygon(_node); break;
|
||||||
|
case NODE_3D.sdf : draw3DSdf(_node); break;
|
||||||
|
}
|
||||||
|
} #endregion
|
||||||
|
|
||||||
function drawPreviewOverlay() { #region
|
function drawPreviewOverlay() { #region
|
||||||
right_menu_y = toolbar_height - ui(4);
|
right_menu_y = toolbar_height - ui(4);
|
||||||
if(show_view_control == 2) {
|
if(show_view_control == 2) {
|
||||||
|
@ -1436,14 +1471,7 @@ function Panel_Preview() : PanelContent() constructor {
|
||||||
var params = { w, h, toolbar_height };
|
var params = { w, h, toolbar_height };
|
||||||
var mouse_free = false;
|
var mouse_free = false;
|
||||||
|
|
||||||
if(_node.is_3D) {
|
if(_node.is_3D == NODE_3D.none) {
|
||||||
if(key_mod_press(CTRL) || d3_tool_snap) {
|
|
||||||
_snx = d3_tool_snap_position;
|
|
||||||
_sny = d3_tool_snap_rotation;
|
|
||||||
}
|
|
||||||
|
|
||||||
mouse_free = _node.drawOverlay3D(overActive, d3_scene, _mx, _my, _snx, _sny, params);
|
|
||||||
} else {
|
|
||||||
if(key_mod_press(CTRL)) {
|
if(key_mod_press(CTRL)) {
|
||||||
_snx = PROJECT.previewGrid.show? PROJECT.previewGrid.size[0] : 1;
|
_snx = PROJECT.previewGrid.show? PROJECT.previewGrid.size[0] : 1;
|
||||||
_sny = PROJECT.previewGrid.show? PROJECT.previewGrid.size[1] : 1;
|
_sny = PROJECT.previewGrid.show? PROJECT.previewGrid.size[1] : 1;
|
||||||
|
@ -1453,6 +1481,13 @@ function Panel_Preview() : PanelContent() constructor {
|
||||||
}
|
}
|
||||||
|
|
||||||
mouse_free = _node.drawOverlay(overHover, overActive, cx, cy, canvas_s, _mx, _my, _snx, _sny, params);
|
mouse_free = _node.drawOverlay(overHover, overActive, cx, cy, canvas_s, _mx, _my, _snx, _sny, params);
|
||||||
|
} else {
|
||||||
|
if(key_mod_press(CTRL) || d3_tool_snap) {
|
||||||
|
_snx = d3_tool_snap_position;
|
||||||
|
_sny = d3_tool_snap_rotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
mouse_free = _node.drawOverlay3D(overActive, d3_scene, _mx, _my, _snx, _sny, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region node overlay
|
#region node overlay
|
||||||
|
@ -1901,9 +1936,8 @@ function Panel_Preview() : PanelContent() constructor {
|
||||||
if(do_fullView) run_in(1, fullView);
|
if(do_fullView) run_in(1, fullView);
|
||||||
do_fullView = false;
|
do_fullView = false;
|
||||||
|
|
||||||
var _prev_node = getNodePreview();
|
var _prev_node = getNodePreview();
|
||||||
|
d3_active = _prev_node != noone && _prev_node.is_3D != NODE_3D.none;
|
||||||
d3_active = _prev_node != noone && _prev_node.is_3D;
|
|
||||||
|
|
||||||
draw_clear(bg_color);
|
draw_clear(bg_color);
|
||||||
if(canvas_bg == -1 && canvas_s >= 0.1)
|
if(canvas_bg == -1 && canvas_s >= 0.1)
|
||||||
|
|
|
@ -72,6 +72,7 @@ uniform float triplanar[MAX_SHAPES] ;
|
||||||
|
|
||||||
uniform vec3 camRotation;
|
uniform vec3 camRotation;
|
||||||
uniform float camScale;
|
uniform float camScale;
|
||||||
|
uniform float camRatio;
|
||||||
|
|
||||||
uniform int ortho;
|
uniform int ortho;
|
||||||
uniform float fov;
|
uniform float fov;
|
||||||
|
@ -86,8 +87,6 @@ uniform vec3 lightPosition;
|
||||||
|
|
||||||
uniform int useEnv;
|
uniform int useEnv;
|
||||||
|
|
||||||
mat3 rotMatrix, irotMatrix;
|
|
||||||
|
|
||||||
#region ////========== Transform ============
|
#region ////========== Transform ============
|
||||||
mat3 rotateX(float dg) {
|
mat3 rotateX(float dg) {
|
||||||
float c = cos(radians(dg));
|
float c = cos(radians(dg));
|
||||||
|
@ -475,8 +474,8 @@ float sceneSDF(int index, vec3 p) {
|
||||||
mat3 rx = rotateX(rotation[index].x);
|
mat3 rx = rotateX(rotation[index].x);
|
||||||
mat3 ry = rotateY(rotation[index].y);
|
mat3 ry = rotateY(rotation[index].y);
|
||||||
mat3 rz = rotateZ(rotation[index].z);
|
mat3 rz = rotateZ(rotation[index].z);
|
||||||
rotMatrix = rx * ry * rz;
|
mat3 rotMatrix = rx * ry * rz;
|
||||||
irotMatrix = inverse(rotMatrix);
|
mat3 irotMatrix = inverse(rotMatrix);
|
||||||
|
|
||||||
p /= objectScale[index];
|
p /= objectScale[index];
|
||||||
p -= position[index];
|
p -= position[index];
|
||||||
|
@ -541,20 +540,20 @@ float operateSceneSDF(vec3 p, out vec3 blendIndx) {
|
||||||
float index[MAX_OP];
|
float index[MAX_OP];
|
||||||
|
|
||||||
float d1, d2, o1, o2;
|
float d1, d2, o1, o2;
|
||||||
float merge;
|
float mrg;
|
||||||
int top = 0;
|
int top = 0;
|
||||||
int opr = 0;
|
int opr = 0;
|
||||||
|
|
||||||
for(int i = 0; i < opLength; i++) {
|
for(int i = 0; i < opLength; i++) {
|
||||||
opr = operations[i];
|
opr = operations[i];
|
||||||
merge = opArgument[i];
|
mrg = opArgument[i];
|
||||||
|
|
||||||
if(opr < 100) {
|
if(opr < 100) {
|
||||||
depth[top] = sceneSDF(opr, p);
|
depth[top] = sceneSDF(opr, p);
|
||||||
index[top] = float(opr);
|
index[top] = float(opr);
|
||||||
top++;
|
top++;
|
||||||
|
|
||||||
} else {
|
} else if(top >= 2) {
|
||||||
top--;
|
top--;
|
||||||
d1 = depth[top];
|
d1 = depth[top];
|
||||||
o1 = index[top];
|
o1 = index[top];
|
||||||
|
@ -567,21 +566,19 @@ float operateSceneSDF(vec3 p, out vec3 blendIndx) {
|
||||||
if(d1 < d2) {
|
if(d1 < d2) {
|
||||||
depth[top] = d1;
|
depth[top] = d1;
|
||||||
index[top] = o1;
|
index[top] = o1;
|
||||||
blendIndx.x = o1;
|
blendIndx.x = o1;
|
||||||
blendIndx.z = 0.;
|
blendIndx.z = 0.;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
depth[top] = d2;
|
depth[top] = d2;
|
||||||
index[top] = o2;
|
index[top] = o2;
|
||||||
blendIndx.x = o2;
|
blendIndx.x = o2;
|
||||||
blendIndx.z = 0.;
|
blendIndx.z = 0.;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
top++;
|
|
||||||
|
|
||||||
} else if(opr == 101) {
|
} else if(opr == 101) {
|
||||||
vec2 m = smin(d1, d2, merge);
|
vec2 m = smin(d1, d2, mrg);
|
||||||
blendIndx.x = o1;
|
blendIndx.x = o1;
|
||||||
blendIndx.y = o2;
|
blendIndx.y = o2;
|
||||||
blendIndx.z = m.y;
|
blendIndx.z = m.y;
|
||||||
|
@ -590,15 +587,15 @@ float operateSceneSDF(vec3 p, out vec3 blendIndx) {
|
||||||
index[top] = d1 < d2? o1 : o2;
|
index[top] = d1 < d2? o1 : o2;
|
||||||
|
|
||||||
} else if(opr == 102) {
|
} else if(opr == 102) {
|
||||||
float m = opSmoothSubtraction(d1, d2, merge);
|
float m = opSmoothSubtraction(d1, d2, mrg);
|
||||||
blendIndx.x = o1;
|
blendIndx.x = o2;
|
||||||
blendIndx.z = 0.;
|
blendIndx.z = 0.;
|
||||||
|
|
||||||
depth[top] = m;
|
depth[top] = m;
|
||||||
index[top] = o1;
|
index[top] = o2;
|
||||||
|
|
||||||
} else if(opr == 103) {
|
} else if(opr == 103) {
|
||||||
float m = opSmoothIntersection(d1, d2, merge);
|
float m = opSmoothIntersection(d1, d2, mrg);
|
||||||
blendIndx.x = o1;
|
blendIndx.x = o1;
|
||||||
blendIndx.z = 0.;
|
blendIndx.z = 0.;
|
||||||
|
|
||||||
|
@ -606,7 +603,11 @@ float operateSceneSDF(vec3 p, out vec3 blendIndx) {
|
||||||
index[top] = o1;
|
index[top] = o1;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
top++;
|
||||||
|
|
||||||
|
} else //error, not enough values
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return depth[0];
|
return depth[0];
|
||||||
|
@ -667,10 +668,13 @@ vec4 scene() {
|
||||||
mat3 camIrotMatrix = inverse(camRotMatrix);
|
mat3 camIrotMatrix = inverse(camRotMatrix);
|
||||||
|
|
||||||
float dz = 1. / tan(radians(fov) / 2.);
|
float dz = 1. / tan(radians(fov) / 2.);
|
||||||
vec3 dir = normalize(vec3((v_vTexcoord - .5) * 2., -dz));
|
vec2 cps = (v_vTexcoord - .5) * 2.;
|
||||||
|
cps.x *= camRatio;
|
||||||
|
|
||||||
|
vec3 dir = normalize(vec3(cps, -dz));
|
||||||
vec3 eye = vec3(0., 0., 5.);
|
vec3 eye = vec3(0., 0., 5.);
|
||||||
|
|
||||||
dir = normalize(camIrotMatrix * dir) / camScale;
|
dir = normalize(camIrotMatrix * dir);
|
||||||
eye = camIrotMatrix * eye;
|
eye = camIrotMatrix * eye;
|
||||||
eye /= camScale;
|
eye /= camScale;
|
||||||
|
|
||||||
|
@ -692,6 +696,12 @@ vec4 scene() {
|
||||||
if(depth > viewRange.y - EPSILON) // Not hitting anything.
|
if(depth > viewRange.y - EPSILON) // Not hitting anything.
|
||||||
return vec4(0.);
|
return vec4(0.);
|
||||||
|
|
||||||
|
rx = rotateX(mix(rotation[idx0].x, rotation[idx1].x, rat));
|
||||||
|
ry = rotateY(mix(rotation[idx0].y, rotation[idx1].y, rat));
|
||||||
|
rz = rotateZ(mix(rotation[idx0].z, rotation[idx1].z, rat));
|
||||||
|
mat3 rotMatrix = rx * ry * rz;
|
||||||
|
mat3 irotMatrix = inverse(rotMatrix);
|
||||||
|
|
||||||
vec3 c0 = useTexture[idx0] == 1?
|
vec3 c0 = useTexture[idx0] == 1?
|
||||||
boxmap(int(TEXTURE_S) + idx0, irotMatrix * coll * textureScale[idx0], irotMatrix * norm, triplanar[idx0]).rgb * diffuseColor[idx0].rgb :
|
boxmap(int(TEXTURE_S) + idx0, irotMatrix * coll * textureScale[idx0], irotMatrix * norm, triplanar[idx0]).rgb * diffuseColor[idx0].rgb :
|
||||||
diffuseColor[idx0].rgb;
|
diffuseColor[idx0].rgb;
|
||||||
|
|
Loading…
Reference in a new issue