mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-01-24 03:48:06 +01:00
[Stack] Add blend mode property.
This commit is contained in:
parent
8eff3f78f6
commit
6a56d1e4dc
8 changed files with 126 additions and 41 deletions
|
@ -75,7 +75,6 @@
|
|||
{"name":"d3d_compose","order":3,"path":"folders/nodes/data/3D/d3d_compose.yy",},
|
||||
{"name":"d3d_light","order":4,"path":"folders/nodes/data/3D/d3d_light.yy",},
|
||||
{"name":"d3d_mesh","order":5,"path":"folders/nodes/data/3D/d3d_mesh.yy",},
|
||||
{"name":"mesh","order":11,"path":"folders/nodes/data/3D/d3d_mesh/mesh.yy",},
|
||||
{"name":"d3d_modifier","order":6,"path":"folders/nodes/data/3D/d3d_modifier.yy",},
|
||||
{"name":"d3d_particle","order":7,"path":"folders/nodes/data/3D/d3d_particle.yy",},
|
||||
{"name":"raymarching","order":8,"path":"folders/nodes/data/3D/raymarching.yy",},
|
||||
|
@ -667,30 +666,32 @@
|
|||
{"name":"mouse_input","order":1,"path":"scripts/mouse_input/mouse_input.yy",},
|
||||
{"name":"mtl_reader","order":6,"path":"scripts/mtl_reader/mtl_reader.yy",},
|
||||
{"name":"network_data","order":22,"path":"scripts/network_data/network_data.yy",},
|
||||
{"name":"node_3d_bend","order":9,"path":"scripts/node_3d_bend/node_3d_bend.yy",},
|
||||
{"name":"node_3d_camera_set","order":1,"path":"scripts/node_3d_camera_set/node_3d_camera_set.yy",},
|
||||
{"name":"node_3d_depth","order":4,"path":"scripts/node_3d_depth/node_3d_depth.yy",},
|
||||
{"name":"node_3d_displace","order":8,"path":"scripts/node_3d_displace/node_3d_displace.yy",},
|
||||
{"name":"node_3d_instancer","order":3,"path":"scripts/node_3d_instancer/node_3d_instancer.yy",},
|
||||
{"name":"node_3d_light_point","order":2,"path":"scripts/node_3d_light_point/node_3d_light_point.yy",},
|
||||
{"name":"node_3d_material","order":11,"path":"scripts/node_3d_material/node_3d_material.yy",},
|
||||
{"name":"node_3d_mesh_cone","order":6,"path":"scripts/node_3d_mesh_cone/node_3d_mesh_cone.yy",},
|
||||
{"name":"node_3d_mesh_cylinder","order":3,"path":"scripts/node_3d_mesh_cylinder/node_3d_mesh_cylinder.yy",},
|
||||
{"name":"node_3d_mesh_cone","order":7,"path":"scripts/node_3d_mesh_cone/node_3d_mesh_cone.yy",},
|
||||
{"name":"node_3d_mesh_cube","order":2,"path":"scripts/node_3d_mesh_cube/node_3d_mesh_cube.yy",},
|
||||
{"name":"node_3d_mesh_cylinder","order":4,"path":"scripts/node_3d_mesh_cylinder/node_3d_mesh_cylinder.yy",},
|
||||
{"name":"node_3d_mesh_export","order":14,"path":"scripts/node_3d_mesh_export/node_3d_mesh_export.yy",},
|
||||
{"name":"node_3d_mesh_extrude","order":8,"path":"scripts/node_3d_mesh_extrude/node_3d_mesh_extrude.yy",},
|
||||
{"name":"node_3d_mesh_obj","order":2,"path":"scripts/node_3d_mesh_obj/node_3d_mesh_obj.yy",},
|
||||
{"name":"node_3d_mesh_path_extrude","order":10,"path":"scripts/node_3d_mesh_path_extrude/node_3d_mesh_path_extrude.yy",},
|
||||
{"name":"node_3d_mesh_plane","order":7,"path":"scripts/node_3d_mesh_plane/node_3d_mesh_plane.yy",},
|
||||
{"name":"node_3d_mesh_sphere_ico","order":5,"path":"scripts/node_3d_mesh_sphere_ico/node_3d_mesh_sphere_ico.yy",},
|
||||
{"name":"node_3d_mesh_sphere_uv","order":4,"path":"scripts/node_3d_mesh_sphere_uv/node_3d_mesh_sphere_uv.yy",},
|
||||
{"name":"node_3d_mesh_extrude","order":9,"path":"scripts/node_3d_mesh_extrude/node_3d_mesh_extrude.yy",},
|
||||
{"name":"node_3d_mesh_obj","order":3,"path":"scripts/node_3d_mesh_obj/node_3d_mesh_obj.yy",},
|
||||
{"name":"node_3d_mesh_path_extrude","order":11,"path":"scripts/node_3d_mesh_path_extrude/node_3d_mesh_path_extrude.yy",},
|
||||
{"name":"node_3d_mesh_plane","order":8,"path":"scripts/node_3d_mesh_plane/node_3d_mesh_plane.yy",},
|
||||
{"name":"node_3d_mesh_sphere_ico","order":6,"path":"scripts/node_3d_mesh_sphere_ico/node_3d_mesh_sphere_ico.yy",},
|
||||
{"name":"node_3d_mesh_sphere_uv","order":5,"path":"scripts/node_3d_mesh_sphere_uv/node_3d_mesh_sphere_uv.yy",},
|
||||
{"name":"node_3d_mesh_stack_slice","order":7,"path":"scripts/node_3d_mesh_stack_slice/node_3d_mesh_stack_slice.yy",},
|
||||
{"name":"node_3d_mesh_terrain","order":9,"path":"scripts/node_3d_mesh_terrain/node_3d_mesh_terrain.yy",},
|
||||
{"name":"node_3d_mesh_terrain","order":10,"path":"scripts/node_3d_mesh_terrain/node_3d_mesh_terrain.yy",},
|
||||
{"name":"node_3d_mesh_torus","order":12,"path":"scripts/node_3d_mesh_torus/node_3d_mesh_torus.yy",},
|
||||
{"name":"node_3d_mesh_wall_builder","order":13,"path":"scripts/node_3d_mesh_wall_builder/node_3d_mesh_wall_builder.yy",},
|
||||
{"name":"node_3d_point_affector","order":12,"path":"scripts/node_3d_point_affector/node_3d_point_affector.yy",},
|
||||
{"name":"node_3d_repeat","order":1,"path":"scripts/node_3d_repeat/node_3d_repeat.yy",},
|
||||
{"name":"node_3d_round_vertex","order":1,"path":"scripts/node_3d_round_vertex/node_3d_round_vertex.yy",},
|
||||
{"name":"node_3d_set_material","order":2,"path":"scripts/node_3d_set_material/node_3d_set_material.yy",},
|
||||
{"name":"node_3d_subdivide","order":9,"path":"scripts/node_3d_subdivide/node_3d_subdivide.yy",},
|
||||
{"name":"node_3d_subdivide","order":10,"path":"scripts/node_3d_subdivide/node_3d_subdivide.yy",},
|
||||
{"name":"node_3d_transform_image","order":13,"path":"scripts/node_3d_transform_image/node_3d_transform_image.yy",},
|
||||
{"name":"node_3d_transform_scene","order":4,"path":"scripts/node_3d_transform_scene/node_3d_transform_scene.yy",},
|
||||
{"name":"node_3d_transform","order":6,"path":"scripts/node_3d_transform/node_3d_transform.yy",},
|
||||
|
|
|
@ -1168,6 +1168,7 @@
|
|||
{"id":{"name":"mtl_reader","path":"scripts/mtl_reader/mtl_reader.yy",},},
|
||||
{"id":{"name":"network_data","path":"scripts/network_data/network_data.yy",},},
|
||||
{"id":{"name":"node_2d_light","path":"scripts/node_2d_light/node_2d_light.yy",},},
|
||||
{"id":{"name":"node_3d_bend","path":"scripts/node_3d_bend/node_3d_bend.yy",},},
|
||||
{"id":{"name":"node_3d_camera_set","path":"scripts/node_3d_camera_set/node_3d_camera_set.yy",},},
|
||||
{"id":{"name":"node_3d_camera","path":"scripts/node_3d_camera/node_3d_camera.yy",},},
|
||||
{"id":{"name":"node_3d_depth","path":"scripts/node_3d_depth/node_3d_depth.yy",},},
|
||||
|
|
|
@ -2,8 +2,7 @@ function __3dPlane() : __3dObject() constructor {
|
|||
VF = global.VF_POS_NORM_TEX_COL;
|
||||
render_type = pr_trianglelist;
|
||||
|
||||
self.normal = 0;
|
||||
|
||||
normal = 0;
|
||||
two_side = false;
|
||||
|
||||
static initModel = function() {
|
||||
|
|
69
scripts/node_3d_bend/node_3d_bend.gml
Normal file
69
scripts/node_3d_bend/node_3d_bend.gml
Normal file
|
@ -0,0 +1,69 @@
|
|||
function Node_3D_Bend(_x, _y, _group = noone) : Node_3D_Modifier(_x, _y, _group) constructor {
|
||||
name = "Bend Mesh";
|
||||
|
||||
var i = in_mesh;
|
||||
newInput(i+0, nodeValue_Enum_Button("Axis", self, 0, [ "X", "Y", "Z"]));
|
||||
|
||||
newInput(i+1, nodeValue_Float("Radius", self, 1));
|
||||
|
||||
newInput(i+2, nodeValue_Float("Amount", self, 1));
|
||||
|
||||
newInput(i+3, nodeValue_Vec3("Origin", self, [ 0, 0, 0 ]));
|
||||
|
||||
newInput(i+4, nodeValue_Bool("Recalculate normal", self, true));
|
||||
|
||||
input_display_list = [
|
||||
["Mesh", false], 0,
|
||||
["Bend", false], i+0, i+3, i+1, i+2, i+4,
|
||||
];
|
||||
|
||||
static processData = function(_output, _data, _output_index, _array_index = 0) {
|
||||
var _obj = _data[0];
|
||||
var _axs = _data[in_mesh + 0];
|
||||
var _rad = _data[in_mesh + 1];
|
||||
var _amo = _data[in_mesh + 2];
|
||||
var _ori = _data[in_mesh + 3];
|
||||
var _nrm = _data[in_mesh + 4];
|
||||
|
||||
if(!is_instanceof(_obj, __3dObject)) return noone;
|
||||
|
||||
var _res = _obj.clone();
|
||||
var _vlen = array_length(_res.vertex);
|
||||
var _tarr = array_create_ext(_vlen, function(i) /*=>*/ {return i});
|
||||
|
||||
for( var i = 0, n = array_length(_tarr); i < n; i++ ) {
|
||||
var _vi = _tarr[i];
|
||||
var _vt = _res.vertex[_vi];
|
||||
|
||||
for( var j = 0, m = array_length(_vt); j < m; j++ ) {
|
||||
var _v = _vt[j];
|
||||
|
||||
_v.x += 1;
|
||||
_v.y += 1;
|
||||
_v.z += 1;
|
||||
}
|
||||
|
||||
if(_nrm)
|
||||
for( var j = 0, m = array_length(_vt); j < m; j += 3 ) {
|
||||
var _v0 = _vt[j + 0];
|
||||
var _v1 = _vt[j + 1];
|
||||
var _v2 = _vt[j + 2];
|
||||
|
||||
var _nres = d3_cross_product_element(_v1.x - _v0.x, _v1.y - _v0.y, _v1.z - _v0.z,
|
||||
_v0.x - _v2.x, _v0.y - _v2.y, _v0.z - _v2.z);
|
||||
|
||||
var _nnl = sqrt(_nres[0] * _nres[0] + _nres[1] * _nres[1] + _nres[2] * _nres[2]);
|
||||
_nres[0] /= _nnl;
|
||||
_nres[1] /= _nnl;
|
||||
_nres[2] /= _nnl;
|
||||
|
||||
_v0.nx = _nres[0]; _v0.ny = _nres[1]; _v0.nz = _nres[2];
|
||||
_v1.nx = _nres[0]; _v1.ny = _nres[1]; _v1.nz = _nres[2];
|
||||
_v2.nx = _nres[0]; _v2.ny = _nres[1]; _v2.nz = _nres[2];
|
||||
}
|
||||
}
|
||||
|
||||
_res.VB = _res.build();
|
||||
return _res;
|
||||
}
|
||||
}
|
14
scripts/node_3d_bend/node_3d_bend.yy
Normal file
14
scripts/node_3d_bend/node_3d_bend.yy
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"$GMScript":"v1",
|
||||
"%Name":"node_3d_bend",
|
||||
"isCompatibility":false,
|
||||
"isDnD":false,
|
||||
"name":"node_3d_bend",
|
||||
"parent":{
|
||||
"name":"d3d_modifier",
|
||||
"path":"folders/nodes/data/3D/d3d_modifier.yy",
|
||||
},
|
||||
"resourceType":"GMScript",
|
||||
"resourceVersion":"2.0",
|
||||
"tags":[],
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
function Node_3D_Displace(_x, _y, _group = noone) : Node_3D_Modifier(_x, _y, _group) constructor {
|
||||
name = "Displace vertex";
|
||||
name = "Displace Vertex";
|
||||
|
||||
newInput(in_mesh + 0, nodeValue_D3Material("Displace Texture", self, new __d3dMaterial()))
|
||||
.setVisible(true, true);
|
||||
|
|
|
@ -15,11 +15,20 @@ function Node_Stack(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
|||
newInput(3, nodeValue_Padding("Padding", self, [ 0, 0, 0, 0 ]))
|
||||
.rejectArray();
|
||||
|
||||
newInput(4, nodeValue_Enum_Scroll("Blend Mode", self, 0, BLEND_TYPES))
|
||||
.rejectArray();
|
||||
|
||||
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
|
||||
|
||||
newOutput(1, nodeValue_Output("Atlas data", self, VALUE_TYPE.atlas, []));
|
||||
|
||||
temp_surface = [ noone, noone ];
|
||||
input_display_list = [
|
||||
["Stack", false], 0, 1, 2, 3,
|
||||
["Render", false], 4,
|
||||
["Surfaces", false],
|
||||
]
|
||||
|
||||
temp_surface = [ noone, noone, noone ];
|
||||
|
||||
static createNewInput = function() {
|
||||
var index = array_length(inputs);
|
||||
|
@ -31,18 +40,19 @@ function Node_Stack(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
|||
|
||||
attribute_surface_depth();
|
||||
|
||||
static step = function() { #region
|
||||
static step = function() {
|
||||
var _axis = getInputData(0);
|
||||
|
||||
inputs[1].setVisible(_axis != 2);
|
||||
inputs[2].setVisible(_axis != 2);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static update = function(frame = CURRENT_FRAME) { #region
|
||||
static update = function(frame = CURRENT_FRAME) {
|
||||
var _axis = getInputData(0);
|
||||
var _alig = getInputData(1);
|
||||
var _spac = getInputData(2);
|
||||
var _padd = getInputData(3);
|
||||
var _blnd = getInputData(4);
|
||||
|
||||
var ww = 0;
|
||||
var hh = 0;
|
||||
|
@ -78,11 +88,9 @@ function Node_Stack(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
|||
var _outSurf = outputs[0].getValue();
|
||||
_outSurf = surface_verify(_outSurf, ow, oh, attrDepth());
|
||||
|
||||
temp_surface[0] = surface_verify(temp_surface[0], ow, oh, attrDepth());
|
||||
temp_surface[1] = surface_verify(temp_surface[1], ow, oh, attrDepth());
|
||||
|
||||
surface_clear(temp_surface[0]);
|
||||
surface_clear(temp_surface[1]);
|
||||
for( var i = 0, n = array_length(temp_surface); i < n; i++ )
|
||||
temp_surface[i] = surface_verify(temp_surface[i], ow, oh, attrDepth());
|
||||
blend_temp_surface = temp_surface[2];
|
||||
|
||||
var atlas = [];
|
||||
var ppind = 0;
|
||||
|
@ -103,35 +111,31 @@ function Node_Stack(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
|||
case fa_center: sy = hh / 2 - sh / 2; break;
|
||||
case fa_right: sy = hh - sh; break;
|
||||
}
|
||||
|
||||
} else if(_axis == 1) {
|
||||
switch(_alig) {
|
||||
case fa_left: sx = 0; break;
|
||||
case fa_center: sx = ww / 2 - sw / 2; break;
|
||||
case fa_right: sx = ww - sw; break;
|
||||
}
|
||||
|
||||
} else if(_axis == 2) {
|
||||
sx = ww / 2 - sw / 2;
|
||||
sy = hh / 2 - sh / 2;
|
||||
}
|
||||
|
||||
var px = sx + _padd[PADDING.left];
|
||||
var py = sy + _padd[PADDING.top]
|
||||
|
||||
array_push(atlas, new SurfaceAtlas(_surf[j], sx, sy));
|
||||
surface_set_shader(temp_surface[!ppind], sh_draw_surface);
|
||||
DRAW_CLEAR
|
||||
BLEND_OVERRIDE
|
||||
shader_set_f("dimension", ow, oh);
|
||||
|
||||
shader_set_surface("fore", _surf[j]);
|
||||
shader_set_f("fdimension", sw, sh);
|
||||
shader_set_f("position", sx + _padd[PADDING.left], sy + _padd[PADDING.top]);
|
||||
|
||||
draw_surface_safe(temp_surface[ppind]);
|
||||
|
||||
BLEND_NORMAL
|
||||
|
||||
surface_set_shader(temp_surface[!ppind], noone, true, BLEND.over);
|
||||
draw_surface_blend_ext(temp_surface[ppind], _surf[j], px, py, 1, 1, 0, c_white, 1, _blnd);
|
||||
surface_reset_shader();
|
||||
|
||||
|
||||
ppind = !ppind;
|
||||
|
||||
if(_axis == 0) sx += sw + _spac;
|
||||
if(_axis == 0) sx += sw + _spac;
|
||||
else if(_axis == 1) sy += sh + _spac;
|
||||
}
|
||||
}
|
||||
|
@ -147,6 +151,6 @@ function Node_Stack(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
|||
|
||||
outputs[0].setValue(_outSurf);
|
||||
outputs[1].setValue(atlas);
|
||||
} #endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Simple passthrough fragment shader
|
||||
//
|
||||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
||||
|
|
Loading…
Reference in a new issue