From 1907b33d809f96cefec9a67a99150281d598d5e7 Mon Sep 17 00:00:00 2001 From: Tanasart <22589759+Ttanasart-pt@users.noreply.github.com> Date: Tue, 5 Sep 2023 18:05:18 +0200 Subject: [PATCH] - [3D Camera] Fix render result error when previewing. --- PixelComposer.resource_order | 3 + PixelComposer.yyp | 5 + datafiles/GMD3D11.dll | Bin 0 -> 31744 bytes scripts/__d3d11/__d3d11.gml | 124 ++++++++++++ scripts/__d3d11/__d3d11.yy | 11 ++ scripts/__d3d11_cbuffer/__d3d11_cbuffer.gml | 183 ++++++++++++++++++ scripts/__d3d11_cbuffer/__d3d11_cbuffer.yy | 11 ++ scripts/__d3d11_shader/__d3d11_shader.gml | 104 ++++++++++ scripts/__d3d11_shader/__d3d11_shader.yy | 11 ++ scripts/__node_3d/__node_3d.gml | 4 +- .../__panel_linear_setting.gml | 17 ++ scripts/d3d_scene/d3d_scene.gml | 40 ++-- scripts/globals/globals.gml | 6 +- scripts/node_3d_camera/node_3d_camera.gml | 11 +- scripts/panel_preview/panel_preview.gml | 56 +++--- .../panel_preview_3d_setting.gml | 15 +- scripts/shader_functions/shader_functions.gml | 17 ++ shaders/sh_d3d_default/sh_d3d_default.fsh | 8 + 18 files changed, 564 insertions(+), 62 deletions(-) create mode 100644 datafiles/GMD3D11.dll create mode 100644 scripts/__d3d11/__d3d11.gml create mode 100644 scripts/__d3d11/__d3d11.yy create mode 100644 scripts/__d3d11_cbuffer/__d3d11_cbuffer.gml create mode 100644 scripts/__d3d11_cbuffer/__d3d11_cbuffer.yy create mode 100644 scripts/__d3d11_shader/__d3d11_shader.gml create mode 100644 scripts/__d3d11_shader/__d3d11_shader.yy diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index 774d3f93e..72efa6fca 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -5,6 +5,7 @@ {"name":"_extensions","order":16,"path":"folders/_extensions.yy",}, {"name":"BBMOD","order":8,"path":"folders/_extensions/BBMOD.yy",}, {"name":"Math","order":1,"path":"folders/_extensions/BBMOD/Math.yy",}, + {"name":"GMD3D11","order":11,"path":"folders/_extensions/GMD3D11.yy",}, {"name":"MAC","order":6,"path":"folders/_extensions/MAC.yy",}, {"name":"addons","order":10,"path":"folders/addons.yy",}, {"name":"custom","order":4,"path":"folders/addons/custom.yy",}, @@ -1315,6 +1316,7 @@ {"name":"vectorBox","order":18,"path":"scripts/vectorBox/vectorBox.yy",}, {"name":"sh_3d_extrude_corner","order":7,"path":"shaders/sh_3d_extrude_corner/sh_3d_extrude_corner.yy",}, {"name":"sh_blend_normal_dim","order":10,"path":"shaders/sh_blend_normal_dim/sh_blend_normal_dim.yy",}, + {"name":"__d3d11_cbuffer","order":1,"path":"scripts/__d3d11_cbuffer/__d3d11_cbuffer.yy",}, {"name":"node_skew","order":11,"path":"scripts/node_skew/node_skew.yy",}, {"name":"s_node_dot_product","order":13,"path":"sprites/s_node_dot_product/s_node_dot_product.yy",}, {"name":"sh_downsample","order":1,"path":"shaders/sh_downsample/sh_downsample.yy",}, @@ -1353,6 +1355,7 @@ {"name":"node_grey_to_alpha","order":4,"path":"scripts/node_grey_to_alpha/node_grey_to_alpha.yy",}, {"name":"sh_blend_add","order":7,"path":"shaders/sh_blend_add/sh_blend_add.yy",}, {"name":"s_node_FFT","order":15,"path":"sprites/s_node_FFT/s_node_FFT.yy",}, + {"name":"__d3d11_shader","order":2,"path":"scripts/__d3d11_shader/__d3d11_shader.yy",}, {"name":"node_de_stray","order":1,"path":"scripts/node_de_stray/node_de_stray.yy",}, {"name":"d3d_transformation","order":12,"path":"scripts/d3d_transformation/d3d_transformation.yy",}, {"name":"sh_channel_G","order":2,"path":"shaders/sh_channel_G/sh_channel_G.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index ff0161ef3..ff0373823 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -25,6 +25,7 @@ {"resourceType":"GMFolder","resourceVersion":"1.0","name":"BBMOD","folderPath":"folders/_extensions/BBMOD.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"Math","folderPath":"folders/_extensions/BBMOD/Math.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"Gameframe","folderPath":"folders/_extensions/Gameframe.yy",}, + {"resourceType":"GMFolder","resourceVersion":"1.0","name":"GMD3D11","folderPath":"folders/_extensions/GMD3D11.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"MAC","folderPath":"folders/_extensions/MAC.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"addons","folderPath":"folders/addons.yy",}, {"resourceType":"GMFolder","resourceVersion":"1.0","name":"custom","folderPath":"folders/addons/custom.yy",}, @@ -667,6 +668,7 @@ {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"gifski.dll","CopyToMask":-1,"filePath":"datafiles/gifski/win/developer",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"gifski.h","CopyToMask":-1,"filePath":"datafiles/gifski/win/developer",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"gifski.exe","CopyToMask":-1,"filePath":"datafiles/gifski/win",}, + {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"GMD3D11.dll","CopyToMask":-1,"filePath":"datafiles",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"convert.exe","CopyToMask":-1,"filePath":"datafiles/ImageMagick",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"LICENSE.txt","CopyToMask":-1,"filePath":"datafiles/ImageMagick",}, {"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"magick.exe","CopyToMask":-1,"filePath":"datafiles/ImageMagick",}, @@ -1992,6 +1994,7 @@ {"id":{"name":"vectorBox","path":"scripts/vectorBox/vectorBox.yy",},}, {"id":{"name":"sh_3d_extrude_corner","path":"shaders/sh_3d_extrude_corner/sh_3d_extrude_corner.yy",},}, {"id":{"name":"sh_blend_normal_dim","path":"shaders/sh_blend_normal_dim/sh_blend_normal_dim.yy",},}, + {"id":{"name":"__d3d11_cbuffer","path":"scripts/__d3d11_cbuffer/__d3d11_cbuffer.yy",},}, {"id":{"name":"node_skew","path":"scripts/node_skew/node_skew.yy",},}, {"id":{"name":"s_node_dot_product","path":"sprites/s_node_dot_product/s_node_dot_product.yy",},}, {"id":{"name":"s_node_canvas","path":"sprites/s_node_canvas/s_node_canvas.yy",},}, @@ -2037,6 +2040,7 @@ {"id":{"name":"node_grey_to_alpha","path":"scripts/node_grey_to_alpha/node_grey_to_alpha.yy",},}, {"id":{"name":"sh_blend_add","path":"shaders/sh_blend_add/sh_blend_add.yy",},}, {"id":{"name":"s_node_FFT","path":"sprites/s_node_FFT/s_node_FFT.yy",},}, + {"id":{"name":"__d3d11_shader","path":"scripts/__d3d11_shader/__d3d11_shader.yy",},}, {"id":{"name":"node_de_stray","path":"scripts/node_de_stray/node_de_stray.yy",},}, {"id":{"name":"d3d_transformation","path":"scripts/d3d_transformation/d3d_transformation.yy",},}, {"id":{"name":"sh_channel_G","path":"shaders/sh_channel_G/sh_channel_G.yy",},}, @@ -2092,6 +2096,7 @@ {"id":{"name":"node_action_object","path":"scripts/node_action_object/node_action_object.yy",},}, {"id":{"name":"s_node_pb_box_divide","path":"sprites/s_node_pb_box_divide/s_node_pb_box_divide.yy",},}, {"id":{"name":"bin_function","path":"scripts/bin_function/bin_function.yy",},}, + {"id":{"name":"__d3d11","path":"scripts/__d3d11/__d3d11.yy",},}, {"id":{"name":"s_node_feedback_output","path":"sprites/s_node_feedback_output/s_node_feedback_output.yy",},}, {"id":{"name":"sh_fd_repulse","path":"shaders/sh_fd_repulse/sh_fd_repulse.yy",},}, {"id":{"name":"sh_surface_replace_fast_find","path":"shaders/sh_surface_replace_fast_find/sh_surface_replace_fast_find.yy",},}, diff --git a/datafiles/GMD3D11.dll b/datafiles/GMD3D11.dll new file mode 100644 index 0000000000000000000000000000000000000000..a065213ad8ad907bf1da1d511edfd3e319423f1d GIT binary patch literal 31744 zcmeHw4PaE&weFr|CJaf288D+kQ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~6&8l+__;0i{l0$v69Lxj5nuq8n9m8GLB1j!fH3Y;MM!3ZZvzAVBC zu0YU}%y0bYuv0;KA!=k&@^Qcx&OpZ>WAQs3bm!vRx{;~qYe7LvL%j`$?m=8v&Ci-W zD<{k5YpiMVVrieBwX&jQW^R^^oCMx#TxRy=XKnEXvkDfPQWsPQgT99K^;>KZ&=}0m z!nSdKu%^z}P#v7v;I9cZ1)FL^GvO$hUma|iwP|*i4GUp^E&Lj*w7Ef)&9)#E2nR!M zY-tr~Q@=)bm4Zh$|q&B*k?;TNWk8hK& z9(TF%&d;h2x*In&ZS)1QY+=8vhPDCuS+&*mL0^{b${{%mt~`4#3vm5gqtk*bhYE+} z3$9e_4IigB$LW+R+;0PQ`|kGLJ9qEey=V9S-QBx;cAwZiusi3$+y|WxRy|nvVDp15 z54JwI{Xxq^nGe|>%6_Q*p`8y6JT&-F{3qQ%$$r@Ru<&rt!_vb84-Y=f9x*=B`pEW2 m+8^2Z2;KJ~dlGiF?Ao=fdzZA!_~Yy!pRU3`DF1mi@V@}geE(bk literal 0 HcmV?d00001 diff --git a/scripts/__d3d11/__d3d11.gml b/scripts/__d3d11/__d3d11.gml new file mode 100644 index 000000000..e71d3381a --- /dev/null +++ b/scripts/__d3d11/__d3d11.gml @@ -0,0 +1,124 @@ +/// @macro {String} Path to the GMD3D11 dynamic library. +/// Default value is "GMD3D11.dll". +#macro GMD3D11_PATH "GMD3D11.dll" + +/// @macro {Bool} Expands to `true` if GMD3D11 is supported on the current +/// platform. +#macro GMD3D11_IS_SUPPORTED (os_type == os_windows) + +/// @func d3d11_get_error_string() +/// +/// @desc Retrieves the last error message. +/// +/// @return {String} The last error message. +function d3d11_get_error_string() +{ + gml_pragma("forceinline"); + static _fn = external_define( + GMD3D11_PATH, "d3d11_get_error_string", dll_cdecl, ty_string, + 0); + return external_call(_fn); +} + +/// @func d3d11_texture_set_stage_vs(_slot, _texture) +/// +/// @desc Passes a texture to a vertex shader. +/// +/// @param {Real} _slot The vertex texture slot index. Must be in range +/// 0..{@link D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT}-1. +/// @param {Pointer.Texture} _texture The texture to pass. +/// +/// @return {Real} Returns 1 on success or 0 on fail. +function d3d11_texture_set_stage_vs(_slot, _texture) +{ + gml_pragma("forceinline"); + static _fn = external_define( + GMD3D11_PATH, "d3d11_texture_set_stage_vs", dll_cdecl, ty_real, + 1, ty_real); + texture_set_stage(0, _texture); + return external_call(_fn, _slot); +} + +/// @func texture_set_stage_vs(_slot, _texture) +/// +/// @desc If GMD3D11 is supported, then uses {@link d3d11_texture_set_stage_vs} +/// to pass a texture to a vertex shader, otherwise uses `texture_set_stage` +/// (which should work on OpenGL platforms). +/// +/// @param {Real} _slot The vertex texture slot index. Must be in range 0..7. +/// @param {Pointer.Texture} _texture The texture to pass. +/// +/// @see GMD3D11_IS_SUPPORTED +function texture_set_stage_vs(_slot, _texture) +{ + gml_pragma("forceinline"); + if (GMD3D11_IS_SUPPORTED) + { + d3d11_texture_set_stage_vs(_slot, _texture); + return; + } + texture_set_stage(_slot, _texture); +} + +/// @func d3d11_texture_set_stage_ps(_slot, _texture) +/// +/// @desc Passes a texture to a pixel shader. +/// +/// @param {Real} _slot The pixel texture slot index. Must be in range +/// 0..{@link D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT}-1. +/// @param {Pointer.Texture} _texture The texture to pass. +/// +/// @return {Real} Returns 1 on success or 0 on fail. +function d3d11_texture_set_stage_ps(_slot, _texture) +{ + gml_pragma("forceinline"); + static _fn = external_define( + GMD3D11_PATH, "d3d11_texture_set_stage_ps", dll_cdecl, ty_real, + 1, ty_real); + texture_set_stage(0, _texture); + return external_call(_fn, _slot); +} + +/// @func d3d11_draw_instanced(_count) +/// +/// @desc Configures the number of instances to draw the next time a vertex buffer +/// is submitted. After that the number is reset back to 0! +/// +/// @param {Real} _count Number of instances to draw. Use 0 to disable instanced rendering. +function d3d11_draw_instanced(_count) +{ + gml_pragma("forceinline"); + static _fn = external_define( + GMD3D11_PATH, "d3d11_draw_instanced", dll_cdecl, ty_real, + 1, ty_real); + return external_call(_fn, _count); +} + +/// @func vertex_submit_instanced(_vbuff, _prim, _texture, _count) +/// +/// @desc Draws multiple instances of a vertex buffer. +/// +/// @param {Id.VertexBuffer} _vbuff The vertex buffer to submit. +/// @param {Constant.PrimitiveType} _prim The primitive type. +/// @param {Pointer.Texture} _texture The texture to use. +/// @param {Real} _count The number of instances to draw. +function vertex_submit_instanced(_vbuff, _prim, _texture, _count) +{ + gml_pragma("forceinline"); + if (!d3d11_draw_instanced(_count)) + { + return false; + } + vertex_submit(_vbuff, _prim, _texture); + return true; +} + +if (GMD3D11_IS_SUPPORTED) +{ + var _init = external_define( + GMD3D11_PATH, "d3d11_init", dll_cdecl, ty_real, 2, ty_string, ty_string); + var _osInfo = os_get_info(); + var _device = _osInfo[? "video_d3d11_device"]; + var _context = _osInfo[? "video_d3d11_context"]; + external_call(_init, _device, _context); +} diff --git a/scripts/__d3d11/__d3d11.yy b/scripts/__d3d11/__d3d11.yy new file mode 100644 index 000000000..75dad56c2 --- /dev/null +++ b/scripts/__d3d11/__d3d11.yy @@ -0,0 +1,11 @@ +{ + "resourceType": "GMScript", + "resourceVersion": "1.0", + "name": "__d3d11", + "isCompatibility": false, + "isDnD": false, + "parent": { + "name": "GMD3D11", + "path": "folders/_extensions/GMD3D11.yy", + }, +} \ No newline at end of file diff --git a/scripts/__d3d11_cbuffer/__d3d11_cbuffer.gml b/scripts/__d3d11_cbuffer/__d3d11_cbuffer.gml new file mode 100644 index 000000000..438d8de40 --- /dev/null +++ b/scripts/__d3d11_cbuffer/__d3d11_cbuffer.gml @@ -0,0 +1,183 @@ +/// @func d3d11_cbuffer_begin() +/// +/// @desc Starts building a constant buffer. +/// +/// @see d3d11_cbuffer_end +function d3d11_cbuffer_begin() +{ + gml_pragma("forceinline"); + static _fn = external_define( + GMD3D11_PATH, "d3d11_cbuffer_begin", dll_cdecl, ty_real, + 0); + return external_call(_fn); +} + +/// @func d3d11_cbuffer_end() +/// +/// @desc Finishes building a constant buffer. +/// +/// @return {Real} The ID of the created constant buffer or -1 on fail. +/// +/// @see d3d11_cbuffer_exists +/// @see d3d11_cbuffer_update +function d3d11_cbuffer_end() +{ + gml_pragma("forceinline"); + static _fn = external_define( + GMD3D11_PATH, "d3d11_cbuffer_end", dll_cdecl, ty_real, + 0); + return external_call(_fn); +} + +/// @func d3d11_cbuffer_add_bool(_count) +/// +/// @desc Adds a bool into a constant buffer that is currently being built. +/// +/// @param {Real} _count Number of bools to add into the constant buffer. +/// +/// @see d3d11_cbuffer_begin +function d3d11_cbuffer_add_bool(_count) +{ + gml_pragma("forceinline"); + static _fn = external_define( + GMD3D11_PATH, "d3d11_cbuffer_add_bool", dll_cdecl, ty_real, + 1, ty_real); + return external_call(_fn, _count); +} + +/// @func d3d11_cbuffer_add_int(_count) +/// +/// @desc Adds an int into a constant buffer that is currently being built. +/// +/// @param {Real} _count Number of ints to add into the constant buffer. +/// +/// @see d3d11_cbuffer_begin +function d3d11_cbuffer_add_int(_count) +{ + gml_pragma("forceinline"); + static _fn = external_define( + GMD3D11_PATH, "d3d11_cbuffer_add_int", dll_cdecl, ty_real, + 1, ty_real); + return external_call(_fn, _count); +} + +/// @func d3d11_cbuffer_add_uint(_count) +/// +/// @desc Adds an uint into a constant buffer that is currently being built. +/// +/// @param {Real} _count Number of uints to add into the constant buffer. +/// +/// @see d3d11_cbuffer_begin +function d3d11_cbuffer_add_uint(_count) +{ + gml_pragma("forceinline"); + static _fn = external_define( + GMD3D11_PATH, "d3d11_cbuffer_add_uint", dll_cdecl, ty_real, + 1, ty_real); + return external_call(_fn, _count); +} + +/// @func d3d11_cbuffer_add_float(_count) +/// +/// @desc Adds a float into a constant buffer that is currently being built. +/// +/// @param {Real} _count Number of floats to add into the constant buffer. +/// +/// @see d3d11_cbuffer_begin +function d3d11_cbuffer_add_float(_count) +{ + gml_pragma("forceinline"); + static _fn = external_define( + GMD3D11_PATH, "d3d11_cbuffer_add_float", dll_cdecl, ty_real, + 1, ty_real); + return external_call(_fn, _count); +} + +/// @func d3d11_cbuffer_get_size(_cbuffer) +/// +/// @desc Retrieves size of a constant buffer in bytes. +/// +/// @param {Real} The size of the constant buffer in bytes. +function d3d11_cbuffer_get_size(_cbuffer) +{ + gml_pragma("forceinline"); + static _fn = external_define( + GMD3D11_PATH, "d3d11_cbuffer_get_size", dll_cdecl, ty_real, + 1, ty_real); + return external_call(_fn, _cbuffer); +} + +/// @func d3d11_cbuffer_update(_cbuffer, _buffer) +/// +/// @desc Updates data of a constant buffer. +/// +/// @param {Real} _cbuffer The ID of the constant buffer. +/// @param {Id.Buffer} _buffer A buffer with new data. +function d3d11_cbuffer_update(_cbuffer, _buffer) +{ + gml_pragma("forceinline"); + static _fn = external_define( + GMD3D11_PATH, "d3d11_cbuffer_update", dll_cdecl, ty_real, + 2, ty_real, ty_string); + return external_call(_fn, _cbuffer, buffer_get_address(_buffer)); +} + +/// @func d3d11_shader_set_cbuffer_ps(_slot, _cbuffer) +/// +/// @desc Binds a constant buffer to a pixel shader. +/// +/// @param {Real} _slot The slot to bind the constant buffer to. +/// @param {Real} _cbuffer The ID of the constant buffer or -1 to ubind the slot. +function d3d11_shader_set_cbuffer_ps(_slot, _cbuffer) +{ + gml_pragma("forceinline"); + static _fn = external_define( + GMD3D11_PATH, "d3d11_shader_set_cbuffer_ps", dll_cdecl, ty_real, + 2, ty_real, ty_real); + return external_call(_fn, _slot, _cbuffer); +} + +/// @func d3d11_shader_set_cbuffer_vs(_slot, _cbuffer) +/// +/// @desc Binds a constant buffer to a vertex shader. +/// +/// @param {Real} _slot The slot to bind the constant buffer to. +/// @param {Real} _cbuffer The ID of the constant buffer or -1 to ubind the slot. +function d3d11_shader_set_cbuffer_vs(_slot, _cbuffer) +{ + gml_pragma("forceinline"); + static _fn = external_define( + GMD3D11_PATH, "d3d11_shader_set_cbuffer_vs", dll_cdecl, ty_real, + 2, ty_real, ty_real); + return external_call(_fn, _slot, _cbuffer); +} + +/// @func d3d11_cbuffer_exists(_cbuffer) +/// +/// @desc Checks whether a constant buffer exists. +/// +/// @param {Real} _cbuffer The ID of the comand buffer. +/// +/// @return {Bool} Returns true if the constant buffer exists. +function d3d11_cbuffer_exists(_cbuffer) +{ + gml_pragma("forceinline"); + static _fn = external_define( + GMD3D11_PATH, "d3d11_cbuffer_exists", dll_cdecl, ty_real, + 1, ty_real); + return external_call(_fn, _cbuffer); +} + +/// @func d3d11_cbuffer_destroy(_cbuffer) +/// +/// @desc Destroys a constant buffer. +/// +/// @param {Real} _cbuffer The ID of the constant buffer to destroy. +function d3d11_cbuffer_destroy(_cbuffer) +{ + gml_pragma("forceinline"); + static _fn = external_define( + GMD3D11_PATH, "d3d11_cbuffer_destroy", dll_cdecl, ty_real, + 1, ty_real); + return external_call(_fn, _cbuffer); +} diff --git a/scripts/__d3d11_cbuffer/__d3d11_cbuffer.yy b/scripts/__d3d11_cbuffer/__d3d11_cbuffer.yy new file mode 100644 index 000000000..740e301a7 --- /dev/null +++ b/scripts/__d3d11_cbuffer/__d3d11_cbuffer.yy @@ -0,0 +1,11 @@ +{ + "resourceType": "GMScript", + "resourceVersion": "1.0", + "name": "__d3d11_cbuffer", + "isCompatibility": false, + "isDnD": false, + "parent": { + "name": "GMD3D11", + "path": "folders/_extensions/GMD3D11.yy", + }, +} \ No newline at end of file diff --git a/scripts/__d3d11_shader/__d3d11_shader.gml b/scripts/__d3d11_shader/__d3d11_shader.gml new file mode 100644 index 000000000..542fdcf08 --- /dev/null +++ b/scripts/__d3d11_shader/__d3d11_shader.gml @@ -0,0 +1,104 @@ +/// @macro {Real} Maximum number of slots for shader resources. +#macro D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT 128 + +/// @func d3d11_shader_compile_ps(_file, _entryPoint, _profile) +/// +/// @desc Compiles a pixel shader from file. +/// +/// @param {String} _file The path to file to compile. +/// @param {String} _entryPoint The name of the entry point function, e.g. "main". +/// @param {String} _profile The pixel shader profile, e.g. "ps_4_0". +/// +/// @return {Real} The ID of the pixel shader or -1 on fail. +/// +/// @see d3d11_get_error_string +function d3d11_shader_compile_ps(_file, _entryPoint, _profile) +{ + gml_pragma("forceinline"); + static _fn = external_define( + GMD3D11_PATH, "d3d11_shader_compile_ps", dll_cdecl, ty_real, + 3, ty_string, ty_string, ty_string); + return external_call(_fn, _file, _entryPoint, _profile); +} + +/// @func d3d11_shader_compile_vs(_file, _entryPoint, _profile) +/// +/// @desc Compiles a vertex shader from file. +/// +/// @param {String} _file The path to file to compile. +/// @param {String} _entryPoint The name of the entry point function, e.g. "main". +/// @param {String} _profile The vertex shader profile, e.g. "vs_4_0". +/// +/// @return {Real} The ID of the vertex shader or -1 on fail. +/// +/// @see d3d11_get_error_string +function d3d11_shader_compile_vs(_file, _entryPoint, _profile) +{ + gml_pragma("forceinline"); + static _fn = external_define( + GMD3D11_PATH, "d3d11_shader_compile_vs", dll_cdecl, ty_real, + 3, ty_string, ty_string, ty_string); + return external_call(_fn, _file, _entryPoint, _profile); +} + +/// @func d3d11_shader_override_ps(_ps) +/// +/// @desc Hooks into `ID3D11DeviceContext::Draw` and replaces the current pixel +/// shader with a custom one. +/// +/// @param {Real} _ps The ID of the shader or -1 to disable the override. +function d3d11_shader_override_ps(_ps) +{ + gml_pragma("forceinline"); + static _fn = external_define( + GMD3D11_PATH, "d3d11_shader_override_ps", dll_cdecl, ty_real, + 1, ty_real); + return external_call(_fn, _ps); +} + +/// @func d3d11_shader_override_vs(_vs) +/// +/// @desc Hooks into `ID3D11DeviceContext::Draw` and replaces the current vertex +/// shader with a custom one. +/// +/// @param {Real} _vs The ID of the shader or -1 to disable the override. The +/// vertex format expected by the shader must be compatible with the overriden +/// shader! +function d3d11_shader_override_vs(_vs) +{ + gml_pragma("forceinline"); + static _fn = external_define( + GMD3D11_PATH, "d3d11_shader_override_vs", dll_cdecl, ty_real, + 1, ty_real); + return external_call(_fn, _vs); +} + +/// @func d3d11_shader_exists(_shader) +/// +/// @desc Checks whether a shader exists. +/// +/// @param {Real} _ps The ID of the shader. +/// +/// @return {Bool} Returns true if the shader exists. +function d3d11_shader_exists(_shader) +{ + gml_pragma("forceinline"); + static _fn = external_define( + GMD3D11_PATH, "d3d11_shader_exists", dll_cdecl, ty_real, + 1, ty_real); + return external_call(_fn, _shader); +} + +/// @func d3d11_shader_destroy(_shader) +/// +/// @desc Destroys a shader. +/// +/// @param {Real} _shader The ID of the shader to destroy. +function d3d11_shader_destroy(_shader) +{ + gml_pragma("forceinline"); + static _fn = external_define( + GMD3D11_PATH, "d3d11_shader_destroy", dll_cdecl, ty_real, + 1, ty_real); + return external_call(_fn, _shader); +} diff --git a/scripts/__d3d11_shader/__d3d11_shader.yy b/scripts/__d3d11_shader/__d3d11_shader.yy new file mode 100644 index 000000000..ee5c02538 --- /dev/null +++ b/scripts/__d3d11_shader/__d3d11_shader.yy @@ -0,0 +1,11 @@ +{ + "resourceType": "GMScript", + "resourceVersion": "1.0", + "name": "__d3d11_shader", + "isCompatibility": false, + "isDnD": false, + "parent": { + "name": "GMD3D11", + "path": "folders/_extensions/GMD3D11.yy", + }, +} \ No newline at end of file diff --git a/scripts/__node_3d/__node_3d.gml b/scripts/__node_3d/__node_3d.gml index 51e1fea9a..91545845d 100644 --- a/scripts/__node_3d/__node_3d.gml +++ b/scripts/__node_3d/__node_3d.gml @@ -46,7 +46,7 @@ function Node_3D(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constr gpu_set_ztestenable(true); gpu_set_cullmode(cull_noculling); - D3D_GLOBAL_PREVIEW.applyCamera(); + D3D_GLOBAL_PREVIEW.camera.applyCamera(); D3D_GLOBAL_PREVIEW.apply(); for( var i = 0, n = array_length(_prev_obj); i < n; i++ ) { @@ -66,7 +66,7 @@ function Node_3D(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constr } surface_reset_target(); - D3D_GLOBAL_PREVIEW.resetCamera(); + D3D_GLOBAL_PREVIEW.camera.resetCamera(); } #endregion static postUpdate = function() { refreshPreview(); } diff --git a/scripts/__panel_linear_setting/__panel_linear_setting.gml b/scripts/__panel_linear_setting/__panel_linear_setting.gml index ddffe6951..334bd5d5a 100644 --- a/scripts/__panel_linear_setting/__panel_linear_setting.gml +++ b/scripts/__panel_linear_setting/__panel_linear_setting.gml @@ -23,6 +23,23 @@ function Panel_Linear_Setting() : PanelContent() constructor { var _prop = properties[i]; var _widg = _prop[0]; + + if(is_string(_widg)) { + var _text = _prop[0]; + var _spr = _prop[1]; + var _ind = _prop[2]; + var _colr = _prop[3]; + + draw_sprite_stretched_ext(THEME.group_label, 0, ui(4), yy - th / 2 + ui(2), w - ui(8), th - ui(4), _colr, 1); + draw_sprite_ui(_spr, _ind, ui(4) + th / 2, yy); + + draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text); + draw_text_add(ui(4) + th, yy, _text); + + yy += th; + continue; + } + var _text = _prop[1]; var _data = _prop[2](); diff --git a/scripts/d3d_scene/d3d_scene.gml b/scripts/d3d_scene/d3d_scene.gml index c27000b0d..5d3603a5c 100644 --- a/scripts/d3d_scene/d3d_scene.gml +++ b/scripts/d3d_scene/d3d_scene.gml @@ -37,9 +37,9 @@ function __3dScene(camera) constructor { lightAmbient = c_black; lightDir_max = 16; - lightDir_shadow_max = 2; + lightDir_shadow_max = 4; lightPnt_max = 16; - lightPnt_shadow_max = 2; + lightPnt_shadow_max = 4; cull_mode = cull_noculling; enviroment_map = noone; @@ -52,10 +52,7 @@ function __3dScene(camera) constructor { show_normal = false; - geometry_data = [ noone, noone, noone ]; - ssao_enabled = false; - ssao = noone; ssao_sample = 32; ssao_radius = 0.1; ssao_bias = 0.1; @@ -88,9 +85,6 @@ function __3dScene(camera) constructor { lightPnt_shadowBias = []; } reset(); #endregion - static applyCamera = function() { camera.applyCamera(); } - static resetCamera = function() { camera.resetCamera(); } - static _submit = function(callback, object, shader = noone) { matrix_stack_clear(); if(apply_transform) custom_transform.submitMatrix(); @@ -104,8 +98,10 @@ function __3dScene(camera) constructor { static submitShader = function(object, shader = noone) { _submit(function(object, shader) { object.submitShader (self, shader); }, object, shader) } static deferPass = function(object, w, h) { #region - geometryPass(object, w, h); - ssaoPass(); + var geometry_data = geometryPass(object, w, h); + var ssao = ssaoPass(geometry_data); + + return { geometry_data, ssao }; } #endregion static renderBackground = function(w, h) { #region @@ -132,6 +128,7 @@ function __3dScene(camera) constructor { } #endregion static geometryPass = function(object, w = 512, h = 512) { #region + var geometry_data = [ noone, noone, noone ]; geometry_data[0] = surface_verify(geometry_data[0], w, h, surface_rgba32float); geometry_data[1] = surface_verify(geometry_data[1], w, h, surface_rgba32float); geometry_data[2] = surface_verify(geometry_data[2], w, h, surface_rgba32float); @@ -144,7 +141,7 @@ function __3dScene(camera) constructor { DRAW_CLEAR camera.setMatrix(); - applyCamera(); + camera.applyCamera(); gpu_set_cullmode(cull_mode); @@ -169,10 +166,11 @@ function __3dScene(camera) constructor { surface_free(geometry_data[2]); geometry_data[2] = _normal_blurred; } + + return geometry_data; } #endregion - static ssaoPass = function() { #region - surface_free_safe(ssao); + static ssaoPass = function(geometry_data) { #region if(!ssao_enabled) return; var _sw = surface_get_width(geometry_data[0]); @@ -201,17 +199,17 @@ function __3dScene(camera) constructor { surface_free(_ssao_surf); - ssao = _ssao_blur; + return _ssao_blur; } #endregion - static apply = function() { #region + static apply = function(deferData = noone) { #region shader_set(sh_d3d_default); #region ---- background ---- shader_set_f("light_ambient", colToVec4(lightAmbient)); shader_set_i("env_use_mapping", is_surface(enviroment_map) ); shader_set_surface("env_map", enviroment_map, false, true ); shader_set_dim("env_map_dimension", enviroment_map ); - shader_set_surface("ao_map", ssao ); + if(deferData != noone) shader_set_surface("ao_map", deferData.ssao ); #endregion shader_set_i("light_dir_count", lightDir_count); #region @@ -220,7 +218,7 @@ function __3dScene(camera) constructor { shader_set_f("light_dir_color", lightDir_color); shader_set_f("light_dir_intensity", lightDir_intensity); shader_set_i("light_dir_shadow_active", lightDir_shadow); - for( var i = 0, n = array_length(lightDir_shadowMap); i < n; i++ ) + for( var i = 0, n = array_length(lightDir_shadowMap); i < n; i++ ) shader_set_surface($"light_dir_shadowmap_{i}", lightDir_shadowMap[i], true); shader_set_f("light_dir_view", lightDir_viewMat); shader_set_f("light_dir_proj", lightDir_projMat); @@ -234,16 +232,16 @@ function __3dScene(camera) constructor { shader_set_f("light_pnt_intensity", lightPnt_intensity); shader_set_f("light_pnt_radius", lightPnt_radius); shader_set_i("light_pnt_shadow_active", lightPnt_shadow); - for( var i = 0, n = array_length(lightPnt_shadowMap); i < n; i++ ) + for( var i = 0, n = array_length(lightPnt_shadowMap); i < n; i++ ) shader_set_surface($"light_pnt_shadowmap_{i}", lightPnt_shadowMap[i], true, true); shader_set_f("light_pnt_view", lightPnt_viewMat); shader_set_f("light_pnt_proj", lightPnt_projMat); shader_set_f("light_pnt_shadow_bias", lightPnt_shadowBias); } #endregion - if(defer_normal && array_length(geometry_data) > 2) { + if(defer_normal && deferData != noone && array_length(deferData.geometry_data) > 2) { shader_set_i("mat_defer_normal", 1); - shader_set_surface("mat_normal_map", geometry_data[2]); + shader_set_surface("mat_normal_map", deferData.geometry_data[2]); } else shader_set_i("mat_defer_normal", 0); @@ -255,6 +253,8 @@ function __3dScene(camera) constructor { shader_set_f("viewProjMat", camera.getCombinedMatrix() ); #endregion + + //print($"Submitting scene with {lightDir_count} dir, {lightPnt_count} pnt lights."); shader_reset(); } #endregion diff --git a/scripts/globals/globals.gml b/scripts/globals/globals.gml index ae3fa9f56..e014e079c 100644 --- a/scripts/globals/globals.gml +++ b/scripts/globals/globals.gml @@ -101,10 +101,10 @@ globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER; - VERSION = 11510; + VERSION = 11520; SAVE_VERSION = 11500; - VERSION_STRING = "1.15.1.0"; - BUILD_NUMBER = 11510; + VERSION_STRING = "1.15.2.0"; + BUILD_NUMBER = 11520; globalvar APPEND_MAP; APPEND_MAP = ds_map_create(); diff --git a/scripts/node_3d_camera/node_3d_camera.gml b/scripts/node_3d_camera/node_3d_camera.gml index ec0aa2806..41eea2dfe 100644 --- a/scripts/node_3d_camera/node_3d_camera.gml +++ b/scripts/node_3d_camera/node_3d_camera.gml @@ -126,9 +126,9 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group) } } #endregion - static onValueUpdate = function(index) { + static onValueUpdate = function(index) { #region if(index == in_d3d + 9) PANEL_PREVIEW.tool_current = noone; - } + } #endregion static step = function() { #region var _proj = inputs[| in_d3d + 3].getValue(); @@ -261,11 +261,10 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group) scene.ssao_bias = _aoBi; scene.ssao_strength = _aoSr; scene.defer_normal_radius = _nrmSmt; - scene.draw_background = _dbg; var _bgSurf = _dbg? scene.renderBackground(_dim[0], _dim[1]) : noone; - scene.deferPass(_scne, _dim[0], _dim[1]); + var _defer = scene.deferPass(_scne, _dim[0], _dim[1]); var _render = outputs[| 0].getValue(); var _normal = outputs[| 1].getValue(); @@ -289,7 +288,7 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group) scene.reset(); scene.submitShader(_scne); - scene.apply(); + scene.apply(_defer); scene.submit(_scne); surface_reset_target(); @@ -308,7 +307,7 @@ function Node_3D_Camera(_x, _y, _group = noone) : Node_3D_Object(_x, _y, _group) draw_surface(_render, 0, 0); BLEND_MULTIPLY - draw_surface_safe(scene.ssao); + draw_surface_safe(_defer.ssao); BLEND_NORMAL surface_reset_target(); surface_free(_render); diff --git a/scripts/panel_preview/panel_preview.gml b/scripts/panel_preview/panel_preview.gml index eb80951ad..bdff9c102 100644 --- a/scripts/panel_preview/panel_preview.gml +++ b/scripts/panel_preview/panel_preview.gml @@ -756,6 +756,8 @@ function Panel_Preview() : PanelContent() constructor { function draw3D() { #region var _prev_node = getNodePreview(); if(_prev_node == noone) return; + if(!_prev_node.is_3D) return; + _prev_node.previewing = 1; d3_scene_preview = struct_has(_prev_node, "scene")? _prev_node.scene : d3_scene; @@ -802,12 +804,12 @@ function Panel_Preview() : PanelContent() constructor { #region background surface_free_safe(d3_surface_bg); - if(_prev_node.is_3D && d3_scene_preview != d3_scene) + if(d3_scene_preview != d3_scene) d3_surface_bg = d3_scene_preview.renderBackground(w, h); #endregion #region shadow - if(_prev_node.is_3D && d3_scene_preview == d3_scene) { + if(d3_scene_preview == d3_scene) { d3_scene_light0.shadow_map_scale = d3_view_camera.focus_dist * 2; var _prev_obj = _prev_node.getPreviewObjects(); @@ -834,10 +836,8 @@ function Panel_Preview() : PanelContent() constructor { d3_surface_outline = surface_verify(d3_surface_outline, w, h); #region defer - if(_prev_node.is_3D) { - var _prev_obj = _prev_node.getPreviewObject(); - d3_scene_preview.deferPass(_prev_obj, w, h); - } + var _prev_obj = _prev_node.getPreviewObject(); + var _defer = d3_scene_preview.deferPass(_prev_obj, w, h); #endregion #region grid @@ -868,33 +868,31 @@ function Panel_Preview() : PanelContent() constructor { #endregion #region draw - if(d3_scene_preview == d3_scene) - d3_scene_preview.reset(); + d3_scene_preview.reset(); gpu_set_cullmode(cull_counterclockwise); - if(_prev_node.is_3D) { - var _prev_obj = _prev_node.getPreviewObjects(); + var _prev_obj = _prev_node.getPreviewObjects(); - if(d3_scene_light_enabled && d3_scene_preview == d3_scene) { - d3_scene.addLightDirectional(d3_scene_light0); - d3_scene.addLightDirectional(d3_scene_light1); + if(d3_scene_preview == d3_scene) { + if(d3_scene_light_enabled) { + d3_scene_preview.addLightDirectional(d3_scene_light0); + d3_scene_preview.addLightDirectional(d3_scene_light1); } + } - if(d3_scene_preview == d3_scene) - for( var i = 0, n = array_length(_prev_obj); i < n; i++ ) { - var _prev = _prev_obj[i]; - if(_prev == noone) continue; + for( var i = 0, n = array_length(_prev_obj); i < n; i++ ) { + var _prev = _prev_obj[i]; + if(_prev == noone) continue; - _prev.submitShader(d3_scene_preview); - } + _prev.submitShader(d3_scene_preview); + } - d3_scene_preview.apply(); + d3_scene_preview.apply(_defer); - for( var i = 0, n = array_length(_prev_obj); i < n; i++ ) { - var _prev = _prev_obj[i]; - if(_prev == noone) continue; - _prev.submitUI(d3_scene_preview); //////////////// SUBMIT //////////////// - } + for( var i = 0, n = array_length(_prev_obj); i < n; i++ ) { + var _prev = _prev_obj[i]; + if(_prev == noone) continue; + _prev.submitUI(d3_scene_preview); //////////////// SUBMIT //////////////// } gpu_set_cullmode(cull_noculling); @@ -909,7 +907,7 @@ function Panel_Preview() : PanelContent() constructor { draw_surface_safe(d3_surface); BLEND_MULTIPLY - draw_surface_safe(d3_scene_preview.ssao); + draw_surface_safe(_defer.ssao); BLEND_NORMAL //draw_clear(c_white); @@ -919,7 +917,7 @@ function Panel_Preview() : PanelContent() constructor { case 2 : draw_surface_safe(d3_surface_depth); break; } - //draw_surface_stretched_safe(d3_scene_light0.shadow_map, 64, 64, 128, 128); + draw_surface_stretched_safe(d3_scene_light0.shadow_map, 64, 64, 128, 128); #endregion #region outline @@ -931,7 +929,7 @@ function Panel_Preview() : PanelContent() constructor { surface_set_target(d3_surface_outline); draw_clear(c_black); - d3_view_camera.applyCamera(); + d3_scene_preview.camera.applyCamera(); gpu_set_ztestenable(false); for( var i = 0, n = array_length(_inspect_obj); i < n; i++ ) { @@ -948,7 +946,7 @@ function Panel_Preview() : PanelContent() constructor { } #endregion - d3_scene_preview.resetCamera(); + d3_scene_preview.camera.resetCamera(); } #endregion function drawPreviewOverlay() { #region diff --git a/scripts/panel_preview_3d_setting/panel_preview_3d_setting.gml b/scripts/panel_preview_3d_setting/panel_preview_3d_setting.gml index 06e718a66..07a25b594 100644 --- a/scripts/panel_preview_3d_setting/panel_preview_3d_setting.gml +++ b/scripts/panel_preview_3d_setting/panel_preview_3d_setting.gml @@ -5,7 +5,7 @@ function Panel_Preview_3D_Setting(panel) : Panel_Linear_Setting() constructor { preview_panel = panel; #region data - properties = [ + properties_default = [ [ new checkBox(function() { preview_panel.d3_scene_light_enabled = !preview_panel.d3_scene_light_enabled; }), __txt("Preview Light"), @@ -52,7 +52,18 @@ function Panel_Preview_3D_Setting(panel) : Panel_Linear_Setting() constructor { function() { return preview_panel.d3_scene.show_normal }, ], ] - + + var scene_camera = [ + [ "Currently using camera node settings", THEME.noti_icon_warning, 1, COLORS._main_accent ], + ]; + + properties_camera = array_append(scene_camera, properties_default); + properties = preview_panel.d3_scene_preview == preview_panel.d3_scene? properties_default : properties_camera; + setHeight(); #endregion + + function drawContent(panel) { + drawSettings(panel); + } } \ No newline at end of file diff --git a/scripts/shader_functions/shader_functions.gml b/scripts/shader_functions/shader_functions.gml index 199d975d1..7cddc1a75 100644 --- a/scripts/shader_functions/shader_functions.gml +++ b/scripts/shader_functions/shader_functions.gml @@ -56,11 +56,28 @@ function shader_set_surface(sampler, surface, linear = false, _repeat = false) { if(!is_surface(surface)) return; var t = shader_get_sampler_index(shader, sampler); + texture_set_stage(t, surface_get_texture(surface)); gpu_set_tex_filter_ext(t, linear); gpu_set_tex_repeat_ext(t, _repeat); } +//function shader_set_surface_ext(sampler, surface, linear = false, _repeat = false) { +// var shader = shader_current(); +// if(!is_surface(surface)) return; + +// if (!GMD3D11_IS_SUPPORTED) { +// shader_set_surface(sampler, surface, linear, _repeat); +// return; +// } + +// var t = shader_get_sampler_index(shader, sampler); +// gpu_set_tex_filter_ext(t, linear); +// gpu_set_tex_repeat_ext(t, _repeat); + +// d3d11_texture_set_stage_ps(t, surface_get_texture(surface)); +//} + function shader_set_surface_dimension(uniform, surface) { var shader = shader_current(); if(!is_surface(surface)) return; diff --git a/shaders/sh_d3d_default/sh_d3d_default.fsh b/shaders/sh_d3d_default/sh_d3d_default.fsh index fb4713262..4b52d058d 100644 --- a/shaders/sh_d3d_default/sh_d3d_default.fsh +++ b/shaders/sh_d3d_default/sh_d3d_default.fsh @@ -27,6 +27,8 @@ varying float v_cameraDistance; 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; #define LIGHT_PNT_LIMIT 16 uniform int light_pnt_count; @@ -41,6 +43,8 @@ varying float v_cameraDistance; 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 ---- @@ -93,6 +97,8 @@ varying float v_cameraDistance; float sampleDirShadowMap(int index, vec2 position) { if(index == 0) return texture2D(light_dir_shadowmap_0, position).r; if(index == 1) return texture2D(light_dir_shadowmap_1, position).r; + //if(index == 2) return texture2D(light_dir_shadowmap_2, position).r; + //if(index == 3) return texture2D(light_dir_shadowmap_3, position).r; return 0.; } @@ -105,6 +111,8 @@ varying float v_cameraDistance; if(index == 0) return texture2D(light_pnt_shadowmap_0, position)[side]; if(index == 1) return texture2D(light_pnt_shadowmap_1, position)[side]; + //if(index == 2) return texture2D(light_pnt_shadowmap_2, position)[side]; + //if(index == 3) return texture2D(light_pnt_shadowmap_3, position)[side]; return 0.; } #endregion