From e6057b956169febf82a32d58563ff4828dd79b31 Mon Sep 17 00:00:00 2001 From: Tanasart Date: Fri, 24 Jan 2025 11:16:37 +0700 Subject: [PATCH] [3D Camera] Add AO, shadow, diffuse passes. --- PixelComposer.resource_order | 39 +++---- PixelComposer.yyp | 13 +-- datafiles/data/Nodes/Internal.zip | Bin 9099746 -> 9099746 bytes scripts/d3d_group/d3d_group.gml | 63 +++-------- scripts/d3d_object/d3d_object.gml | 62 +++++----- scripts/globals/globals.gml | 4 +- scripts/node_3d_camera/node_3d_camera.gml | 92 +++++++++------ .../node_3d_light_directional.gml | 29 +---- .../node_3d_light_point.gml | 12 +- shaders/sh_d3d_default/sh_d3d_default.fsh | 25 ++-- shaders/sh_d3d_ssao/sh_d3d_ssao.fsh | 1 - shaders/sh_d3d_unlit/sh_d3d_unlit.fsh | 107 ++++++++++++++++++ shaders/sh_d3d_unlit/sh_d3d_unlit.vsh | 37 ++++++ shaders/sh_d3d_unlit/sh_d3d_unlit.yy | 13 +++ 14 files changed, 298 insertions(+), 199 deletions(-) create mode 100644 shaders/sh_d3d_unlit/sh_d3d_unlit.fsh create mode 100644 shaders/sh_d3d_unlit/sh_d3d_unlit.vsh create mode 100644 shaders/sh_d3d_unlit/sh_d3d_unlit.yy diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index b336d11ae..0dd1acb4b 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -383,7 +383,7 @@ {"name":"slider_Slider","order":1,"path":"objects/slider_Slider/slider_Slider.yy",}, {"name":"rm_main","order":1,"path":"rooms/rm_main/rm_main.yy",}, {"name":"__3d_particle","order":1,"path":"scripts/__3d_particle/__3d_particle.yy",}, - {"name":"__3D","order":6,"path":"scripts/__3D/__3D.yy",}, + {"name":"__3D","order":1,"path":"scripts/__3D/__3D.yy",}, {"name":"__add_node_item","order":12,"path":"scripts/__add_node_item/__add_node_item.yy",}, {"name":"__bbox","order":5,"path":"scripts/__bbox/__bbox.yy",}, {"name":"__bone_constain_look_at","order":6,"path":"scripts/__bone_constain_look_at/__bone_constain_look_at.yy",}, @@ -408,7 +408,6 @@ {"name":"__node_3d_displace","order":2,"path":"scripts/__node_3d_displace/__node_3d_displace.yy",}, {"name":"__node_3d_export","order":3,"path":"scripts/__node_3d_export/__node_3d_export.yy",}, {"name":"__node_3d_extrude","order":4,"path":"scripts/__node_3d_extrude/__node_3d_extrude.yy",}, - {"name":"__node_3d_light","order":1,"path":"scripts/__node_3d_light/__node_3d_light.yy",}, {"name":"__node_3d_mesh","order":1,"path":"scripts/__node_3d_mesh/__node_3d_mesh.yy",}, {"name":"__node_3d_obj","order":5,"path":"scripts/__node_3d_obj/__node_3d_obj.yy",}, {"name":"__node_3d_object","order":11,"path":"scripts/__node_3d_object/__node_3d_object.yy",}, @@ -541,20 +540,20 @@ {"name":"d3d_gizmo_line","order":1,"path":"scripts/d3d_gizmo_line/d3d_gizmo_line.yy",}, {"name":"d3d_gizmo_plane_falloff","order":6,"path":"scripts/d3d_gizmo_plane_falloff/d3d_gizmo_plane_falloff.yy",}, {"name":"d3d_gizmo_plane","order":5,"path":"scripts/d3d_gizmo_plane/d3d_gizmo_plane.yy",}, - {"name":"d3d_group","order":3,"path":"scripts/d3d_group/d3d_group.yy",}, + {"name":"d3d_group","order":4,"path":"scripts/d3d_group/d3d_group.yy",}, {"name":"d3d_icosphere","order":10,"path":"scripts/d3d_icosphere/d3d_icosphere.yy",}, {"name":"d3d_light_directional","order":1,"path":"scripts/d3d_light_directional/d3d_light_directional.yy",}, {"name":"d3d_light_point","order":2,"path":"scripts/d3d_light_point/d3d_light_point.yy",}, - {"name":"d3d_material","order":4,"path":"scripts/d3d_material/d3d_material.yy",}, - {"name":"d3d_object_instancer","order":5,"path":"scripts/d3d_object_instancer/d3d_object_instancer.yy",}, - {"name":"d3d_object","order":1,"path":"scripts/d3d_object/d3d_object.yy",}, + {"name":"d3d_material","order":5,"path":"scripts/d3d_material/d3d_material.yy",}, + {"name":"d3d_object_instancer","order":6,"path":"scripts/d3d_object_instancer/d3d_object_instancer.yy",}, + {"name":"d3d_object","order":2,"path":"scripts/d3d_object/d3d_object.yy",}, {"name":"d3d_path_extrude","order":22,"path":"scripts/d3d_path_extrude/d3d_path_extrude.yy",}, {"name":"d3d_plane_bend_mesh","order":16,"path":"scripts/d3d_plane_bend_mesh/d3d_plane_bend_mesh.yy",}, {"name":"d3d_plane_mesh","order":14,"path":"scripts/d3d_plane_mesh/d3d_plane_mesh.yy",}, {"name":"d3d_plane","order":2,"path":"scripts/d3d_plane/d3d_plane.yy",}, {"name":"d3d_ray","order":9,"path":"scripts/d3d_ray/d3d_ray.yy",}, {"name":"d3d_rot3","order":3,"path":"scripts/d3d_rot3/d3d_rot3.yy",}, - {"name":"d3d_scene","order":2,"path":"scripts/d3d_scene/d3d_scene.yy",}, + {"name":"d3d_scene","order":3,"path":"scripts/d3d_scene/d3d_scene.yy",}, {"name":"d3d_surface_extrude","order":18,"path":"scripts/d3d_surface_extrude/d3d_surface_extrude.yy",}, {"name":"d3d_terrain","order":20,"path":"scripts/d3d_terrain/d3d_terrain.yy",}, {"name":"d3d_torus","order":24,"path":"scripts/d3d_torus/d3d_torus.yy",}, @@ -1377,6 +1376,7 @@ {"name":"png_reader","order":9,"path":"scripts/png_reader/png_reader.yy",}, {"name":"point_direction_positive","order":4,"path":"scripts/point_direction_positive/point_direction_positive.yy",}, {"name":"point_rect_overlap","order":2,"path":"scripts/point_rect_overlap/point_rect_overlap.yy",}, + {"name":"sh_d3d_unlit","order":4,"path":"shaders/sh_d3d_unlit/sh_d3d_unlit.yy",}, {"name":"point_rotate","order":1,"path":"scripts/point_rotate/point_rotate.yy",}, {"name":"polygon_points","order":2,"path":"scripts/polygon_points/polygon_points.yy",}, {"name":"preferences","order":5,"path":"scripts/preferences/preferences.yy",}, @@ -1572,20 +1572,20 @@ {"name":"sh_cross_section","order":17,"path":"shaders/sh_cross_section/sh_cross_section.yy",}, {"name":"sh_curve_hsv","order":39,"path":"shaders/sh_curve_hsv/sh_curve_hsv.yy",}, {"name":"sh_curve","order":3,"path":"shaders/sh_curve/sh_curve.yy",}, - {"name":"sh_d3d_3d_transform","order":16,"path":"shaders/sh_d3d_3d_transform/sh_d3d_3d_transform.yy",}, - {"name":"sh_d3d_background","order":12,"path":"shaders/sh_d3d_background/sh_d3d_background.yy",}, + {"name":"sh_d3d_3d_transform","order":17,"path":"shaders/sh_d3d_3d_transform/sh_d3d_3d_transform.yy",}, + {"name":"sh_d3d_background","order":13,"path":"shaders/sh_d3d_background/sh_d3d_background.yy",}, {"name":"sh_d3d_default","order":3,"path":"shaders/sh_d3d_default/sh_d3d_default.yy",}, - {"name":"sh_d3d_extrude_extends","order":15,"path":"shaders/sh_d3d_extrude_extends/sh_d3d_extrude_extends.yy",}, - {"name":"sh_d3d_geometry","order":13,"path":"shaders/sh_d3d_geometry/sh_d3d_geometry.yy",}, - {"name":"sh_d3d_grid_view","order":5,"path":"shaders/sh_d3d_grid_view/sh_d3d_grid_view.yy",}, - {"name":"sh_d3d_normal_blur","order":14,"path":"shaders/sh_d3d_normal_blur/sh_d3d_normal_blur.yy",}, - {"name":"sh_d3d_normal","order":9,"path":"shaders/sh_d3d_normal/sh_d3d_normal.yy",}, - {"name":"sh_d3d_outline","order":7,"path":"shaders/sh_d3d_outline/sh_d3d_outline.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_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_extrude_extends","order":16,"path":"shaders/sh_d3d_extrude_extends/sh_d3d_extrude_extends.yy",}, + {"name":"sh_d3d_geometry","order":14,"path":"shaders/sh_d3d_geometry/sh_d3d_geometry.yy",}, + {"name":"sh_d3d_grid_view","order":6,"path":"shaders/sh_d3d_grid_view/sh_d3d_grid_view.yy",}, + {"name":"sh_d3d_normal_blur","order":15,"path":"shaders/sh_d3d_normal_blur/sh_d3d_normal_blur.yy",}, + {"name":"sh_d3d_normal","order":10,"path":"shaders/sh_d3d_normal/sh_d3d_normal.yy",}, + {"name":"sh_d3d_outline","order":8,"path":"shaders/sh_d3d_outline/sh_d3d_outline.yy",}, + {"name":"sh_d3d_shadow_cube_depth","order":12,"path":"shaders/sh_d3d_shadow_cube_depth/sh_d3d_shadow_cube_depth.yy",}, + {"name":"sh_d3d_shadow_depth","order":11,"path":"shaders/sh_d3d_shadow_depth/sh_d3d_shadow_depth.yy",}, + {"name":"sh_d3d_silhouette","order":7,"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_wireframe","order":8,"path":"shaders/sh_d3d_wireframe/sh_d3d_wireframe.yy",}, + {"name":"sh_d3d_wireframe","order":9,"path":"shaders/sh_d3d_wireframe/sh_d3d_wireframe.yy",}, {"name":"sh_de_corner","order":1,"path":"shaders/sh_de_corner/sh_de_corner.yy",}, {"name":"sh_de_stray","order":3,"path":"shaders/sh_de_stray/sh_de_stray.yy",}, {"name":"sh_default","order":6,"path":"shaders/sh_default/sh_default.yy",}, @@ -1899,6 +1899,7 @@ {"name":"s_node_3d_mesh_export","order":31,"path":"sprites/s_node_3d_mesh_export/s_node_3d_mesh_export.yy",}, {"name":"s_node_3d_mesh_extrude","order":2,"path":"sprites/s_node_3d_mesh_extrude/s_node_3d_mesh_extrude.yy",}, {"name":"s_node_3d_mesh_obj","order":3,"path":"sprites/s_node_3d_mesh_obj/s_node_3d_mesh_obj.yy",}, + {"name":"node_3d_light_directional","order":1,"path":"scripts/node_3d_light_directional/node_3d_light_directional.yy",}, {"name":"s_node_3d_mesh_path_extrude","order":32,"path":"sprites/s_node_3d_mesh_path_extrude/s_node_3d_mesh_path_extrude.yy",}, {"name":"s_node_3d_mesh_plane","order":6,"path":"sprites/s_node_3d_mesh_plane/s_node_3d_mesh_plane.yy",}, {"name":"s_node_3d_mesh_sphere_ico","order":16,"path":"sprites/s_node_3d_mesh_sphere_ico/s_node_3d_mesh_sphere_ico.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index f70167c2f..96af4c0aa 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -1306,11 +1306,7 @@ {"$GMIncludedFile":"","%Name":"Canvas.png","CopyToMask":-1,"filePath":"datafiles/data/Welcome files/Templates","name":"Canvas.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"Canvas.pxc","CopyToMask":-1,"filePath":"datafiles/data/Welcome files/Templates","name":"Canvas.pxc","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"Welcome files.zip","CopyToMask":-1,"filePath":"datafiles/data/Welcome files","name":"Welcome files.zip","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, - {"$GMIncludedFile":"","%Name":"dllcredits.txt","ConfigValues":{ - "Itch":{ - "CopyToMask":"0", - }, - },"CopyToMask":0,"filePath":"datafiles","name":"dllcredits.txt","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, + {"$GMIncludedFile":"","%Name":"dllcredits.txt","ConfigValues":{"Itch":{"CopyToMask":"0",},},"CopyToMask":0,"filePath":"datafiles","name":"dllcredits.txt","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"dlltest1.dll","CopyToMask":-1,"filePath":"datafiles","name":"dlltest1.dll","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"ffmpeg.exe","CopyToMask":-1,"filePath":"datafiles/ffmpeg/bin","name":"ffmpeg.exe","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"LICENSE","CopyToMask":-1,"filePath":"datafiles/ffmpeg","name":"LICENSE","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, @@ -1329,11 +1325,7 @@ {"$GMIncludedFile":"","%Name":"mf.dll","CopyToMask":-1,"filePath":"datafiles","name":"mf.dll","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"mfcore.dll","CopyToMask":-1,"filePath":"datafiles","name":"mfcore.dll","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"mfplat.dll","CopyToMask":-1,"filePath":"datafiles","name":"mfplat.dll","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, - {"$GMIncludedFile":"","%Name":"PixelComposer_profile-2.provisionprofile","ConfigValues":{ - "Itch":{ - "CopyToMask":"2", - }, - },"CopyToMask":-1,"filePath":"datafiles","name":"PixelComposer_profile-2.provisionprofile","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, + {"$GMIncludedFile":"","%Name":"PixelComposer_profile-2.provisionprofile","ConfigValues":{"Itch":{"CopyToMask":"2",},},"CopyToMask":-1,"filePath":"datafiles","name":"PixelComposer_profile-2.provisionprofile","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"data.win","CopyToMask":-1,"filePath":"datafiles/report","name":"data.win","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"execute_shell_simple_ext_x64.dll","CopyToMask":-1,"filePath":"datafiles/report","name":"execute_shell_simple_ext_x64.dll","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, {"$GMIncludedFile":"","%Name":"options.ini","CopyToMask":-1,"filePath":"datafiles/report","name":"options.ini","resourceType":"GMIncludedFile","resourceVersion":"2.0",}, @@ -2329,6 +2321,7 @@ {"id":{"name":"node_scatter_points","path":"scripts/node_scatter_points/node_scatter_points.yy",},}, {"id":{"name":"node_scatter","path":"scripts/node_scatter/node_scatter.yy",},}, {"id":{"name":"node_sdf","path":"scripts/node_sdf/node_sdf.yy",},}, + {"id":{"name":"sh_d3d_unlit","path":"shaders/sh_d3d_unlit/sh_d3d_unlit.yy",},}, {"id":{"name":"node_segment_filter","path":"scripts/node_segment_filter/node_segment_filter.yy",},}, {"id":{"name":"node_separate_color","path":"scripts/node_separate_color/node_separate_color.yy",},}, {"id":{"name":"node_seperate_shape","path":"scripts/node_seperate_shape/node_seperate_shape.yy",},}, diff --git a/datafiles/data/Nodes/Internal.zip b/datafiles/data/Nodes/Internal.zip index c5ba500ce5cf58f0d666d230f6474977a16dbc2e..4537f2e49090cf87f7036c61cc7a1206d6ff3bb0 100644 GIT binary patch delta 1362 zcmZ9~TWphM7zc2%9c3MbA;_Vfj3T(fVB;XLBP-hnGR9$m&~^hh4uZ;Q2i>L)LHX~i z-nZh8H=Q4j*P5w%jv}nUN))36tFRhtuokal9oAz5N>PS#RG<=7*obO`un9G& z{nn@ryY5Fz^`nU4*DYbgCsk|MD3)+7Y%G`XbJ$oR;jgfDJpH_~gvUPr=J;ew2e|fIgs~aYFbbNlV*Vj<*a?g1o^T~W+K7Nth^?jp#soao0 z5zCHwn+)1aTj&kiN_Di2>S;Uepq;df8fZ7|p}q7b?W6q^rU*r;k(%fL9i&6lOf7Vn zj?hs$MsLw^IzeyKJM=D{q*HX7&d^zEr8a7(4tkH?r%vjkZu)>eq>reF&e6woo-WWQ z^eJ6Tc$=`b&Gmr4(!NoYN%&$E>oXzo<0!uKNULWIMfz3>xl$!l_T=9wluM^_3{{yB z;~@1WddAGBS+0jXwr$*8ErBmOs9XOuJ^H6{(<`mt#?4jE+8U=5)FEFiYtk#soFbbq z#rgiPPMFi2J;ARAmFItxzfYKJWt}0Y5A`dr4y7k;(Je;I6YEHu6ialZKP$W^|BWky z)&>c`4q6)}EEuxNCF~!vDkYpBu>$(mkhNHbG5R+$q5`e@QxC>4@csf2-~RU<*J%)etFDOIym;g0>JBTkq)Vn32G^8BC# zcYJ+A-cd!D3g~t1s#vPy?P^OVByP5=3b(W#cdB}4vQ9#*OKp>o>QXzLnLwhtTm2A} z-#DjFZIZC7Pt{1si}RM7eQK#x{2BrMv`-Z{Yat2EaeG?U2jcd6Nk8|x`&FR~v8w&& Lki_MFwWsPCI#wKp delta 1362 zcmZ9~U2Icj7zc219c3Mb38>IcW)aw6W8*^@`|h>_Y>bZyLfZ}56a_y}_aO{)a|8c7 z<-7?5FXT1rg5eqxNHi%IkbQK!&`htoXxti-aYsT-@QMqg|303h(+;pi87R<0+pyjHEIwl$!}bvO`}EIYBS+f2Bws=>!gg`QSn5<8B%F>I1roforcbAmSfWQF_SwAGr*nTt zmj3NOt!ztW>AV(uiVyDls&CMvo9B0QY~`TG+uW4lTJcQ!lm5bd{6e|wUWkmI z&5C+j4cbM!X%96}BkiRo+DH5803D=edW{azVS1g8&`}Cem?G3dt#pjupySj=?er$S zMJMQOdWTNZDSDUQqxb0pI!zzaNAxjuP$zX!H+@29=q&ZnIXX|D(r465ee^l?(*Rwd zi}Xd@(~5@9jAi_lj!dCU!k1Inkq+@6rf}CSt=?%A>N`o~NR>$1lYb^rE}hD0RHZ|d zgEScLoi?9j%2MZyxkUnBbU=4JHQoBh8Pg-JUuVqC&e~R|6VO3#G;`i7Oh24#z7pg6 z|7O-)bGOKc~m7JXz!Ue*Jjd z%9Uzy!YXruU!O==tEEE1+9_cqVbw{HEAuAoBc*C{Doof#$ z$?s9oqx^b%mnxR(WS82V4)NPvs=_6$$7fZOGubF1+N1VLNcO1x&Wt}^b54C9kTQEn z)k-)xr0OK(#(2x^A+=5_eht5VGNkgIwV;Hym_04)BQbluWSDzh!>T}rSk?b?Nc`%s HI#l%+$SUTU diff --git a/scripts/d3d_group/d3d_group.gml b/scripts/d3d_group/d3d_group.gml index 8514103a4..c87436fae 100644 --- a/scripts/d3d_group/d3d_group.gml +++ b/scripts/d3d_group/d3d_group.gml @@ -1,9 +1,12 @@ +#macro __3D_GROUP_PRESUB transform.submitMatrix(); for( var i = 0, n = array_length(objects); i < n; i++ ) +#macro __3D_GROUP_POSSUB transform.clearMatrix(); + function __3dGroup() constructor { objects = []; transform = new __transform(); - static getCenter = function() { #region + static getCenter = function() { var _v = new __vec3(); var _i = 0; @@ -19,9 +22,9 @@ function __3dGroup() constructor { _v.add(transform.position); return _v; - } #endregion + } - static getBBOX = function() { #region + static getBBOX = function() { if(array_empty(objects)) return new __bbox3D(new __vec3(-0.5), new __vec3(0.5)); var _m0 = noone; var _m1 = noone; @@ -50,52 +53,18 @@ function __3dGroup() constructor { _m1._subtract(_cc); return new __bbox3D(_m0, _m1); - } #endregion + } - static addObject = function(_obj) { #region - INLINE - array_push(objects, _obj); - } #endregion + static addObject = function(_obj) { array_push(objects, _obj); } - static submit = function(scene = {}, shader = noone) { #region - transform.submitMatrix(); - for( var i = 0, n = array_length(objects); i < n; i++ ) - objects[i].submit(scene, shader); - transform.clearMatrix(); - } #endregion + static submit = function(_sc = {}, _sh = noone) /*=>*/ { __3D_GROUP_PRESUB objects[i].submit(_sc, _sh); __3D_GROUP_POSSUB } + static submitUI = function(_sc = {}, _sh = noone) /*=>*/ { __3D_GROUP_PRESUB objects[i].submitUI(_sc, _sh); __3D_GROUP_POSSUB } + static submitSel = function(_sc = {}, _sh = noone) /*=>*/ { __3D_GROUP_PRESUB objects[i].submitSel(_sc, _sh); __3D_GROUP_POSSUB } + static submitShader = function(_sc = {}, _sh = noone) /*=>*/ { __3D_GROUP_PRESUB objects[i].submitShader(_sc, _sh); __3D_GROUP_POSSUB } + static submitShadow = function(_sc = {}, object = noone) /*=>*/ { for( var i = 0, n = array_length(objects); i < n; i++ ) objects[i].submitShadow(_sc, object); } + static map = function(callback, _sc = {}) /*=>*/ { for( var i = 0, n = array_length(objects); i < n; i++ ) callback(objects[i], _sc); } - static submitUI = function(scene = {}, shader = noone) { #region - transform.submitMatrix(); - for( var i = 0, n = array_length(objects); i < n; i++ ) - objects[i].submitUI(scene, shader); - transform.clearMatrix(); - } #endregion - - static submitSel = function(scene = {}, shader = noone) { #region - transform.submitMatrix(); - for( var i = 0, n = array_length(objects); i < n; i++ ) - objects[i].submitSel(scene, shader); - transform.clearMatrix(); - } #endregion - - static submitShader = function(scene = {}, shader = noone) { #region - transform.submitMatrix(); - for( var i = 0, n = array_length(objects); i < n; i++ ) - objects[i].submitShader(scene, shader); - transform.clearMatrix(); - } #endregion - - static submitShadow = function(scene = {}, object = noone) { #region - for( var i = 0, n = array_length(objects); i < n; i++ ) - objects[i].submitShadow(scene, object); - } #endregion - - static map = function(callback, scene = {}) { #region - for( var i = 0, n = array_length(objects); i < n; i++ ) - callback(objects[i], scene); - } #endregion - - static clone = function(vertex = true, cloneBuffer = false) { #region + static clone = function(vertex = true, cloneBuffer = false) { var _new = new __3dGroup(); _new.transform = transform.clone(); @@ -105,5 +74,5 @@ function __3dGroup() constructor { _new.objects[i] = objects[i].clone(vertex, cloneBuffer); return _new; - } #endregion + } } \ No newline at end of file diff --git a/scripts/d3d_object/d3d_object.gml b/scripts/d3d_object/d3d_object.gml index 5a38e8b01..792f0ed76 100644 --- a/scripts/d3d_object/d3d_object.gml +++ b/scripts/d3d_object/d3d_object.gml @@ -31,6 +31,7 @@ function __3dObject() constructor { VF = global.VF_POS_COL; NVB = noone; WVB = noone; + name = UUID_generate(); transform = new __transform(); size = new __vec3(1); @@ -154,24 +155,24 @@ function __3dObject() constructor { ////- Submit - static preSubmitVertex = function(scene = {}) {} - static postSubmitVertex = function(scene = {}) {} + static preSubmitVertex = function(_sc = {}) {} + static postSubmitVertex = function(_sc = {}) {} 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 submit = function(scene = {}, shader = noone) { submitVertex(scene, shader); } - static submitUI = function(scene = {}, shader = noone) { submitVertex(scene, shader); } - static submitSel = function(scene = {}, shader = noone) { - var _s = variable_clone(scene); + static submit = function(_sc = {}, _sh = noone) { submitVertex(_sc, _sh); } + static submitUI = function(_sc = {}, _sh = noone) { submitVertex(_sc, _sh); } + static submitSel = function(_sc = {}, _sh = noone) { + var _s = variable_clone(_sc); _s.show_normal = false; submitVertex(_s, sh_d3d_silhouette); } - static submitShader = function(scene = {}, shader = noone) {} - static submitShadow = function(scene = {}, object = noone) {} + static submitShader = function(_sc = {}, _sh = noone) { submitVertex(_sc, _sh); } + static submitShadow = function(_sc = {}, _ob = noone) {} - static submitVertex = function(scene = {}, shader = noone) { + static submitVertex = function(_sc = {}, _sh = noone) { var _shader; switch(VF) { @@ -181,26 +182,32 @@ function __3dObject() constructor { } if(custom_shader != noone) _shader = custom_shader; - if(shader != noone) _shader = shader; - if(!is_undefined(shader)) shader_set(_shader); + if(_sh != noone) _shader = _sh; + if(!is_undefined(_sh)) shader_set(_shader); - preSubmitVertex(scene); + preSubmitVertex(_sc); transform.submitMatrix(); matrix_set(matrix_world, matrix_stack_top()); gpu_set_tex_repeat(true); for( var i = 0, n = array_length(VB); i < n; i++ ) { - var _ind = array_safe_get_fast(material_index, i, i); - var _mat = array_safe_get_fast(materials, _ind, noone); - var _useMat = is_instanceof(_mat, __d3dMaterial); + var _ind = array_safe_get_fast(material_index, i, i); + var _mat = array_safe_get_fast(materials, _ind, noone); + var _uMat = is_instanceof(_mat, __d3dMaterial); shader_set_i("mat_flip", texture_flip); - var _tex = _useMat? _mat.getTexture() : -1; + var _tex = _uMat? _mat.getTexture() : -1; - if(_shader == sh_d3d_default) { - if(_useMat) { - _mat.submitShader(); - } else { + if(_shader == sh_d3d_geometry) { + if(_uMat) _mat.submitGeometry(); + else { + shader_set_i("use_normal", 0); + shader_set_f("mat_texScale", [ 1, 1 ] ); + } + + } else { + if(_uMat) _mat.submitShader(); + else { shader_set_f("mat_diffuse", 1); shader_set_f("mat_specular", 0); shader_set_f("mat_shine", 1); @@ -208,23 +215,16 @@ function __3dObject() constructor { shader_set_f("mat_reflective", 0); shader_set_f("mat_texScale", [ 1, 1 ] ); } - - } else if(_shader == sh_d3d_geometry) { - if(_useMat) _mat.submitGeometry(); - else { - shader_set_i("use_normal", 0); - shader_set_f("mat_texScale", [ 1, 1 ] ); - } - } vertex_submit(VB[i], render_type, _tex); } + // print(shader_get_name(_shader), instanceof(self)); gpu_set_tex_repeat(false); - if(!is_undefined(shader)) shader_reset(); + if(!is_undefined(_sh)) shader_reset(); - if(scene.show_normal) { + if(_sc.show_normal) { if(NVB == noone) generateNormal(); if(NVB != noone) { shader_set(sh_d3d_wireframe); @@ -236,7 +236,7 @@ function __3dObject() constructor { transform.clearMatrix(); matrix_set(matrix_world, matrix_build_identity()); - postSubmitVertex(scene); + postSubmitVertex(_sc); } diff --git a/scripts/globals/globals.gml b/scripts/globals/globals.gml index 6cf0fbce6..c41bd96c2 100644 --- a/scripts/globals/globals.gml +++ b/scripts/globals/globals.gml @@ -41,9 +41,9 @@ globalvar HOTKEYS, HOTKEY_CONTEXT; LATEST_VERSION = 1_18_00_0; - VERSION = 1_18_06_2; + VERSION = 1_18_08_0; SAVE_VERSION = 1_18_05_0; - VERSION_STRING = MAC? "1.18.003m" : "1.18.7.1"; + VERSION_STRING = MAC? "1.18.003m" : "1.18.8.001"; BUILD_NUMBER = 118071.001; PREF_VERSION = 1_17_1; diff --git a/scripts/node_3d_camera/node_3d_camera.gml b/scripts/node_3d_camera/node_3d_camera.gml index ad0fcb038..7ad039947 100644 --- a/scripts/node_3d_camera/node_3d_camera.gml +++ b/scripts/node_3d_camera/node_3d_camera.gml @@ -86,24 +86,26 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group) in_cam = array_length(inputs); newOutput(0, nodeValue_Output("Rendered", self, VALUE_TYPE.surface, noone )); - - newOutput(1, nodeValue_Output("Normal", self, VALUE_TYPE.surface, noone )) - .setVisible(false); - - newOutput(2, nodeValue_Output("Depth", self, VALUE_TYPE.surface, noone )) - .setVisible(false); + newOutput(1, nodeValue_Output("Normal", self, VALUE_TYPE.surface, noone )).setVisible(false); + newOutput(2, nodeValue_Output("Depth", self, VALUE_TYPE.surface, noone )).setVisible(false); + newOutput(3, nodeValue_Output("Shadow", self, VALUE_TYPE.surface, noone )).setVisible(false); + newOutput(4, nodeValue_Output("Ambient Occlusion", self, VALUE_TYPE.surface, noone )).setVisible(false); + newOutput(5, nodeValue_Output("Diffuse", self, VALUE_TYPE.surface, noone )).setVisible(false); input_display_list = [ i+4, - ["Output", false], i+ 2, - ["Transform", false], i+ 9, 0, 1, i+10, i+11, i+12, i+13, i+14, - ["Camera", true], i+ 3, i+ 0, i+ 1, i+ 8, - ["Render", true], i+ 5, i+16, i+ 6, i+ 7, i+15, i+22, - ["Wireframe", true, i+23], i+24, i+25, i+26, i+27, i+28, - ["Ambient Occlusion", true], i+17, i+20, i+18, i+19, - ["Effects", true], i+21, + ["Output", false], i+ 2, + ["Transform", false], i+ 9, 0, 1, i+10, i+11, i+12, i+13, i+14, + ["Camera", true], i+ 3, i+ 0, i+ 1, i+ 8, + ["Render", true], i+ 5, i+16, i+ 6, i+ 7, i+15, i+22, + ["Wireframe", true, i+23], i+24, i+25, i+26, i+27, i+28, + ["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 ); + output_display_list = [ 0, 5, 1, 2, 3, 4 ]; + + temp_surface = [ 0 ]; + tool_lookat = new NodeTool( "Move Target", THEME.tools_3d_transform_object ); ////- Preview @@ -207,7 +209,7 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group) static submitShadow = function() {} static submitShader = function() {} - static processData = function(_output, _data, _output_index, _array_index = 0) { + static processData = function(_outData, _data, _output_index, _array_index = 0) { #region data var _pos = _data[0]; var _rot = _data[1]; @@ -330,36 +332,32 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group) #endregion #region submit - var _render = outputs[0].getValue(); - var _normal = outputs[1].getValue(); - var _depth = outputs[2].getValue(); + for( var i = 0, n = array_length(_outData); i < n; i++ ) { + if(is_surface(_outData[i]) && !surface_has_depth(_outData[i])) + surface_free(_outData[i]); + _outData[i] = surface_verify(_outData[i], _dim[0], _dim[1]); + } + + temp_surface[0] = surface_verify(temp_surface[0], _dim[0], _dim[1]); + var _render = temp_surface[0]; var _bgSurf = _dbg? scene.renderBackground(_dim[0], _dim[1]) : noone; - - _render = surface_verify(_render, _dim[0], _dim[1]); - _normal = surface_verify(_normal, _dim[0], _dim[1]); - _depth = surface_verify(_depth , _dim[0], _dim[1]); - + if(_sobj) { _sobj.submitShadow(scene, _sobj); submitShadow(); - deferData = scene.deferPass(_sobj, _dim[0], _dim[1], deferData); + deferData = scene.deferPass(_sobj, _dim[0], _dim[1], deferData); surface_set_target_ext(0, _render); - surface_set_target_ext(1, _normal); - surface_set_target_ext(2, _depth ); - + surface_set_target_ext(1, _outData[1]); + surface_set_target_ext(2, _outData[2]); + surface_set_target_ext(3, _outData[3]); DRAW_CLEAR gpu_set_zwriteenable(true); gpu_set_cullmode(_back); - - if(_blend == 0) { - gpu_set_ztestenable(true); - } else { - BLEND_ADD - gpu_set_ztestenable(false); - } + gpu_set_ztestenable(_blend == 0); + if(_blend == 1) BLEND_ADD camera.applyCamera(); scene.reset(); @@ -373,12 +371,30 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group) surface_reset_target(); camera.resetCamera(); + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + surface_set_target_ext(0, _outData[5]); + DRAW_CLEAR + + gpu_set_zwriteenable(true); + gpu_set_cullmode(_back); + gpu_set_ztestenable(_blend == 0); + if(_blend == 1) BLEND_ADD + + camera.applyCamera(); + scene.submitShader(_sobj, sh_d3d_unlit); + + BLEND_NORMAL + surface_reset_target(); + + camera.resetCamera(); + } #endregion #region render - var _finalRender = surface_create(_dim[0], _dim[1]); - surface_set_target(_finalRender); + surface_set_target(_outData[0]); DRAW_CLEAR BLEND_ALPHA @@ -395,11 +411,13 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group) } surface_reset_target(); surface_free(_render); + + _outData[4] = deferData.ssao; #endregion surface_depth_disable(true); - return [ _finalRender, _normal, _depth ]; + return _outData; } ////- Draw diff --git a/scripts/node_3d_light_directional/node_3d_light_directional.gml b/scripts/node_3d_light_directional/node_3d_light_directional.gml index 9ed6457e7..e355b5717 100644 --- a/scripts/node_3d_light_directional/node_3d_light_directional.gml +++ b/scripts/node_3d_light_directional/node_3d_light_directional.gml @@ -14,37 +14,14 @@ function Node_3D_Light_Directional(_x, _y, _group = noone) : Node_3D_Light(_x, _ input_display_list = [ ["Transform", false], 0, __d3d_input_list_light, - ["Shadow", false], in_light + 0, in_light + 1, in_light + 2, in_light + 3, + ["Shadow", false, in_light + 0], in_light + 1, in_light + 2, in_light + 3, ] tools = [ tool_pos ]; tool_settings = []; tool_attribute.context = 1; - //static drawOverlay3D = function(active, params, _mx, _my, _snx, _sny, _panel) { #region - // var object = getObject(0); - // var _outSurf = object.shadow_map; - - // if(!is_surface(_outSurf)) return; - - // var _w = _panel.w; - // var _h = _panel.h - _panel.toolbar_height; - // var _pw = surface_get_width_safe(_outSurf); - // var _ph = surface_get_height_safe(_outSurf); - // var _ps = min(128 / _ph, 160 / _pw); - - // var _pws = _pw * _ps; - // var _phs = _ph * _ps; - - // var _px = _w - 16 - _pws; - // var _py = _h - 16 - _phs; - - // draw_surface_ext_safe(_outSurf, _px, _py, _ps, _ps); - // draw_set_color(COLORS._main_icon); - // draw_rectangle(_px, _py, _px + _pws, _py + _phs, true); - //} #endregion - - static processData = function(_output, _data, _output_index, _array_index = 0) { #region + static processData = function(_output, _data, _output_index, _array_index = 0) { var _active = _data[in_d3d + 0]; if(!_active) return noone; @@ -64,5 +41,5 @@ function Node_3D_Light_Directional(_x, _y, _group = noone) : Node_3D_Light(_x, _ object.transform.rotation.FromEuler(_rot.x, _rot.y, _rot.z); return object; - } #endregion + } } \ No newline at end of file diff --git a/scripts/node_3d_light_point/node_3d_light_point.gml b/scripts/node_3d_light_point/node_3d_light_point.gml index b57e8eb5f..51ea35ea2 100644 --- a/scripts/node_3d_light_point/node_3d_light_point.gml +++ b/scripts/node_3d_light_point/node_3d_light_point.gml @@ -17,7 +17,7 @@ function Node_3D_Light_Point(_x, _y, _group = noone) : Node_3D_Light(_x, _y, _gr input_display_list = [ ["Transform", false], 0, __d3d_input_list_light, in_light, - ["Shadow", false], in_light + 1, in_light + 2, in_light + 3, + ["Shadow", false, in_light + 1], in_light + 2, in_light + 3, ] tools = [ tool_pos ]; @@ -43,14 +43,4 @@ function Node_3D_Light_Point(_x, _y, _group = noone) : Node_3D_Light(_x, _y, _gr return _object; } - - // static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { - // var bbox = drawGetBbox(xx, yy, _s); - // var _object = getObject(0); - - // if(_object == noone) return; - - // var __smap = _object.shadow_map; - // draw_surface_ext_safe(__smap, bbox.x0, bbox.y0, .5 * _s, .5 * _s); - // } } \ No newline at end of file diff --git a/shaders/sh_d3d_default/sh_d3d_default.fsh b/shaders/sh_d3d_default/sh_d3d_default.fsh index b77de78ed..535464a00 100644 --- a/shaders/sh_d3d_default/sh_d3d_default.fsh +++ b/shaders/sh_d3d_default/sh_d3d_default.fsh @@ -206,6 +206,7 @@ void main() { mat_baseColor *= v_vColour; vec4 final_color = mat_baseColor; + vec3 shadow = vec3(0.); if(show_wireframe == 1 && wireframe_shade == 1) final_color = wireframeCalc(final_color); vec3 viewDirection = normalize(cameraPosition - v_worldPosition.xyz); @@ -272,20 +273,18 @@ void main() { if(lightMapUV.x >= 0. && lightMapUV.x <= 1. && lightMapUV.y >= 0. && lightMapUV.y <= 1.) { light_map_depth = sampleDirShadowMap(shadow_map_index, lightMapUV); - //gl_FragData[0] = texture2D(light_dir_shadowmap_0, lightMapUV); - //return; - shadow_map_index++; float shadowFactor = dot(normal, lightVector); float bias = mix(light_dir_shadow_bias[i], 0., shadowFactor); - if(l_lightDistance > light_map_depth + bias) + if(l_lightDistance > light_map_depth + bias) { + shadow += 1. / float(light_dir_count + light_pnt_count); continue; + } } - } + } vec3 light_phong = phongLight(normal, lightVector, viewDirection, light_dir_color[i].rgb); - light_effect += light_phong * light_dir_intensity[i]; } #endregion @@ -299,11 +298,8 @@ void main() { vec3 lightVector = light_pnt_position[i] - v_worldPosition.xyz; light_distance = length(lightVector); - if(light_distance > light_pnt_radius[i]) { - // gl_FragData[0] = vec4(1., 0., 0., .5); - // return; + if(light_distance > light_pnt_radius[i]) continue; - } lightVector = normalize(lightVector); @@ -328,17 +324,15 @@ void main() { light_map_depth = samplePntShadowMap(shadow_map_index, lightMapUV, side); shadow_map_index++; - // gl_FragData[0] = vec4((l_lightDistance - (light_map_depth + bias)) * 10., ((light_map_depth + bias) - l_lightDistance) * 10., 0., 1.); - // return; - - if(l_lightDistance > light_map_depth + bias) + if(l_lightDistance > light_map_depth + bias) { + shadow += 1. / float(light_dir_count + light_pnt_count); continue; + } } } light_attenuation = 1. - pow(light_distance / light_pnt_radius[i], 2.); vec3 light_phong = phongLight(normal, lightVector, viewDirection, light_pnt_color[i].rgb * light_attenuation); - light_effect += light_phong * light_pnt_intensity[i]; } #endregion @@ -360,4 +354,5 @@ void main() { gl_FragData[0] = final_color; 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[3] = vec4(shadow, 1.); } \ No newline at end of file diff --git a/shaders/sh_d3d_ssao/sh_d3d_ssao.fsh b/shaders/sh_d3d_ssao/sh_d3d_ssao.fsh index a0980329b..0c8159a17 100644 --- a/shaders/sh_d3d_ssao/sh_d3d_ssao.fsh +++ b/shaders/sh_d3d_ssao/sh_d3d_ssao.fsh @@ -66,5 +66,4 @@ void main() { } gl_FragColor = vec4(vec3(1. - occluded / raysTotal * strength), 1.); - //gl_FragColor = vec4(vec3(distance(cPosition, cameraPosition) / 10.), 1.); } diff --git a/shaders/sh_d3d_unlit/sh_d3d_unlit.fsh b/shaders/sh_d3d_unlit/sh_d3d_unlit.fsh new file mode 100644 index 000000000..200db0932 --- /dev/null +++ b/shaders/sh_d3d_unlit/sh_d3d_unlit.fsh @@ -0,0 +1,107 @@ +#extension GL_OES_standard_derivatives : enable + +varying vec2 v_vTexcoord; +varying vec4 v_vColour; +varying vec3 v_vNormal; +varying vec3 v_barycentric; + +varying vec4 v_worldPosition; +varying vec3 v_viewPosition; +varying float v_cameraDistance; + +#define PI 3.14159265359 +#define TAU 6.28318530718 + +uniform int use_8bit; + +#region ---- light ---- + uniform vec4 light_ambient; + uniform float shadowBias; + + #ifdef _YY_HLSL11_ + #define LIGHT_DIR_LIMIT 16 + #define LIGHT_PNT_LIMIT 16 + #define LIGHT_PNT_LIMIT6 16*6 + #else + #define LIGHT_DIR_LIMIT 8 + #define LIGHT_PNT_LIMIT 8 + #define LIGHT_PNT_LIMIT6 8*6 + #endif + + uniform int light_dir_count; + uniform vec3 light_dir_direction[LIGHT_DIR_LIMIT]; + uniform vec4 light_dir_color[LIGHT_DIR_LIMIT]; + uniform float light_dir_intensity[LIGHT_DIR_LIMIT]; + + uniform mat4 light_dir_view[LIGHT_DIR_LIMIT]; + uniform mat4 light_dir_proj[LIGHT_DIR_LIMIT]; + uniform int light_dir_shadow_active[LIGHT_DIR_LIMIT]; + uniform float light_dir_shadow_bias[LIGHT_DIR_LIMIT]; + uniform sampler2D light_dir_shadowmap_0; + uniform sampler2D light_dir_shadowmap_1; + //uniform sampler2D light_dir_shadowmap_2; + //uniform sampler2D light_dir_shadowmap_3; + + uniform int light_pnt_count; + uniform vec3 light_pnt_position[LIGHT_PNT_LIMIT]; + uniform vec4 light_pnt_color[LIGHT_PNT_LIMIT]; + uniform float light_pnt_intensity[LIGHT_PNT_LIMIT]; + uniform float light_pnt_radius[LIGHT_PNT_LIMIT]; + + uniform mat4 light_pnt_view[LIGHT_PNT_LIMIT6]; + uniform mat4 light_pnt_proj[LIGHT_PNT_LIMIT]; + uniform int light_pnt_shadow_active[LIGHT_PNT_LIMIT]; + uniform float light_pnt_shadow_bias[LIGHT_DIR_LIMIT]; + uniform sampler2D light_pnt_shadowmap_0; + uniform sampler2D light_pnt_shadowmap_1; + //uniform sampler2D light_pnt_shadowmap_2; + //uniform sampler2D light_pnt_shadowmap_3; +#endregion + +#region ---- material ---- + vec4 mat_baseColor; + + uniform float mat_diffuse; + uniform float mat_specular; + uniform float mat_shine; + uniform int mat_metalic; + uniform float mat_reflective; + uniform vec2 mat_texScale; + uniform vec2 mat_texShift; + + uniform int mat_defer_normal; + uniform float mat_normal_strength; + uniform sampler2D mat_normal_map; + + uniform int mat_flip; +#endregion + +#region ---- rendering ---- + uniform vec3 cameraPosition; + uniform int gammaCorrection; + + uniform int env_use_mapping; + uniform sampler2D env_map; + uniform vec2 env_map_dimension; + + 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 + +void main() { + vec2 uv_coord = v_vTexcoord; + if(mat_flip == 1) uv_coord.y = -uv_coord.y; + + uv_coord = fract(uv_coord * mat_texScale + mat_texShift); + mat_baseColor = texture2D( gm_BaseTexture, uv_coord ); + mat_baseColor *= v_vColour; + + gl_FragData[0] = mat_baseColor; + // gl_FragColor = mat_baseColor; +} \ No newline at end of file diff --git a/shaders/sh_d3d_unlit/sh_d3d_unlit.vsh b/shaders/sh_d3d_unlit/sh_d3d_unlit.vsh new file mode 100644 index 000000000..829ce6945 --- /dev/null +++ b/shaders/sh_d3d_unlit/sh_d3d_unlit.vsh @@ -0,0 +1,37 @@ +attribute vec3 in_Position; +attribute vec3 in_Normal; +attribute vec2 in_TextureCoord; +attribute vec4 in_Colour; +attribute vec3 in_Barycentric; + +varying vec2 v_vTexcoord; +varying vec4 v_vColour; +varying vec3 v_vNormal; +varying vec3 v_barycentric; + +varying vec4 v_worldPosition; +varying vec3 v_viewPosition; +varying float v_cameraDistance; + +uniform float planeNear; +uniform float planeFar; + +void main() { + vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0); + gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos; + + v_worldPosition = gm_Matrices[MATRIX_WORLD] * object_space_pos; + v_viewPosition = gl_Position.xyz; + + v_vColour = in_Colour; + v_vTexcoord = in_TextureCoord; + + vec3 worldNormal = normalize(gm_Matrices[MATRIX_WORLD] * vec4(in_Normal, 0.)).xyz; + v_vNormal = worldNormal; + + float depthRange = abs(planeFar - planeNear); + float ndcDepth = (gl_Position.z - planeNear) / depthRange; + v_cameraDistance = ndcDepth * 0.5 + 0.5; + + v_barycentric = in_Barycentric; +} diff --git a/shaders/sh_d3d_unlit/sh_d3d_unlit.yy b/shaders/sh_d3d_unlit/sh_d3d_unlit.yy new file mode 100644 index 000000000..760e73881 --- /dev/null +++ b/shaders/sh_d3d_unlit/sh_d3d_unlit.yy @@ -0,0 +1,13 @@ +{ + "$GMShader":"", + "%Name":"sh_d3d_unlit", + "name":"sh_d3d_unlit", + "parent":{ + "name":"shader", + "path":"folders/nodes/data/3D/shader.yy", + }, + "resourceType":"GMShader", + "resourceVersion":"2.0", + "tags":[], + "type":1, +} \ No newline at end of file