mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-01-24 11:58:05 +01:00
3d wireframe
This commit is contained in:
parent
cba206ba16
commit
aaa74eed52
16 changed files with 467 additions and 288 deletions
|
@ -190,9 +190,8 @@
|
||||||
{"name":"sprites","order":7,"path":"folders/panels/preview/sprites.yy",},
|
{"name":"sprites","order":7,"path":"folders/panels/preview/sprites.yy",},
|
||||||
{"name":"shader","order":331,"path":"folders/shader.yy",},
|
{"name":"shader","order":331,"path":"folders/shader.yy",},
|
||||||
{"name":"3d","order":1,"path":"folders/shader/3d.yy",},
|
{"name":"3d","order":1,"path":"folders/shader/3d.yy",},
|
||||||
{"name":"2d effect","order":12,"path":"folders/shader/3d/2d effect.yy",},
|
{"name":"legacy","order":1,"path":"folders/shader/3d/legacy.yy",},
|
||||||
{"name":"legacy","order":13,"path":"folders/shader/3d/legacy.yy",},
|
{"name":"ssao","order":2,"path":"folders/shader/3d/ssao.yy",},
|
||||||
{"name":"ssao","order":14,"path":"folders/shader/3d/ssao.yy",},
|
|
||||||
{"name":"blend","order":2,"path":"folders/shader/blend.yy",},
|
{"name":"blend","order":2,"path":"folders/shader/blend.yy",},
|
||||||
{"name":"canvas","order":3,"path":"folders/shader/canvas.yy",},
|
{"name":"canvas","order":3,"path":"folders/shader/canvas.yy",},
|
||||||
{"name":"color_picker","order":4,"path":"folders/shader/color_picker.yy",},
|
{"name":"color_picker","order":4,"path":"folders/shader/color_picker.yy",},
|
||||||
|
@ -1525,19 +1524,20 @@
|
||||||
{"name":"sh_cross_section","order":25,"path":"shaders/sh_cross_section/sh_cross_section.yy",},
|
{"name":"sh_cross_section","order":25,"path":"shaders/sh_cross_section/sh_cross_section.yy",},
|
||||||
{"name":"sh_curve_hsv","order":53,"path":"shaders/sh_curve_hsv/sh_curve_hsv.yy",},
|
{"name":"sh_curve_hsv","order":53,"path":"shaders/sh_curve_hsv/sh_curve_hsv.yy",},
|
||||||
{"name":"sh_curve","order":19,"path":"shaders/sh_curve/sh_curve.yy",},
|
{"name":"sh_curve","order":19,"path":"shaders/sh_curve/sh_curve.yy",},
|
||||||
{"name":"sh_d3d_3d_transform","order":15,"path":"shaders/sh_d3d_3d_transform/sh_d3d_3d_transform.yy",},
|
{"name":"sh_d3d_3d_transform","order":16,"path":"shaders/sh_d3d_3d_transform/sh_d3d_3d_transform.yy",},
|
||||||
{"name":"sh_d3d_background","order":8,"path":"shaders/sh_d3d_background/sh_d3d_background.yy",},
|
{"name":"sh_d3d_background","order":12,"path":"shaders/sh_d3d_background/sh_d3d_background.yy",},
|
||||||
{"name":"sh_d3d_extrude_extends","order":11,"path":"shaders/sh_d3d_extrude_extends/sh_d3d_extrude_extends.yy",},
|
{"name":"sh_d3d_default","order":3,"path":"shaders/sh_d3d_default/sh_d3d_default.yy",},
|
||||||
{"name":"sh_d3d_geometry","order":9,"path":"shaders/sh_d3d_geometry/sh_d3d_geometry.yy",},
|
{"name":"sh_d3d_extrude_extends","order":15,"path":"shaders/sh_d3d_extrude_extends/sh_d3d_extrude_extends.yy",},
|
||||||
{"name":"sh_d3d_grid_view","order":1,"path":"shaders/sh_d3d_grid_view/sh_d3d_grid_view.yy",},
|
{"name":"sh_d3d_geometry","order":13,"path":"shaders/sh_d3d_geometry/sh_d3d_geometry.yy",},
|
||||||
{"name":"sh_d3d_normal_blur","order":10,"path":"shaders/sh_d3d_normal_blur/sh_d3d_normal_blur.yy",},
|
{"name":"sh_d3d_grid_view","order":5,"path":"shaders/sh_d3d_grid_view/sh_d3d_grid_view.yy",},
|
||||||
{"name":"sh_d3d_normal","order":5,"path":"shaders/sh_d3d_normal/sh_d3d_normal.yy",},
|
{"name":"sh_d3d_normal_blur","order":14,"path":"shaders/sh_d3d_normal_blur/sh_d3d_normal_blur.yy",},
|
||||||
{"name":"sh_d3d_outline","order":3,"path":"shaders/sh_d3d_outline/sh_d3d_outline.yy",},
|
{"name":"sh_d3d_normal","order":9,"path":"shaders/sh_d3d_normal/sh_d3d_normal.yy",},
|
||||||
{"name":"sh_d3d_shadow_cube_depth","order":7,"path":"shaders/sh_d3d_shadow_cube_depth/sh_d3d_shadow_cube_depth.yy",},
|
{"name":"sh_d3d_outline","order":7,"path":"shaders/sh_d3d_outline/sh_d3d_outline.yy",},
|
||||||
{"name":"sh_d3d_shadow_depth","order":6,"path":"shaders/sh_d3d_shadow_depth/sh_d3d_shadow_depth.yy",},
|
{"name":"sh_d3d_shadow_cube_depth","order":11,"path":"shaders/sh_d3d_shadow_cube_depth/sh_d3d_shadow_cube_depth.yy",},
|
||||||
{"name":"sh_d3d_silhouette","order":2,"path":"shaders/sh_d3d_silhouette/sh_d3d_silhouette.yy",},
|
{"name":"sh_d3d_shadow_depth","order":10,"path":"shaders/sh_d3d_shadow_depth/sh_d3d_shadow_depth.yy",},
|
||||||
|
{"name":"sh_d3d_silhouette","order":6,"path":"shaders/sh_d3d_silhouette/sh_d3d_silhouette.yy",},
|
||||||
{"name":"sh_d3d_ssao_blur","order":1,"path":"shaders/sh_d3d_ssao_blur/sh_d3d_ssao_blur.yy",},
|
{"name":"sh_d3d_ssao_blur","order":1,"path":"shaders/sh_d3d_ssao_blur/sh_d3d_ssao_blur.yy",},
|
||||||
{"name":"sh_d3d_wireframe","order":4,"path":"shaders/sh_d3d_wireframe/sh_d3d_wireframe.yy",},
|
{"name":"sh_d3d_wireframe","order":8,"path":"shaders/sh_d3d_wireframe/sh_d3d_wireframe.yy",},
|
||||||
{"name":"sh_de_corner","order":21,"path":"shaders/sh_de_corner/sh_de_corner.yy",},
|
{"name":"sh_de_corner","order":21,"path":"shaders/sh_de_corner/sh_de_corner.yy",},
|
||||||
{"name":"sh_de_stray","order":22,"path":"shaders/sh_de_stray/sh_de_stray.yy",},
|
{"name":"sh_de_stray","order":22,"path":"shaders/sh_de_stray/sh_de_stray.yy",},
|
||||||
{"name":"sh_default","order":6,"path":"shaders/sh_default/sh_default.yy",},
|
{"name":"sh_default","order":6,"path":"shaders/sh_default/sh_default.yy",},
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
/// @description
|
/// @description
|
||||||
if !ready exit;
|
if !ready exit;
|
||||||
|
|
||||||
|
if(!is_undefined(content) && content != noone)
|
||||||
|
content.preDraw();
|
||||||
|
|
||||||
DIALOG_PREDRAW
|
DIALOG_PREDRAW
|
||||||
DIALOG_WINCLEAR
|
DIALOG_WINCLEAR
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
/// @description
|
/// @description
|
||||||
if(!is_undefined(content) && content != noone)
|
if(!is_undefined(content) && content != noone)
|
||||||
content.drawGUI();
|
content.drawGUI();
|
||||||
|
|
||||||
event_inherited();
|
event_inherited();
|
|
@ -42,11 +42,26 @@ function Panel_Linear_Setting() : PanelContent() constructor {
|
||||||
selecting_menu = noone;
|
selecting_menu = noone;
|
||||||
properties = [];
|
properties = [];
|
||||||
|
|
||||||
static setHeight = function() { h = ui(12 + 36 * array_length(properties)); }
|
prop_height = ui(32);
|
||||||
|
curr_height = 0;
|
||||||
|
|
||||||
static drawSettings = function(panel) {
|
static setHeight = function() { h = prop_height * array_length(properties) + ui(16); }
|
||||||
var yy = ui(24);
|
static resetHeight = function(_h) {
|
||||||
var th = ui(36);
|
if(h == _h) return;
|
||||||
|
|
||||||
|
if(in_dialog) {
|
||||||
|
panel.dialog_y -= _h - h;
|
||||||
|
panel.dialog_h = _h
|
||||||
|
h = _h;
|
||||||
|
panel.contentResize();
|
||||||
|
}
|
||||||
|
|
||||||
|
h = _h;
|
||||||
|
}
|
||||||
|
|
||||||
|
static drawSettings = function() {
|
||||||
|
var yy = ui(4);
|
||||||
|
var th = prop_height;
|
||||||
var ww = max(wdgw, w * 0.5);
|
var ww = max(wdgw, w * 0.5);
|
||||||
var wh = TEXTBOX_HEIGHT;
|
var wh = TEXTBOX_HEIGHT;
|
||||||
|
|
||||||
|
@ -56,17 +71,53 @@ function Panel_Linear_Setting() : PanelContent() constructor {
|
||||||
for( var i = 0, n = array_length(properties); i < n; i++ ) {
|
for( var i = 0, n = array_length(properties); i < n; i++ ) {
|
||||||
var _prop = properties[i];
|
var _prop = properties[i];
|
||||||
|
|
||||||
|
if(is_array(_prop)) {
|
||||||
|
yy += bool(i) * ui(4);
|
||||||
|
|
||||||
|
var txt = __txt(_prop[0]);
|
||||||
|
var coll = _prop[1];
|
||||||
|
|
||||||
|
var lbx = ui(4);
|
||||||
|
var lby = ui(0);
|
||||||
|
var lbh = th - ui(4);
|
||||||
|
var lbw = w - ui(8);
|
||||||
|
|
||||||
|
if(pHOVER && point_in_rectangle(mx, my, lbx, yy, lbx + lbw, yy + lbh)) {
|
||||||
|
draw_sprite_stretched_ext(THEME.s_box_r5_clr, 0, lbx, yy, lbw, lbh, COLORS.panel_inspector_group_hover, 1);
|
||||||
|
if(mouse_press(mb_left, pFOCUS)) _prop[@ 1] = !coll;
|
||||||
|
|
||||||
|
} else
|
||||||
|
draw_sprite_stretched_ext(THEME.s_box_r5_clr, 0, lbx, yy, lbw, lbh, CDEF.main_ltgrey, 1);
|
||||||
|
|
||||||
|
draw_sprite_ui(THEME.arrow, coll * 3, lbx + ui(16), yy + lbh / 2, 1, 1, 0, COLORS.panel_inspector_group_bg, 1);
|
||||||
|
draw_set_text(f_p2, fa_left, fa_center, COLORS.panel_inspector_group_bg, 1);
|
||||||
|
draw_text_add(lbx + ui(32), yy + lbh / 2, txt);
|
||||||
|
draw_set_alpha(1);
|
||||||
|
|
||||||
|
if(coll) { // skip
|
||||||
|
var j = i + 1;
|
||||||
|
while(j < n) {
|
||||||
|
if(is_array(properties[j])) break;
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
i = j - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
yy += lbh + (!coll) * ui(4);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if(is_instanceof(_prop, __Panel_Linear_Setting_Label)) {
|
if(is_instanceof(_prop, __Panel_Linear_Setting_Label)) {
|
||||||
var _text = _prop.name;
|
var _text = _prop.name;
|
||||||
var _spr = _prop.sprite;
|
var _spr = _prop.sprite;
|
||||||
var _ind = _prop.index;
|
var _ind = _prop.index;
|
||||||
var _colr = _prop.color;
|
var _colr = _prop.color;
|
||||||
|
|
||||||
draw_sprite_stretched_ext(THEME.s_box_r5_clr, 0, ui(4), yy - th / 2 + ui(2), w - ui(8), th - ui(4), _colr, 1);
|
draw_sprite_stretched_ext(THEME.s_box_r5_clr, 0, ui(4), yy + ui(2), w - ui(8), th - ui(4), _colr, 1);
|
||||||
draw_sprite_ui(_spr, _ind, ui(4) + th / 2, yy);
|
draw_sprite_ui(_spr, _ind, ui(4) + th / 2, yy + th / 2);
|
||||||
|
|
||||||
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text);
|
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text);
|
||||||
draw_text_add(ui(4) + th, yy, _text);
|
draw_text_add(ui(4) + th, yy + th / 2, _text);
|
||||||
|
|
||||||
yy += th;
|
yy += th;
|
||||||
continue;
|
continue;
|
||||||
|
@ -82,14 +133,14 @@ function Panel_Linear_Setting() : PanelContent() constructor {
|
||||||
_widg.register();
|
_widg.register();
|
||||||
|
|
||||||
var _whover = false;
|
var _whover = false;
|
||||||
if(pHOVER && point_in_rectangle(mx, my, 0, yy - th / 2, w, yy + th / 2)) {
|
if(pHOVER && point_in_rectangle(mx, my, 0, yy, w, yy + th)) {
|
||||||
bg_y_to = yy - th / 2;
|
bg_y_to = yy;
|
||||||
_hov = true;
|
_hov = true;
|
||||||
_whover = true;
|
_whover = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text);
|
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text);
|
||||||
draw_text_add(ui(16), yy, _text);
|
draw_text_add(ui(16), yy + th / 2, _text);
|
||||||
|
|
||||||
var _x1 = w - ui(8);
|
var _x1 = w - ui(8);
|
||||||
var _wdw = ww;
|
var _wdw = ww;
|
||||||
|
@ -97,7 +148,9 @@ function Panel_Linear_Setting() : PanelContent() constructor {
|
||||||
if(_prop.getDefault != noone)
|
if(_prop.getDefault != noone)
|
||||||
_wdw -= ui(32 + 8);
|
_wdw -= ui(32 + 8);
|
||||||
|
|
||||||
var params = new widgetParam(_x1 - ww, yy - wh / 2, _wdw, wh, _data, {}, [ mx, my ], x, y);
|
var params = new widgetParam(_x1 - ww, yy + th / 2 - wh / 2, _wdw, wh, _data, {}, [ mx, my ], x, y)
|
||||||
|
.setFont(f_p2);
|
||||||
|
|
||||||
if(is_instanceof(_widg, checkBox)) {
|
if(is_instanceof(_widg, checkBox)) {
|
||||||
params.halign = fa_center;
|
params.halign = fa_center;
|
||||||
params.valign = fa_center;
|
params.valign = fa_center;
|
||||||
|
@ -128,7 +181,7 @@ function Panel_Linear_Setting() : PanelContent() constructor {
|
||||||
var _th = line_get_height();
|
var _th = line_get_height();
|
||||||
|
|
||||||
var _hx = _x1 - ww - ui(16);
|
var _hx = _x1 - ww - ui(16);
|
||||||
var _hy = yy + ui(2);
|
var _hy = yy + th / 2 + ui(2);
|
||||||
|
|
||||||
var _bx = _hx - _tw - ui(4);
|
var _bx = _hx - _tw - ui(4);
|
||||||
var _by = _hy - _th / 2 - ui(3);
|
var _by = _hy - _th / 2 - ui(3);
|
||||||
|
@ -153,7 +206,7 @@ function Panel_Linear_Setting() : PanelContent() constructor {
|
||||||
var _defVal = is_method(_prop.getDefault)? _prop.getDefault() : _prop.getDefault;
|
var _defVal = is_method(_prop.getDefault)? _prop.getDefault() : _prop.getDefault;
|
||||||
var _bs = ui(32);
|
var _bs = ui(32);
|
||||||
var _bx = _x1 - _bs;
|
var _bx = _x1 - _bs;
|
||||||
var _by = yy - _bs / 2;
|
var _by = yy + th / 2 - _bs / 2;
|
||||||
|
|
||||||
if(isEqual(_data, _defVal))
|
if(isEqual(_data, _defVal))
|
||||||
draw_sprite_ext(THEME.refresh_16, 0, _bx + _bs / 2, _by + _bs / 2, 1, 1, 0, COLORS._main_icon_dark);
|
draw_sprite_ext(THEME.refresh_16, 0, _bx + _bs / 2, _by + _bs / 2, 1, 1, 0, COLORS._main_icon_dark);
|
||||||
|
@ -169,9 +222,7 @@ function Panel_Linear_Setting() : PanelContent() constructor {
|
||||||
}
|
}
|
||||||
|
|
||||||
bg_a = lerp_float(bg_a, _hov, 2);
|
bg_a = lerp_float(bg_a, _hov, 2);
|
||||||
|
bg_y = bg_y == -1? bg_y_to : lerp_float(bg_y, bg_y_to, 2);
|
||||||
if(bg_y == -1) bg_y = bg_y_to;
|
|
||||||
else bg_y = lerp_float(bg_y, bg_y_to, 2);
|
|
||||||
|
|
||||||
if(hk_editing != noone) {
|
if(hk_editing != noone) {
|
||||||
if(keyboard_check_pressed(vk_enter)) hk_editing = noone;
|
if(keyboard_check_pressed(vk_enter)) hk_editing = noone;
|
||||||
|
@ -179,7 +230,13 @@ function Panel_Linear_Setting() : PanelContent() constructor {
|
||||||
|
|
||||||
if(keyboard_check_pressed(vk_escape)) hk_editing = noone;
|
if(keyboard_check_pressed(vk_escape)) hk_editing = noone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
curr_height = yy + ui(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawContent(panel) { drawSettings(panel); }
|
function drawContent() { drawSettings(); }
|
||||||
|
|
||||||
|
function preDraw() {
|
||||||
|
resetHeight(curr_height);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,8 @@
|
||||||
#region vertex format
|
#region vertex format
|
||||||
|
vertex_format_begin();
|
||||||
|
vertex_format_add_position_3d();
|
||||||
|
global.VF_POS = vertex_format_end();
|
||||||
|
|
||||||
vertex_format_begin();
|
vertex_format_begin();
|
||||||
vertex_format_add_position_3d();
|
vertex_format_add_position_3d();
|
||||||
vertex_format_add_color();
|
vertex_format_add_color();
|
||||||
|
@ -9,30 +13,31 @@
|
||||||
vertex_format_add_normal(); // x y z // 12
|
vertex_format_add_normal(); // x y z // 12
|
||||||
vertex_format_add_texcoord(); // u v // 8
|
vertex_format_add_texcoord(); // u v // 8
|
||||||
vertex_format_add_color(); // r g b a // 4
|
vertex_format_add_color(); // r g b a // 4
|
||||||
|
vertex_format_add_custom(vertex_type_float3, vertex_usage_texcoord); // x y z // 12 // barycentric
|
||||||
global.VF_POS_NORM_TEX_COL = vertex_format_end();
|
global.VF_POS_NORM_TEX_COL = vertex_format_end();
|
||||||
global.VF_POS_NORM_TEX_COL_size = 36;
|
global.VF_POS_NORM_TEX_COL_size = 48;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
function __3dObject() constructor {
|
function __3dObject() constructor {
|
||||||
|
object_counts = 1;
|
||||||
vertex = [];
|
vertex = [];
|
||||||
VB = [];
|
VB = [];
|
||||||
normal_vertex = [];
|
VF = global.VF_POS_COL;
|
||||||
object_counts = 1;
|
NVB = noone;
|
||||||
|
WVB = noone;
|
||||||
NVB = noone;
|
|
||||||
normal_draw_size = 0.2;
|
|
||||||
|
|
||||||
VF = global.VF_POS_COL;
|
|
||||||
render_type = pr_trianglelist;
|
|
||||||
|
|
||||||
custom_shader = noone;
|
|
||||||
|
|
||||||
transform = new __transform();
|
transform = new __transform();
|
||||||
size = new __vec3(1);
|
size = new __vec3(1);
|
||||||
|
|
||||||
|
normal_draw_size = 0.2;
|
||||||
|
render_type = pr_trianglelist;
|
||||||
|
|
||||||
|
custom_shader = noone;
|
||||||
|
texture_flip = false;
|
||||||
materials = [];
|
materials = [];
|
||||||
material_index = [];
|
material_index = [];
|
||||||
texture_flip = false;
|
|
||||||
|
////- Object
|
||||||
|
|
||||||
static checkParameter = function(params = {}, forceUpdate = false) {
|
static checkParameter = function(params = {}, forceUpdate = false) {
|
||||||
var _keys = struct_get_names(params);
|
var _keys = struct_get_names(params);
|
||||||
|
@ -56,60 +61,81 @@ function __3dObject() constructor {
|
||||||
|
|
||||||
static onParameterUpdate = function() {}
|
static onParameterUpdate = function() {}
|
||||||
|
|
||||||
|
////- Verticies
|
||||||
|
|
||||||
static generateNormal = function(_s = normal_draw_size) {
|
static generateNormal = function(_s = normal_draw_size) {
|
||||||
if(render_type != pr_trianglelist) return;
|
if(render_type != pr_trianglelist) return;
|
||||||
|
|
||||||
NVB = array_create(object_counts);
|
if(is_array(NVB)) array_foreach(NVB, function(v) /*=>*/ {return vertex_delete_buffer(v)});
|
||||||
|
NVB = array_verify(NVB, object_counts);
|
||||||
|
|
||||||
for( var i = 0; i < object_counts; i++ ) {
|
for( var i = 0; i < object_counts; i++ ) {
|
||||||
NVB[i] = vertex_create_buffer();
|
var _obj = vertex[i];
|
||||||
|
var _nvb = vertex_create_buffer();
|
||||||
|
|
||||||
vertex_begin(NVB[i], global.VF_POS_COL);
|
vertex_begin(_nvb, global.VF_POS_COL);
|
||||||
for( var j = 0, n = array_length(vertex[i]); j < n; j++ ) {
|
for( var j = 0, n = array_length(_obj); j < n; j++ ) {
|
||||||
var _v = vertex[i][j];
|
var _v = _obj[j];
|
||||||
|
|
||||||
vertex_position_3d(NVB[i], _v.x, _v.y, _v.z);
|
vertex_position_3d(_nvb, _v.x, _v.y, _v.z);
|
||||||
vertex_color(NVB[i], c_red, 1);
|
vertex_color(_nvb, c_red, 1);
|
||||||
|
|
||||||
vertex_position_3d(NVB[i], _v.x + _v.nx * _s, _v.y + _v.ny * _s, _v.z + _v.nz * _s);
|
vertex_position_3d(_nvb, _v.x + _v.nx * _s, _v.y + _v.ny * _s, _v.z + _v.nz * _s);
|
||||||
vertex_color(NVB[i], c_red, 1);
|
vertex_color(_nvb, c_red, 1);
|
||||||
}
|
}
|
||||||
vertex_end(NVB[i]);
|
vertex_end(_nvb);
|
||||||
|
NVB[i] = _nvb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static buildVertex = function(_vertex) {
|
static buildVertex = function(_vertex) {
|
||||||
var _buffer = vertex_create_buffer();
|
var _buffer = vertex_create_buffer();
|
||||||
vertex_begin(_buffer, VF);
|
vertex_begin(_buffer, VF);
|
||||||
switch(VF) {
|
|
||||||
case global.VF_POS_COL :
|
switch(VF) {
|
||||||
for( var i = 0, n = array_length(_vertex); i < n; i++ ) {
|
case global.VF_POS_COL :
|
||||||
var v = _vertex[i];
|
for( var i = 0, n = array_length(_vertex); i < n; i++ ) {
|
||||||
vertex_position_3d(_buffer, v.x, v.y, v.z);
|
var v = _vertex[i];
|
||||||
vertex_color(_buffer, v.color, v.alpha);
|
vertex_position_3d( _buffer, v.x, v.y, v.z);
|
||||||
}
|
vertex_color( _buffer, v.color, v.alpha);
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case global.VF_POS_NORM_TEX_COL :
|
||||||
|
for( var i = 0, n = array_length(_vertex); i < n; i += 3 ) {
|
||||||
|
var v0 = _vertex[i + 0];
|
||||||
|
var v1 = _vertex[i + 1];
|
||||||
|
var v2 = _vertex[i + 2];
|
||||||
|
|
||||||
case global.VF_POS_NORM_TEX_COL :
|
vertex_position_3d( _buffer, v0.x, v0.y, v0.z);
|
||||||
for( var i = 0, n = array_length(_vertex); i < n; i++ ) {
|
vertex_normal( _buffer, v0.nx, v0.ny, v0.nz);
|
||||||
var v = _vertex[i];
|
vertex_texcoord( _buffer, v0.u, v0.v);
|
||||||
vertex_position_3d(_buffer, v.x, v.y, v.z);
|
vertex_color( _buffer, v0.color, v0.alpha);
|
||||||
vertex_normal(_buffer, v.nx, v.ny, v.nz);
|
vertex_float3( _buffer, 255, 0, 0);
|
||||||
vertex_texcoord(_buffer, v.u, v.v);
|
|
||||||
vertex_color(_buffer, v.color, v.alpha);
|
vertex_position_3d( _buffer, v1.x, v1.y, v1.z);
|
||||||
}
|
vertex_normal( _buffer, v1.nx, v1.ny, v1.nz);
|
||||||
break;
|
vertex_texcoord( _buffer, v1.u, v1.v);
|
||||||
}
|
vertex_color( _buffer, v1.color, v1.alpha);
|
||||||
|
vertex_float3( _buffer, 0, 255, 0);
|
||||||
|
|
||||||
|
vertex_position_3d( _buffer, v2.x, v2.y, v2.z);
|
||||||
|
vertex_normal( _buffer, v2.nx, v2.ny, v2.nz);
|
||||||
|
vertex_texcoord( _buffer, v2.u, v2.v);
|
||||||
|
vertex_color( _buffer, v2.color, v2.alpha);
|
||||||
|
vertex_float3( _buffer, 0, 0, 255);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
vertex_end(_buffer);
|
vertex_end(_buffer);
|
||||||
|
|
||||||
return _buffer;
|
return _buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static build = function(_buffer = VB, _vertex = vertex, counts = object_counts) {
|
static build = function(_buffer = VB, _vertex = vertex, counts = object_counts) {
|
||||||
if(is_array(_buffer)) {
|
if(is_array(_buffer)) array_foreach(_buffer, function(b) /*=>*/ { if(b != noone) vertex_delete_buffer(b); });
|
||||||
for( var i = 0, n = array_length(_buffer); i < n; i++ )
|
else if(_buffer != noone) vertex_delete_buffer(_buffer);
|
||||||
if(_buffer[i] != noone) vertex_delete_buffer(_buffer[i])
|
|
||||||
} else if(_buffer != noone) vertex_delete_buffer(_buffer);
|
|
||||||
|
|
||||||
if(array_empty(_vertex)) return noone;
|
if(array_empty(_vertex)) return noone;
|
||||||
|
|
||||||
|
@ -120,17 +146,14 @@ function __3dObject() constructor {
|
||||||
return _res;
|
return _res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////- Submit
|
||||||
|
|
||||||
static preSubmitVertex = function(scene = {}) {}
|
static preSubmitVertex = function(scene = {}) {}
|
||||||
static postSubmitVertex = function(scene = {}) {}
|
static postSubmitVertex = function(scene = {}) {}
|
||||||
|
|
||||||
static getCenter = function() { return new __vec3(transform.position.x, transform.position.y, transform.position.z); }
|
static getCenter = function() { return new __vec3(transform.position.x, transform.position.y, transform.position.z); }
|
||||||
static getBBOX = function() { return new __bbox3D(size.multiplyVec(transform.scale).multiply(-0.5), size.multiplyVec(transform.scale).multiply(0.5)); }
|
static getBBOX = function() { return new __bbox3D(size.multiplyVec(transform.scale).multiply(-0.5), size.multiplyVec(transform.scale).multiply(0.5)); }
|
||||||
|
|
||||||
#region params
|
|
||||||
defDrawParam = { wireframe: false };
|
|
||||||
defDrawParamW = { wireframe: true };
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
static submit = function(scene = {}, shader = noone) { submitVertex(scene, shader); }
|
static submit = function(scene = {}, shader = noone) { submitVertex(scene, shader); }
|
||||||
static submitUI = function(scene = {}, shader = noone) { submitVertex(scene, shader); }
|
static submitUI = function(scene = {}, shader = noone) { submitVertex(scene, shader); }
|
||||||
static submitSel = function(scene = {}, shader = noone) {
|
static submitSel = function(scene = {}, shader = noone) {
|
||||||
|
@ -142,17 +165,17 @@ function __3dObject() constructor {
|
||||||
static submitShader = function(scene = {}, shader = noone) {}
|
static submitShader = function(scene = {}, shader = noone) {}
|
||||||
static submitShadow = function(scene = {}, object = noone) {}
|
static submitShadow = function(scene = {}, object = noone) {}
|
||||||
|
|
||||||
static submitVertex = function(scene = {}, shader = noone, param = defDrawParam) {
|
static submitVertex = function(scene = {}, shader = noone) {
|
||||||
var _shader = sh_d3d_default;
|
var _shader;
|
||||||
|
|
||||||
switch(VF) {
|
switch(VF) {
|
||||||
case global.VF_POS_NORM_TEX_COL: _shader = sh_d3d_default; break;
|
case global.VF_POS_COL: _shader = sh_d3d_wireframe; break;
|
||||||
case global.VF_POS_COL: _shader = sh_d3d_wireframe; break;
|
case global.VF_POS_NORM_TEX_COL:
|
||||||
|
default : _shader = sh_d3d_default; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(custom_shader != noone) _shader = custom_shader;
|
if(custom_shader != noone) _shader = custom_shader;
|
||||||
if(shader != noone) _shader = shader;
|
if(shader != noone) _shader = shader;
|
||||||
|
|
||||||
if(!is_undefined(shader)) shader_set(_shader);
|
if(!is_undefined(shader)) shader_set(_shader);
|
||||||
|
|
||||||
preSubmitVertex(scene);
|
preSubmitVertex(scene);
|
||||||
|
@ -160,7 +183,6 @@ function __3dObject() constructor {
|
||||||
matrix_set(matrix_world, matrix_stack_top());
|
matrix_set(matrix_world, matrix_stack_top());
|
||||||
|
|
||||||
gpu_set_tex_repeat(true);
|
gpu_set_tex_repeat(true);
|
||||||
|
|
||||||
for( var i = 0, n = array_length(VB); i < n; i++ ) {
|
for( var i = 0, n = array_length(VB); i < n; i++ ) {
|
||||||
var _ind = array_safe_get_fast(material_index, i, i);
|
var _ind = array_safe_get_fast(material_index, i, i);
|
||||||
var _mat = array_safe_get_fast(materials, _ind, noone);
|
var _mat = array_safe_get_fast(materials, _ind, noone);
|
||||||
|
@ -189,7 +211,6 @@ function __3dObject() constructor {
|
||||||
|
|
||||||
vertex_submit(VB[i], render_type, _tex);
|
vertex_submit(VB[i], render_type, _tex);
|
||||||
}
|
}
|
||||||
|
|
||||||
gpu_set_tex_repeat(false);
|
gpu_set_tex_repeat(false);
|
||||||
|
|
||||||
if(!is_undefined(shader)) shader_reset();
|
if(!is_undefined(shader)) shader_reset();
|
||||||
|
@ -199,9 +220,7 @@ function __3dObject() constructor {
|
||||||
if(NVB != noone) {
|
if(NVB != noone) {
|
||||||
shader_set(sh_d3d_wireframe);
|
shader_set(sh_d3d_wireframe);
|
||||||
shader_set_color("blend", c_white);
|
shader_set_color("blend", c_white);
|
||||||
|
array_foreach(NVB, function(n) /*=>*/ {return vertex_submit(n, pr_linelist, -1)});
|
||||||
for( var i = 0, n = array_length(NVB); i < n; i++ )
|
|
||||||
vertex_submit(NVB[i], pr_linelist, -1);
|
|
||||||
shader_reset();
|
shader_reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,7 +230,9 @@ function __3dObject() constructor {
|
||||||
postSubmitVertex(scene);
|
postSubmitVertex(scene);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////- Actions
|
||||||
|
|
||||||
static clone = function(_vertex = true, cloneBuffer = false) {
|
static clone = function(_vertex = true, cloneBuffer = false) {
|
||||||
var _obj = new __3dObject();
|
var _obj = new __3dObject();
|
||||||
|
|
||||||
|
|
|
@ -35,31 +35,36 @@ function __3dScene(camera, name = "New scene") constructor {
|
||||||
self.camera = camera;
|
self.camera = camera;
|
||||||
self.name = name;
|
self.name = name;
|
||||||
|
|
||||||
apply_transform = false;
|
apply_transform = false;
|
||||||
custom_transform = new __transform();
|
custom_transform = new __transform();
|
||||||
|
|
||||||
lightAmbient = c_black;
|
lightAmbient = cola(c_black, 1);
|
||||||
lightDir_max = 16;
|
lightDir_max = 16;
|
||||||
lightDir_shadow_max = 4;
|
lightDir_shadow_max = 4;
|
||||||
lightPnt_max = 16;
|
lightPnt_max = 16;
|
||||||
lightPnt_shadow_max = 4;
|
lightPnt_shadow_max = 4;
|
||||||
|
|
||||||
cull_mode = cull_noculling;
|
cull_mode = cull_noculling;
|
||||||
enviroment_map = noone;
|
enviroment_map = noone;
|
||||||
gammaCorrection = true;
|
gammaCorrection = true;
|
||||||
|
|
||||||
draw_background = false;
|
|
||||||
|
|
||||||
defer_normal = true;
|
defer_normal = true;
|
||||||
defer_normal_radius = 0;
|
defer_normal_radius = 0;
|
||||||
|
|
||||||
show_normal = false;
|
draw_background = false;
|
||||||
|
show_normal = false;
|
||||||
|
show_wireframe = false;
|
||||||
|
wireframe_width = 1;
|
||||||
|
wireframe_color = cola(c_black, 1);
|
||||||
|
wireframe_aa = true;
|
||||||
|
wireframe_shade = false;
|
||||||
|
wireframe_only = false;
|
||||||
|
|
||||||
ssao_enabled = false;
|
ssao_enabled = false;
|
||||||
ssao_sample = 32;
|
ssao_sample = 32;
|
||||||
ssao_radius = 0.1;
|
ssao_radius = 0.1;
|
||||||
ssao_bias = 0.1;
|
ssao_bias = 0.1;
|
||||||
ssao_strength = 1.;
|
ssao_strength = 1.;
|
||||||
|
|
||||||
static reset = function() {
|
static reset = function() {
|
||||||
lightDir_count = 0;
|
lightDir_count = 0;
|
||||||
|
@ -88,11 +93,15 @@ function __3dScene(camera, name = "New scene") constructor {
|
||||||
lightPnt_shadowBias = [];
|
lightPnt_shadowBias = [];
|
||||||
} reset();
|
} reset();
|
||||||
|
|
||||||
|
////- Submit
|
||||||
|
|
||||||
static submit = function(object, shader = noone) { D3DSCENE_PRESUBMIT object.submit (self, shader); D3DSCENE_POSTSUBMIT }
|
static submit = function(object, shader = noone) { D3DSCENE_PRESUBMIT object.submit (self, shader); D3DSCENE_POSTSUBMIT }
|
||||||
static submitUI = function(object, shader = noone) { D3DSCENE_PRESUBMIT object.submitUI (self, shader); D3DSCENE_POSTSUBMIT }
|
static submitUI = function(object, shader = noone) { D3DSCENE_PRESUBMIT object.submitUI (self, shader); D3DSCENE_POSTSUBMIT }
|
||||||
static submitSel = function(object, shader = noone) { D3DSCENE_PRESUBMIT object.submitSel (self, shader); D3DSCENE_POSTSUBMIT }
|
static submitSel = function(object, shader = noone) { D3DSCENE_PRESUBMIT object.submitSel (self, shader); D3DSCENE_POSTSUBMIT }
|
||||||
static submitShader = function(object, shader = noone) { D3DSCENE_PRESUBMIT object.submitShader (self, shader); D3DSCENE_POSTSUBMIT }
|
static submitShader = function(object, shader = noone) { D3DSCENE_PRESUBMIT object.submitShader (self, shader); D3DSCENE_POSTSUBMIT }
|
||||||
|
|
||||||
|
////- Rendering
|
||||||
|
|
||||||
static deferPass = function(object, w, h, deferData = noone) {
|
static deferPass = function(object, w, h, deferData = noone) {
|
||||||
if(deferData == noone) deferData = {
|
if(deferData == noone) deferData = {
|
||||||
geometry_data: [ noone, noone, noone ],
|
geometry_data: [ noone, noone, noone ],
|
||||||
|
@ -189,11 +198,11 @@ function __3dScene(camera, name = "New scene") constructor {
|
||||||
surface_set_shader(_ssao_surf, sh_d3d_ssao);
|
surface_set_shader(_ssao_surf, sh_d3d_ssao);
|
||||||
shader_set_surface("vPosition", deferData.geometry_data[0]);
|
shader_set_surface("vPosition", deferData.geometry_data[0]);
|
||||||
shader_set_surface("vNormal", deferData.geometry_data[2]);
|
shader_set_surface("vNormal", deferData.geometry_data[2]);
|
||||||
shader_set_f("radius", ssao_radius);
|
shader_set_f("radius", ssao_radius);
|
||||||
shader_set_f("bias", ssao_bias);
|
shader_set_f("bias", ssao_bias);
|
||||||
shader_set_f("strength", ssao_strength * 2);
|
shader_set_f("strength", ssao_strength * 2);
|
||||||
shader_set_f("projMatrix", camera.getCombinedMatrix());
|
shader_set_f("projMatrix", camera.getCombinedMatrix());
|
||||||
shader_set_f("cameraPosition", camera.position.toArray());
|
shader_set_f("cameraPosition", camera.position.toArray());
|
||||||
|
|
||||||
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, _sw, _sh);
|
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, _sw, _sh);
|
||||||
surface_reset_shader();
|
surface_reset_shader();
|
||||||
|
@ -215,42 +224,43 @@ function __3dScene(camera, name = "New scene") constructor {
|
||||||
shader_set_i("use_8bit", OS == os_macosx);
|
shader_set_i("use_8bit", OS == os_macosx);
|
||||||
|
|
||||||
#region ---- background ----
|
#region ---- background ----
|
||||||
shader_set_f("light_ambient", colToVec4(lightAmbient));
|
shader_set_f("light_ambient", colToVec4(lightAmbient));
|
||||||
shader_set_i("env_use_mapping", is_surface(enviroment_map) );
|
shader_set_i("env_use_mapping", is_surface(enviroment_map) );
|
||||||
shader_set_surface("env_map", enviroment_map, false, true );
|
shader_set_surface("env_map", enviroment_map, false, true );
|
||||||
shader_set_dim("env_map_dimension", enviroment_map );
|
shader_set_dim("env_map_dimension", enviroment_map );
|
||||||
if(deferData != noone) shader_set_surface("ao_map", deferData.ssao );
|
if(deferData != noone) shader_set_surface("ao_map", deferData.ssao );
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
shader_set_i("light_dir_count", lightDir_count);
|
shader_set_i("light_dir_count", lightDir_count);
|
||||||
if(lightDir_count) {
|
if(lightDir_count) {
|
||||||
shader_set_f("light_dir_direction", lightDir_direction);
|
shader_set_f("light_dir_direction", lightDir_direction);
|
||||||
shader_set_f("light_dir_color", lightDir_color);
|
shader_set_f("light_dir_color", lightDir_color);
|
||||||
shader_set_f("light_dir_intensity", lightDir_intensity);
|
shader_set_f("light_dir_intensity", lightDir_intensity);
|
||||||
shader_set_i("light_dir_shadow_active", lightDir_shadow);
|
shader_set_i("light_dir_shadow_active", lightDir_shadow);
|
||||||
|
|
||||||
for( var i = 0, n = array_length(lightDir_shadowMap); i < n; i++ )
|
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);
|
var _sid = shader_set_surface($"light_dir_shadowmap_{i}", lightDir_shadowMap[i], true);
|
||||||
|
|
||||||
shader_set_f("light_dir_view", lightDir_viewMat);
|
shader_set_f("light_dir_view", lightDir_viewMat);
|
||||||
shader_set_f("light_dir_proj", lightDir_projMat);
|
shader_set_f("light_dir_proj", lightDir_projMat);
|
||||||
shader_set_f("light_dir_shadow_bias", lightDir_shadowBias);
|
shader_set_f("light_dir_shadow_bias", lightDir_shadowBias);
|
||||||
}
|
}
|
||||||
|
|
||||||
shader_set_i("light_pnt_count", lightPnt_count);
|
shader_set_i("light_pnt_count", lightPnt_count);
|
||||||
if(lightPnt_count) {
|
if(lightPnt_count) {
|
||||||
shader_set_f("light_pnt_position", lightPnt_position);
|
shader_set_f("light_pnt_position", lightPnt_position);
|
||||||
shader_set_f("light_pnt_color", lightPnt_color);
|
shader_set_f("light_pnt_color", lightPnt_color);
|
||||||
shader_set_f("light_pnt_intensity", lightPnt_intensity);
|
shader_set_f("light_pnt_intensity", lightPnt_intensity);
|
||||||
shader_set_f("light_pnt_radius", lightPnt_radius);
|
shader_set_f("light_pnt_radius", lightPnt_radius);
|
||||||
|
|
||||||
shader_set_i("light_pnt_shadow_active", lightPnt_shadow);
|
shader_set_i("light_pnt_shadow_active", lightPnt_shadow);
|
||||||
|
|
||||||
for( var i = 0, n = array_length(lightPnt_shadowMap); i < n; i++ )
|
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, false);
|
var _sid = shader_set_surface($"light_pnt_shadowmap_{i}", lightPnt_shadowMap[i], true, false);
|
||||||
|
|
||||||
shader_set_f("light_pnt_view", lightPnt_viewMat);
|
shader_set_f("light_pnt_view", lightPnt_viewMat);
|
||||||
shader_set_f("light_pnt_proj", lightPnt_projMat);
|
shader_set_f("light_pnt_proj", lightPnt_projMat);
|
||||||
shader_set_f("light_pnt_shadow_bias", lightPnt_shadowBias);
|
shader_set_f("light_pnt_shadow_bias", lightPnt_shadowBias);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(OS == os_windows && defer_normal && deferData != noone && array_length(deferData.geometry_data) > 2) {
|
if(OS == os_windows && defer_normal && deferData != noone && array_length(deferData.geometry_data) > 2) {
|
||||||
|
@ -268,10 +278,21 @@ function __3dScene(camera, name = "New scene") constructor {
|
||||||
shader_set_f("viewProjMat", camera.getCombinedMatrix() );
|
shader_set_f("viewProjMat", camera.getCombinedMatrix() );
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region ---- wireframe ----
|
||||||
|
shader_set_i("show_wireframe", show_wireframe);
|
||||||
|
shader_set_i("wireframe_aa", wireframe_aa);
|
||||||
|
shader_set_i("wireframe_shade", wireframe_shade);
|
||||||
|
shader_set_i("wireframe_only", wireframe_only);
|
||||||
|
shader_set_f("wireframe_width", max(0, wireframe_width));
|
||||||
|
shader_set_color("wireframe_color", wireframe_color);
|
||||||
|
#endregion
|
||||||
|
|
||||||
//print($"Submitting scene with {lightDir_count} dir, {lightPnt_count} pnt lights.");
|
//print($"Submitting scene with {lightDir_count} dir, {lightPnt_count} pnt lights.");
|
||||||
shader_reset();
|
shader_reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////- Data
|
||||||
|
|
||||||
static addLightDirectional = function(light) {
|
static addLightDirectional = function(light) {
|
||||||
if(lightDir_count >= lightDir_max) {
|
if(lightDir_count >= lightDir_max) {
|
||||||
noti_warning("Direction light limit exceeded");
|
noti_warning("Direction light limit exceeded");
|
||||||
|
|
|
@ -15,7 +15,6 @@ function __vertex(_x = 0, _y = _x, _z = _x, color = c_white, alpha = 1) construc
|
||||||
|
|
||||||
static set = function(_x, _y, _z, _nx, _ny, _nz, _u, _v) {
|
static set = function(_x, _y, _z, _nx, _ny, _nz, _u, _v) {
|
||||||
INLINE
|
INLINE
|
||||||
|
|
||||||
x = _x;
|
x = _x;
|
||||||
y = _y;
|
y = _y;
|
||||||
z = _z;
|
z = _z;
|
||||||
|
@ -26,26 +25,21 @@ function __vertex(_x = 0, _y = _x, _z = _x, color = c_white, alpha = 1) construc
|
||||||
|
|
||||||
u = _u;
|
u = _u;
|
||||||
v = _v;
|
v = _v;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
static setNormal = function(_nx = 0, _ny = _nx, _nz = _nx) {
|
static setNormal = function(_nx = 0, _ny = _nx, _nz = _nx) {
|
||||||
INLINE
|
INLINE
|
||||||
|
|
||||||
nx = _nx;
|
nx = _nx;
|
||||||
ny = _ny;
|
ny = _ny;
|
||||||
nz = _nz;
|
nz = _nz;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
static setUV = function(_u = 0, _v = _u) {
|
static setUV = function(_u = 0, _v = _u) {
|
||||||
INLINE
|
INLINE
|
||||||
|
|
||||||
u = _u;
|
u = _u;
|
||||||
v = _v;
|
v = _v;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
LATEST_VERSION = 1_18_00_0;
|
LATEST_VERSION = 1_18_00_0;
|
||||||
VERSION = 1_18_05_1;
|
VERSION = 1_18_05_1;
|
||||||
SAVE_VERSION = 1_18_05_0;
|
SAVE_VERSION = 1_18_05_0;
|
||||||
VERSION_STRING = MAC? "1.18.003m" : "1.18.6.005";
|
VERSION_STRING = MAC? "1.18.003m" : "1.18.6.006";
|
||||||
BUILD_NUMBER = 1_18_05_1;
|
BUILD_NUMBER = 1_18_05_1;
|
||||||
|
|
||||||
var _vsp = string_split(VERSION_STRING, ".");
|
var _vsp = string_split(VERSION_STRING, ".");
|
||||||
|
@ -167,6 +167,10 @@
|
||||||
#macro returnNull_mf2 ; if(is_undefined(
|
#macro returnNull_mf2 ; if(is_undefined(
|
||||||
#macro returnNull_mf3 ) ||
|
#macro returnNull_mf3 ) ||
|
||||||
#macro returnNull_mf4 == noone) return;
|
#macro returnNull_mf4 == noone) return;
|
||||||
|
//!#mfunc case2 {"args":["a"," b"],"order":[0,1],"token":"keyword"}
|
||||||
|
#macro case2_mf0 case
|
||||||
|
#macro case2_mf1 : case
|
||||||
|
#macro case2_mf2 //
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
@ -17,59 +17,72 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
|
||||||
deferData = noone;
|
deferData = noone;
|
||||||
|
|
||||||
global.SKY_SPHERE = new __3dUVSphere(0.5, 16, 8, true);
|
global.SKY_SPHERE = new __3dUVSphere(0.5, 16, 8, true);
|
||||||
|
var i = in_d3d;
|
||||||
|
|
||||||
newInput(in_d3d + 0, nodeValue_Int("FOV", self, 60 ))
|
newInput(i+0, nodeValue_Int("FOV", self, 60 ))
|
||||||
.setDisplay(VALUE_DISPLAY.slider, { range: [ 10, 90, 0.1 ] });
|
.setDisplay(VALUE_DISPLAY.slider, { range: [ 10, 90, 0.1 ] });
|
||||||
|
|
||||||
newInput(in_d3d + 1, nodeValue_Vec2("Clipping Distance", self, [ 1, 10 ] ));
|
newInput(i+1, nodeValue_Vec2("Clipping Distance", self, [ 1, 10 ] ));
|
||||||
|
|
||||||
newInput(in_d3d + 2, nodeValue_Dimension(self));
|
newInput(i+2, nodeValue_Dimension(self));
|
||||||
|
|
||||||
newInput(in_d3d + 3, nodeValue_Enum_Button("Projection", self, 1 , [ "Perspective", "Orthographic" ]));
|
newInput(i+3, nodeValue_Enum_Button("Projection", self, 1 , [ "Perspective", "Orthographic" ]));
|
||||||
|
|
||||||
newInput(in_d3d + 4, nodeValue_D3Scene("Scene", self, noone ))
|
newInput(i+4, nodeValue_D3Scene("Scene", self, noone ))
|
||||||
.setVisible(true, true);
|
.setVisible(true, true);
|
||||||
|
|
||||||
newInput(in_d3d + 5, nodeValue_Color("Ambient Light", self, c_dkgrey ));
|
newInput(i+5, nodeValue_Color("Ambient Light", self, c_dkgrey ));
|
||||||
|
|
||||||
newInput(in_d3d + 6, nodeValue_Bool("Show Background", self, false ));
|
newInput(i+6, nodeValue_Bool("Show Background", self, false ));
|
||||||
|
|
||||||
newInput(in_d3d + 7, nodeValue_Enum_Button("Backface Culling", self, 2 , [ "None", "CW", "CCW" ]));
|
newInput(i+7, nodeValue_Enum_Button("Backface Culling", self, 2 , [ "None", "CW", "CCW" ]));
|
||||||
|
|
||||||
newInput(in_d3d + 8, nodeValue_Float("Orthographic Scale", self, 0.5 ))
|
newInput(i+8, nodeValue_Float("Orthographic Scale", self, 0.5 ))
|
||||||
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0.01, 4, 0.01 ] });
|
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0.01, 4, 0.01 ] });
|
||||||
|
|
||||||
newInput(in_d3d + 9, nodeValue_Enum_Scroll("Postioning Mode", self, 2, [ "Position + Rotation", "Position + Lookat", "Lookat + Rotation" ] ));
|
newInput(i+9, nodeValue_Enum_Scroll("Postioning Mode", self, 2, [ "Position + Rotation", "Position + Lookat", "Lookat + Rotation" ] ));
|
||||||
|
|
||||||
newInput(in_d3d + 10, nodeValue_Vec3("Lookat Position", self, [ 0, 0, 0 ] ));
|
newInput(i+10, nodeValue_Vec3("Lookat Position", self, [ 0, 0, 0 ] ));
|
||||||
|
|
||||||
newInput(in_d3d + 11, nodeValue_Rotation("Roll", self, 0));
|
newInput(i+11, nodeValue_Rotation("Roll", self, 0));
|
||||||
|
|
||||||
newInput(in_d3d + 12, nodeValue_Rotation("Horizontal Angle", self, 45 ));
|
newInput(i+12, nodeValue_Rotation("Horizontal Angle", self, 45 ));
|
||||||
|
|
||||||
newInput(in_d3d + 13, nodeValue_Float("Vertical Angle", self, 30 ))
|
newInput(i+13, nodeValue_Float("Vertical Angle", self, 30 ))
|
||||||
.setDisplay(VALUE_DISPLAY.slider, { range: [0, 90, 0.1] });
|
.setDisplay(VALUE_DISPLAY.slider, { range: [0, 90, 0.1] });
|
||||||
|
|
||||||
newInput(in_d3d + 14, nodeValue_Float("Distance", self, 4 ));
|
newInput(i+14, nodeValue_Float("Distance", self, 4 ));
|
||||||
|
|
||||||
newInput(in_d3d + 15, nodeValue_Bool("Gamma Adjust", self, false ));
|
newInput(i+15, nodeValue_Bool("Gamma Adjust", self, false ));
|
||||||
|
|
||||||
newInput(in_d3d + 16, nodeValue_Surface("Environment Texture", self));
|
newInput(i+16, nodeValue_Surface("Environment Texture", self));
|
||||||
|
|
||||||
newInput(in_d3d + 17, nodeValue_Bool("Ambient Occlusion", self, false ));
|
newInput(i+17, nodeValue_Bool("Ambient Occlusion", self, false ));
|
||||||
|
|
||||||
newInput(in_d3d + 18, nodeValue_Float("AO Radius", self, 0.25 ));
|
newInput(i+18, nodeValue_Float("AO Radius", self, 0.25 ));
|
||||||
|
|
||||||
newInput(in_d3d + 19, nodeValue_Float("AO Bias", self, 0.05 ));
|
newInput(i+19, nodeValue_Float("AO Bias", self, 0.05 ));
|
||||||
|
|
||||||
newInput(in_d3d + 20, nodeValue_Float("AO Strength", self, 1. ))
|
newInput(i+20, nodeValue_Float("AO Strength", self, 1. ))
|
||||||
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0.01, 4, 0.01 ] });
|
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0.01, 4, 0.01 ] });
|
||||||
|
|
||||||
newInput(in_d3d + 21, nodeValue_Int("Round Normal", self, 0 ))
|
newInput(i+21, nodeValue_Int("Round Normal", self, 0 ))
|
||||||
.setWindows();
|
.setWindows();
|
||||||
|
|
||||||
newInput(in_d3d + 22, nodeValue_Enum_Button("Blend mode", self, 0 , [ "Normal", "Additive" ]));
|
newInput(i+22, nodeValue_Enum_Button("Blend mode", self, 0 , [ "Normal", "Additive" ]));
|
||||||
|
|
||||||
|
newInput(i+23, nodeValue_Bool("Wireframe", self, false));
|
||||||
|
|
||||||
|
newInput(i+24, nodeValue_Float("Wireframe Thickness", self, 1));
|
||||||
|
|
||||||
|
newInput(i+25, nodeValue_Color("Wireframe Color", self, cola(c_black)));
|
||||||
|
|
||||||
|
newInput(i+26, nodeValue_Bool("Wireframe antialias", self, false));
|
||||||
|
|
||||||
|
newInput(i+27, nodeValue_Bool("Wireframe shading", self, false));
|
||||||
|
|
||||||
|
newInput(i+28, nodeValue_Bool("Wireframe only", self, false));
|
||||||
|
|
||||||
in_cam = array_length(inputs);
|
in_cam = array_length(inputs);
|
||||||
|
|
||||||
newOutput(0, nodeValue_Output("Rendered", self, VALUE_TYPE.surface, noone ));
|
newOutput(0, nodeValue_Output("Rendered", self, VALUE_TYPE.surface, noone ));
|
||||||
|
@ -80,25 +93,23 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
|
||||||
newOutput(2, nodeValue_Output("Depth", self, VALUE_TYPE.surface, noone ))
|
newOutput(2, nodeValue_Output("Depth", self, VALUE_TYPE.surface, noone ))
|
||||||
.setVisible(false);
|
.setVisible(false);
|
||||||
|
|
||||||
input_display_list = [ in_d3d + 4,
|
input_display_list = [ i+4,
|
||||||
["Output", false], in_d3d + 2,
|
["Output", false], i+ 2,
|
||||||
["Transform", false], in_d3d + 9, 0, 1, in_d3d + 10, in_d3d + 11, in_d3d + 12, in_d3d + 13, in_d3d + 14,
|
["Transform", false], i+ 9, 0, 1, i+10, i+11, i+12, i+13, i+14,
|
||||||
["Camera", true], in_d3d + 3, in_d3d + 0, in_d3d + 1, in_d3d + 8,
|
["Camera", true], i+ 3, i+ 0, i+ 1, i+ 8,
|
||||||
["Render", true], in_d3d + 5, in_d3d + 16, in_d3d + 6, in_d3d + 7, in_d3d + 15, in_d3d + 22,
|
["Render", true], i+ 5, i+16, i+ 6, i+ 7, i+15, i+22,
|
||||||
["Ambient Occlusion", true], in_d3d + 17, in_d3d + 20, in_d3d + 18, in_d3d + 19,
|
["Wireframe", true, i+23], i+24, i+25, i+26, i+27, i+28,
|
||||||
["Effects", true], in_d3d + 21,
|
["Ambient Occlusion", true], i+17, i+20, i+18, i+19,
|
||||||
|
["Effects", true], i+21,
|
||||||
];
|
];
|
||||||
|
|
||||||
tool_lookat = new NodeTool( "Move Target", THEME.tools_3d_transform_object );
|
tool_lookat = new NodeTool( "Move Target", THEME.tools_3d_transform_object );
|
||||||
|
|
||||||
|
////- Preview
|
||||||
|
|
||||||
static getToolSettings = function() {
|
static getToolSettings = function() {
|
||||||
var _posm = getInputData(in_d3d + 9);
|
var _posm = getInputData(in_d3d + 9);
|
||||||
|
if(_posm == 0) return tool_settings;
|
||||||
switch(_posm) {
|
|
||||||
case 0 : return tool_settings;
|
|
||||||
case 1 :
|
|
||||||
case 2 : return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
@ -148,6 +159,8 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////- Update
|
||||||
|
|
||||||
static onValueUpdate = function(index) {
|
static onValueUpdate = function(index) {
|
||||||
if(index == in_d3d + 9) PANEL_PREVIEW.tool_current = noone;
|
if(index == in_d3d + 9) PANEL_PREVIEW.tool_current = noone;
|
||||||
}
|
}
|
||||||
|
@ -176,10 +189,12 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
|
||||||
case 0 :
|
case 0 :
|
||||||
tools = [ tool_pos, tool_rot ];
|
tools = [ tool_pos, tool_rot ];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1 :
|
case 1 :
|
||||||
tools = [ tool_pos, tool_lookat ];
|
tools = [ tool_pos, tool_lookat ];
|
||||||
tool_attribute.context = 1;
|
tool_attribute.context = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2 :
|
case 2 :
|
||||||
tools = [ tool_lookat ];
|
tools = [ tool_lookat ];
|
||||||
tool_attribute.context = 1;
|
tool_attribute.context = 1;
|
||||||
|
@ -223,6 +238,13 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
|
||||||
|
|
||||||
var _nrmSmt = _data[in_d3d + 21];
|
var _nrmSmt = _data[in_d3d + 21];
|
||||||
var _blend = _data[in_d3d + 22];
|
var _blend = _data[in_d3d + 22];
|
||||||
|
|
||||||
|
var _wire = _data[in_d3d + 23];
|
||||||
|
var _wiret = _data[in_d3d + 24];
|
||||||
|
var _wirec = _data[in_d3d + 25];
|
||||||
|
var _wirea = _data[in_d3d + 26];
|
||||||
|
var _wires = _data[in_d3d + 27];
|
||||||
|
var _wireo = _data[in_d3d + 28];
|
||||||
|
|
||||||
var _qi1 = new BBMOD_Quaternion().FromAxisAngle(new BBMOD_Vec3(0, 1, 0), 90);
|
var _qi1 = new BBMOD_Quaternion().FromAxisAngle(new BBMOD_Vec3(0, 1, 0), 90);
|
||||||
var _qi2 = new BBMOD_Quaternion().FromAxisAngle(new BBMOD_Vec3(1, 0, 0), -90);
|
var _qi2 = new BBMOD_Quaternion().FromAxisAngle(new BBMOD_Vec3(1, 0, 0), -90);
|
||||||
|
@ -279,23 +301,32 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
|
||||||
#region camera view project
|
#region camera view project
|
||||||
camera.projection = _proj;
|
camera.projection = _proj;
|
||||||
camera.setViewFov(_fov, _clip[0], _clip[1]);
|
camera.setViewFov(_fov, _clip[0], _clip[1]);
|
||||||
|
|
||||||
if(_proj == 0) camera.setViewSize(_dim[0], _dim[1]);
|
if(_proj == 0) camera.setViewSize(_dim[0], _dim[1]);
|
||||||
else if(_proj == 1) camera.setViewSize(1 / _orts, _dim[0] / _dim[1] / _orts);
|
else if(_proj == 1) camera.setViewSize(1 / _orts, _dim[0] / _dim[1] / _orts);
|
||||||
|
|
||||||
camera.setMatrix();
|
camera.setMatrix();
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region scene setting
|
#region scene setting
|
||||||
scene.camera = camera;
|
scene.camera = camera;
|
||||||
scene.lightAmbient = _ambt;
|
scene.lightAmbient = _ambt;
|
||||||
scene.gammaCorrection = _gamm;
|
scene.gammaCorrection = _gamm;
|
||||||
scene.enviroment_map = _env;
|
scene.enviroment_map = _env;
|
||||||
scene.cull_mode = _back;
|
scene.cull_mode = _back;
|
||||||
scene.ssao_enabled = _aoEn;
|
scene.ssao_enabled = _aoEn;
|
||||||
scene.ssao_radius = _aoRa;
|
scene.ssao_radius = _aoRa;
|
||||||
scene.ssao_bias = _aoBi;
|
scene.ssao_bias = _aoBi;
|
||||||
scene.ssao_strength = _aoSr;
|
scene.ssao_strength = _aoSr;
|
||||||
scene.defer_normal_radius = _nrmSmt;
|
scene.defer_normal_radius = _nrmSmt;
|
||||||
scene.draw_background = _dbg;
|
scene.draw_background = _dbg;
|
||||||
|
|
||||||
|
scene.show_wireframe = _wire;
|
||||||
|
scene.wireframe_width = _wiret;
|
||||||
|
scene.wireframe_color = _wirec;
|
||||||
|
scene.wireframe_aa = _wirea;
|
||||||
|
scene.wireframe_shade = _wires;
|
||||||
|
scene.wireframe_only = _wireo;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region submit
|
#region submit
|
||||||
|
@ -371,11 +402,11 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
|
||||||
return [ _finalRender, _normal, _depth ];
|
return [ _finalRender, _normal, _depth ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////- Draw
|
||||||
|
|
||||||
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {}
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {}
|
||||||
|
|
||||||
static getPreviewObject = function() {
|
static getPreviewObject = function() { return getSingleValue(in_d3d + 4); }
|
||||||
return getSingleValue(in_d3d + 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
static getPreviewObjects = function() {
|
static getPreviewObjects = function() {
|
||||||
var _posm = getInputData(in_d3d + 9);
|
var _posm = getInputData(in_d3d + 9);
|
||||||
|
@ -392,6 +423,8 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group)
|
||||||
|
|
||||||
static getPreviewObjectOutline = function() { return isUsingTool("Move Target")? [ lookat ] : [ object ]; }
|
static getPreviewObjectOutline = function() { return isUsingTool("Move Target")? [ lookat ] : [ object ]; }
|
||||||
|
|
||||||
|
////- Serialize
|
||||||
|
|
||||||
static doSerialize = function(_map) {
|
static doSerialize = function(_map) {
|
||||||
_map.camera_base_length = in_cam;
|
_map.camera_base_length = in_cam;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
function Node_GMRoom(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
function Node_GMRoom(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
name = "GMRoom";
|
name = "GMRoom";
|
||||||
color = COLORS.node_blend_input;
|
color = COLORS.node_blend_input;
|
||||||
|
icon = s_gamemaker;
|
||||||
|
|
||||||
gmRoom = noone;
|
gmRoom = noone;
|
||||||
layers = [];
|
layers = [];
|
||||||
|
|
|
@ -968,6 +968,7 @@ function PanelContent() constructor {
|
||||||
|
|
||||||
function drawContent(panel) {}
|
function drawContent(panel) {}
|
||||||
|
|
||||||
|
function preDraw() {}
|
||||||
function drawGUI() {}
|
function drawGUI() {}
|
||||||
|
|
||||||
static onFullScreen = function() {}
|
static onFullScreen = function() {}
|
||||||
|
|
|
@ -497,7 +497,7 @@ function Panel_Preview() : PanelContent() constructor {
|
||||||
[
|
[
|
||||||
THEME.icon_visibility,
|
THEME.icon_visibility,
|
||||||
new tooltipHotkey(__txtx("graph_visibility_title", "Visibility settings") + "...", "Preview", "View Settings"),
|
new tooltipHotkey(__txtx("graph_visibility_title", "Visibility settings") + "...", "Preview", "View Settings"),
|
||||||
function(param) /*=>*/ { dialogPanelCall(new Panel_Preview_View_Setting(self), param.x, param.y, { anchor: ANCHOR}); },
|
function(param) /*=>*/ { dialogPanelCall(new Panel_Preview_View_Setting(self), param.x, param.y, { anchor: ANCHOR.bottom | ANCHOR.left }); },
|
||||||
function() /*=>*/ {return 0},
|
function() /*=>*/ {return 0},
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
@ -1259,7 +1259,8 @@ function Panel_Preview() : PanelContent() constructor {
|
||||||
|
|
||||||
#region draw
|
#region draw
|
||||||
d3_scene_preview.reset();
|
d3_scene_preview.reset();
|
||||||
gpu_set_cullmode(cull_counterclockwise);
|
gpu_set_cullmode(d3_scene_preview.cull_mode);
|
||||||
|
// gpu_set_cullmode(cull_counterclockwise);
|
||||||
|
|
||||||
var _prev_obj = _node.getPreviewObjects();
|
var _prev_obj = _node.getPreviewObjects();
|
||||||
|
|
||||||
|
|
|
@ -1,68 +1,87 @@
|
||||||
function Panel_Preview_3D_Setting(panel) : Panel_Linear_Setting() constructor {
|
function Panel_Preview_3D_Setting(_panel) : Panel_Linear_Setting() constructor {
|
||||||
title = __txtx("preview_3d_settings", "3D Preview Settings");
|
title = __txtx("preview_3d_settings", "3D Preview Settings");
|
||||||
preview_panel = panel;
|
preview = _panel;
|
||||||
|
scene = _panel.d3_scene;
|
||||||
|
|
||||||
properties_default = [
|
properties_default = [
|
||||||
new __Panel_Linear_Setting_Item(
|
["Wireframe", false],
|
||||||
__txt("Preview Pass"),
|
new __Panel_Linear_Setting_Item( __txt("Wireframe"),
|
||||||
new scrollBox([ "Rendered", "Normal", "Depth" ], function(index) { preview_panel.d3_preview_channel = index; }),
|
new checkBox(function() /*=>*/ { scene.show_wireframe = !scene.show_wireframe; }),
|
||||||
function() { return preview_panel.d3_preview_channel },
|
function( ) /*=>*/ {return scene.show_wireframe},
|
||||||
function(val) { preview_panel.d3_preview_channel = val; },
|
function(val) /*=>*/ { scene.show_wireframe = val; },
|
||||||
0,
|
|
||||||
),
|
|
||||||
new __Panel_Linear_Setting_Item(
|
|
||||||
__txt("Preview Light"),
|
|
||||||
new checkBox(function() { preview_panel.d3_scene_light_enabled = !preview_panel.d3_scene_light_enabled; }),
|
|
||||||
function() { return preview_panel.d3_scene_light_enabled },
|
|
||||||
function(val) { preview_panel.d3_scene_light_enabled = val; },
|
|
||||||
true,
|
|
||||||
),
|
|
||||||
new __Panel_Linear_Setting_Item(
|
|
||||||
__txt("Ambient Color"),
|
|
||||||
new buttonColor(function(col) { preview_panel.d3_scene.lightAmbient = col; }),
|
|
||||||
function() { return preview_panel.d3_scene.lightAmbient },
|
|
||||||
function(val) { preview_panel.d3_scene.lightAmbient = val; },
|
|
||||||
$404040,
|
|
||||||
),
|
|
||||||
new __Panel_Linear_Setting_Item(
|
|
||||||
__txt("Light Intensity"),
|
|
||||||
slider(0, 1, 0.01, function(val) {
|
|
||||||
preview_panel.d3_scene_light0.intensity = val;
|
|
||||||
preview_panel.d3_scene_light1.intensity = val;
|
|
||||||
}),
|
|
||||||
function() { return preview_panel.d3_scene_light0.intensity },
|
|
||||||
function(val) { preview_panel.d3_scene_light0.intensity = val; },
|
|
||||||
1,
|
|
||||||
),
|
|
||||||
new __Panel_Linear_Setting_Item(
|
|
||||||
__txt("Shadow"),
|
|
||||||
new checkBox(function() { preview_panel.d3_scene_light0.shadow_active = !preview_panel.d3_scene_light0.shadow_active; }),
|
|
||||||
function() { return preview_panel.d3_scene_light0.shadow_active },
|
|
||||||
function(val) { preview_panel.d3_scene_light0.shadow_active = val; },
|
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
new __Panel_Linear_Setting_Item(
|
new __Panel_Linear_Setting_Item( __txt("Wireframe Thickness"),
|
||||||
__txt("View Plane"),
|
new textBox(TEXTBOX_INPUT.number, function(v) /*=>*/ { scene.wireframe_width = v; }),
|
||||||
new vectorBox(2, function(value, index) {
|
function( ) /*=>*/ {return scene.wireframe_width},
|
||||||
if(index == 0) preview_panel.d3_view_camera.view_near = value;
|
function(val) /*=>*/ { scene.wireframe_width = val; },
|
||||||
else if(index == 1) preview_panel.d3_view_camera.view_far = value;
|
1,
|
||||||
}),
|
|
||||||
function() { return [ preview_panel.d3_view_camera.view_near, preview_panel.d3_view_camera.view_far ] },
|
|
||||||
function(val) { preview_panel.d3_view_camera.view_near = val[0]; preview_panel.d3_view_camera.view_far = val[1] },
|
|
||||||
[ 0.01, 50 ],
|
|
||||||
),
|
),
|
||||||
new __Panel_Linear_Setting_Item(
|
new __Panel_Linear_Setting_Item( __txt("Wireframe Color"),
|
||||||
__txt("Gamma Correct"),
|
new buttonColor(function(c) /*=>*/ { scene.wireframe_color = c; }),
|
||||||
new checkBox(function() { preview_panel.d3_scene.gammaCorrection = !preview_panel.d3_scene.gammaCorrection; }),
|
function( ) /*=>*/ {return scene.wireframe_color},
|
||||||
function() { return preview_panel.d3_scene.gammaCorrection },
|
function(val) /*=>*/ { scene.wireframe_color = val; },
|
||||||
function(val) { preview_panel.d3_scene.gammaCorrection = val; },
|
cola(c_black, 1),
|
||||||
|
),
|
||||||
|
|
||||||
|
["Passes", false],
|
||||||
|
new __Panel_Linear_Setting_Item( __txt("Preview Pass"),
|
||||||
|
new scrollBox([ "Rendered", "Normal", "Depth" ], function(index) /*=>*/ { preview.d3_preview_channel = index; }),
|
||||||
|
function( ) /*=>*/ {return preview.d3_preview_channel},
|
||||||
|
function(val) /*=>*/ { preview.d3_preview_channel = val; },
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
|
||||||
|
["Lighting", false],
|
||||||
|
new __Panel_Linear_Setting_Item( __txt("Preview Light"),
|
||||||
|
new checkBox(function() /*=>*/ { preview.d3_scene_light_enabled = !preview.d3_scene_light_enabled; }),
|
||||||
|
function( ) /*=>*/ {return preview.d3_scene_light_enabled},
|
||||||
|
function(val) /*=>*/ { preview.d3_scene_light_enabled = val; },
|
||||||
true,
|
true,
|
||||||
),
|
),
|
||||||
new __Panel_Linear_Setting_Item(
|
new __Panel_Linear_Setting_Item( __txt("Ambient Color"),
|
||||||
__txt("Normal"),
|
new buttonColor(function(col) /*=>*/ { scene.lightAmbient = col; }),
|
||||||
new checkBox(function() { preview_panel.d3_scene.show_normal = !preview_panel.d3_scene.show_normal; }),
|
function( ) /*=>*/ {return scene.lightAmbient},
|
||||||
function() { return preview_panel.d3_scene.show_normal },
|
function(val) /*=>*/ { scene.lightAmbient = val; },
|
||||||
function(val) { preview_panel.d3_scene.show_normal = val; },
|
$404040,
|
||||||
|
),
|
||||||
|
new __Panel_Linear_Setting_Item( __txt("Light Intensity"),
|
||||||
|
slider(0, 1, 0.01, function(val) /*=>*/ {
|
||||||
|
preview.d3_scene_light0.intensity = val;
|
||||||
|
preview.d3_scene_light1.intensity = val;
|
||||||
|
}),
|
||||||
|
function( ) /*=>*/ {return preview.d3_scene_light0.intensity},
|
||||||
|
function(val) /*=>*/ { preview.d3_scene_light0.intensity = val; },
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
|
||||||
|
["Render", false],
|
||||||
|
new __Panel_Linear_Setting_Item( __txt("Shadow"),
|
||||||
|
new checkBox(function() /*=>*/ { preview.d3_scene_light0.shadow_active = !preview.d3_scene_light0.shadow_active; }),
|
||||||
|
function( ) /*=>*/ {return preview.d3_scene_light0.shadow_active},
|
||||||
|
function(val) /*=>*/ { preview.d3_scene_light0.shadow_active = val; },
|
||||||
|
false,
|
||||||
|
),
|
||||||
|
new __Panel_Linear_Setting_Item( __txt("View Plane"),
|
||||||
|
new vectorBox(2, function(value, index) /*=>*/ {
|
||||||
|
if(index == 0) preview.d3_view_camera.view_near = value;
|
||||||
|
else if(index == 1) preview.d3_view_camera.view_far = value;
|
||||||
|
}),
|
||||||
|
function( ) /*=>*/ {return [ preview.d3_view_camera.view_near, preview.d3_view_camera.view_far ]},
|
||||||
|
function(val) /*=>*/ { preview.d3_view_camera.view_near = val[0]; preview.d3_view_camera.view_far = val[1] },
|
||||||
|
[ 0.01, 50 ],
|
||||||
|
),
|
||||||
|
new __Panel_Linear_Setting_Item( __txt("Gamma Correct"),
|
||||||
|
new checkBox(function() /*=>*/ { scene.gammaCorrection = !scene.gammaCorrection; }),
|
||||||
|
function( ) /*=>*/ {return scene.gammaCorrection},
|
||||||
|
function(val) /*=>*/ { scene.gammaCorrection = val; },
|
||||||
|
true,
|
||||||
|
),
|
||||||
|
|
||||||
|
new __Panel_Linear_Setting_Item( __txt("Normal"),
|
||||||
|
new checkBox(function() /*=>*/ { scene.show_normal = !scene.show_normal; }),
|
||||||
|
function( ) /*=>*/ {return scene.show_normal},
|
||||||
|
function(val) /*=>*/ { scene.show_normal = val; },
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
@ -72,7 +91,7 @@ function Panel_Preview_3D_Setting(panel) : Panel_Linear_Setting() constructor {
|
||||||
];
|
];
|
||||||
|
|
||||||
properties_camera = array_append(scene_camera, properties_default);
|
properties_camera = array_append(scene_camera, properties_default);
|
||||||
properties = preview_panel.d3_scene_preview == preview_panel.d3_scene? properties_default : properties_camera;
|
properties = preview.d3_scene_preview == scene? properties_default : properties_camera;
|
||||||
|
|
||||||
setHeight();
|
setHeight();
|
||||||
}
|
}
|
|
@ -1,8 +1,9 @@
|
||||||
// PC3D rendering shader
|
#extension GL_OES_standard_derivatives : enable
|
||||||
|
|
||||||
varying vec2 v_vTexcoord;
|
varying vec2 v_vTexcoord;
|
||||||
varying vec4 v_vColour;
|
varying vec4 v_vColour;
|
||||||
varying vec3 v_vNormal;
|
varying vec3 v_vNormal;
|
||||||
|
varying vec3 v_barycentric;
|
||||||
|
|
||||||
varying vec4 v_worldPosition;
|
varying vec4 v_worldPosition;
|
||||||
varying vec3 v_viewPosition;
|
varying vec3 v_viewPosition;
|
||||||
|
@ -84,6 +85,13 @@ uniform int use_8bit;
|
||||||
uniform vec2 env_map_dimension;
|
uniform vec2 env_map_dimension;
|
||||||
|
|
||||||
uniform mat4 viewProjMat;
|
uniform mat4 viewProjMat;
|
||||||
|
|
||||||
|
uniform int show_wireframe;
|
||||||
|
uniform int wireframe_aa;
|
||||||
|
uniform int wireframe_shade;
|
||||||
|
uniform int wireframe_only;
|
||||||
|
uniform float wireframe_width;
|
||||||
|
uniform vec4 wireframe_color;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ++++ mapping ++++
|
#region ++++ mapping ++++
|
||||||
|
@ -174,55 +182,65 @@ uniform int use_8bit;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
vec4 wireframeCalc(in vec4 baseColr) {
|
||||||
|
vec3 bc_width = fwidth(v_barycentric);
|
||||||
|
vec3 aa_width = wireframe_aa == 1? smoothstep(bc_width * wireframe_width * .9, bc_width * wireframe_width, v_barycentric) :
|
||||||
|
step(bc_width * wireframe_width, v_barycentric);
|
||||||
|
|
||||||
|
float edge_factor = 1. - min(aa_width.r, min(aa_width.g, aa_width.b));
|
||||||
|
vec4 baseColor = wireframe_only == 1? vec4(0.) : baseColr;
|
||||||
|
vec4 mixed_color = mix(baseColor, wireframe_color, edge_factor * wireframe_color.a);
|
||||||
|
|
||||||
|
return mixed_color;
|
||||||
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec2 uv_coord = v_vTexcoord;
|
vec2 uv_coord = v_vTexcoord;
|
||||||
if(mat_flip == 1) uv_coord.y = -uv_coord.y;
|
if(mat_flip == 1) uv_coord.y = -uv_coord.y;
|
||||||
|
|
||||||
uv_coord = fract(uv_coord * mat_texScale + mat_texShift);
|
uv_coord = fract(uv_coord * mat_texScale + mat_texShift);
|
||||||
mat_baseColor = texture2D( gm_BaseTexture, uv_coord );
|
mat_baseColor = texture2D( gm_BaseTexture, uv_coord );
|
||||||
mat_baseColor *= v_vColour;
|
mat_baseColor *= v_vColour;
|
||||||
|
|
||||||
vec4 final_color = mat_baseColor;
|
vec4 final_color = mat_baseColor;
|
||||||
|
if(show_wireframe == 1 && wireframe_shade == 1) final_color = wireframeCalc(final_color);
|
||||||
|
|
||||||
vec3 viewDirection = normalize(cameraPosition - v_worldPosition.xyz);
|
vec3 viewDirection = normalize(cameraPosition - v_worldPosition.xyz);
|
||||||
|
|
||||||
vec4 viewProjPos = viewProjMat * vec4(v_worldPosition.xyz, 1.);
|
vec4 viewProjPos = viewProjMat * vec4(v_worldPosition.xyz, 1.);
|
||||||
viewProjPos /= viewProjPos.w;
|
viewProjPos /= viewProjPos.w;
|
||||||
viewProjPos = viewProjPos * 0.5 + 0.5;
|
viewProjPos = viewProjPos * 0.5 + 0.5;
|
||||||
|
|
||||||
#region ++++ normal ++++
|
vec3 normal = mat_defer_normal == 1? texture2D(mat_normal_map, viewProjPos.xy).rgb : v_vNormal;
|
||||||
vec3 _norm = v_vNormal;
|
normal = normalize(normal);
|
||||||
|
|
||||||
if(mat_defer_normal == 1)
|
|
||||||
_norm = texture2D(mat_normal_map, viewProjPos.xy).rgb;
|
|
||||||
|
|
||||||
vec3 normal = normalize(_norm);
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region ++++ environment ++++
|
#region ++++ environment ++++
|
||||||
if(env_use_mapping == 1 && mat_reflective > 0.) {
|
if(env_use_mapping == 1 && mat_reflective > 0.) {
|
||||||
vec3 reflectDir = reflect(viewDirection, normal);
|
|
||||||
|
|
||||||
float refRad = mix(16., 0., mat_reflective);
|
vec3 reflectDir = reflect(viewDirection, normal);
|
||||||
vec2 tx = 1. / env_map_dimension;
|
float refRad = mix(16., 0., mat_reflective);
|
||||||
|
vec2 tx = 1. / env_map_dimension;
|
||||||
vec2 reflect_sample_pos = equirectangularUv(reflectDir);
|
vec2 reflect_sample_pos = equirectangularUv(reflectDir);
|
||||||
vec4 env_sampled = vec4(0.);
|
vec4 env_sampled = vec4(0.);
|
||||||
float weight = 0.;
|
float weight = 0.;
|
||||||
|
|
||||||
for(float i = -refRad; i <= refRad; i++)
|
for(float i = -refRad; i <= refRad; i++)
|
||||||
for(float j = -refRad; j <= refRad; j++) {
|
for(float j = -refRad; j <= refRad; j++) {
|
||||||
vec2 _map_pos = reflect_sample_pos + vec2(i, j) * tx;
|
vec2 _map_pos = reflect_sample_pos + vec2(i, j) * tx;
|
||||||
if(_map_pos.y < 0.) _map_pos.y = -_map_pos.y;
|
|
||||||
|
if(_map_pos.y < 0.) _map_pos.y = -_map_pos.y;
|
||||||
else if(_map_pos.y > 1.) _map_pos.y = 1. - (_map_pos.y - 1.);
|
else if(_map_pos.y > 1.) _map_pos.y = 1. - (_map_pos.y - 1.);
|
||||||
|
|
||||||
vec4 _samp = texture2D(env_map, _map_pos);
|
vec4 _samp = texture2D(env_map, _map_pos);
|
||||||
env_sampled += _samp;
|
env_sampled += _samp;
|
||||||
weight += _samp.a;
|
weight += _samp.a;
|
||||||
}
|
}
|
||||||
env_sampled /= weight;
|
|
||||||
|
env_sampled /= weight;
|
||||||
env_sampled.a = 1.;
|
env_sampled.a = 1.;
|
||||||
|
|
||||||
vec4 env_effect = mat_metalic == 1? env_sampled * final_color : env_sampled;
|
vec4 env_effect = mat_metalic == 1? env_sampled * final_color : env_sampled;
|
||||||
env_effect = 1. - ( mat_reflective * ( 1. - env_effect ));
|
env_effect = 1. - ( mat_reflective * ( 1. - env_effect ));
|
||||||
|
|
||||||
final_color *= env_effect;
|
final_color *= env_effect;
|
||||||
}
|
}
|
||||||
|
@ -333,9 +351,10 @@ void main() {
|
||||||
final_color.rgb *= light_effect;
|
final_color.rgb *= light_effect;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
if(show_wireframe == 1 && wireframe_shade == 0) final_color = wireframeCalc(final_color);
|
||||||
if(final_color.a < 0.1) discard;
|
if(final_color.a < 0.1) discard;
|
||||||
|
|
||||||
gl_FragData[0] = final_color;
|
gl_FragData[0] = final_color;
|
||||||
gl_FragData[1] = vec4(0.5 + normal * 0.5, final_color.a);
|
gl_FragData[1] = vec4(0.5 + normal * 0.5, final_color.a);
|
||||||
gl_FragData[2] = vec4(vec3(1. - abs(v_cameraDistance)), final_color.a);
|
gl_FragData[2] = vec4(vec3(1. - abs(v_cameraDistance)), final_color.a);
|
||||||
}
|
}
|
|
@ -1,13 +1,16 @@
|
||||||
attribute vec3 in_Position;
|
attribute vec3 in_Position;
|
||||||
attribute vec3 in_Normal;
|
attribute vec3 in_Normal;
|
||||||
attribute vec4 in_Colour;
|
|
||||||
attribute vec2 in_TextureCoord;
|
attribute vec2 in_TextureCoord;
|
||||||
|
attribute vec4 in_Colour;
|
||||||
|
attribute vec3 in_Barycentric;
|
||||||
|
|
||||||
varying vec2 v_vTexcoord;
|
varying vec2 v_vTexcoord;
|
||||||
varying vec4 v_vColour;
|
varying vec4 v_vColour;
|
||||||
varying vec3 v_vNormal;
|
varying vec3 v_vNormal;
|
||||||
varying vec4 v_worldPosition;
|
varying vec3 v_barycentric;
|
||||||
varying vec3 v_viewPosition;
|
|
||||||
|
varying vec4 v_worldPosition;
|
||||||
|
varying vec3 v_viewPosition;
|
||||||
varying float v_cameraDistance;
|
varying float v_cameraDistance;
|
||||||
|
|
||||||
uniform float planeNear;
|
uniform float planeNear;
|
||||||
|
@ -29,4 +32,6 @@ void main() {
|
||||||
float depthRange = abs(planeFar - planeNear);
|
float depthRange = abs(planeFar - planeNear);
|
||||||
float ndcDepth = (gl_Position.z - planeNear) / depthRange;
|
float ndcDepth = (gl_Position.z - planeNear) / depthRange;
|
||||||
v_cameraDistance = ndcDepth * 0.5 + 0.5;
|
v_cameraDistance = ndcDepth * 0.5 + 0.5;
|
||||||
|
|
||||||
|
v_barycentric = in_Barycentric;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
attribute vec3 in_Position;
|
attribute vec3 in_Position;
|
||||||
attribute vec3 in_Normal;
|
attribute vec3 in_Normal;
|
||||||
attribute vec4 in_Colour;
|
|
||||||
attribute vec2 in_TextureCoord;
|
attribute vec2 in_TextureCoord;
|
||||||
|
attribute vec4 in_Colour;
|
||||||
|
attribute vec3 in_Barycentric;
|
||||||
|
|
||||||
varying vec2 v_vTexcoord;
|
varying vec2 v_vTexcoord;
|
||||||
varying vec4 v_worldPosition;
|
varying vec4 v_worldPosition;
|
||||||
|
|
Loading…
Reference in a new issue