diff --git a/Content/Documentation/ScriptingAPI-Documentation.md b/Content/Documentation/ScriptingAPI-Documentation.md index 41f4a45c4..a54d67506 100644 --- a/Content/Documentation/ScriptingAPI-Documentation.md +++ b/Content/Documentation/ScriptingAPI-Documentation.md @@ -1190,6 +1190,7 @@ It can hold Sprites and SpriteFonts and can sort them by layers, update and rend - SetLayerOrder(string name, int order) - SetSpriteOrder(Sprite sprite, int order) - SetFontOrder(SpriteFont font, int order) +- CopyFrom(RenderPath other) -- copies everything from other renderpath into this #### RenderPath3D This is the default scene render path. diff --git a/WickedEngine/wiAudio_BindLua.cpp b/WickedEngine/wiAudio_BindLua.cpp index d93399f20..f7aa7177f 100644 --- a/WickedEngine/wiAudio_BindLua.cpp +++ b/WickedEngine/wiAudio_BindLua.cpp @@ -240,43 +240,45 @@ namespace wi::lua initialized = true; Luna::Register(wi::lua::GetLuaState()); - wi::lua::RunText("audio = Audio()"); + wi::lua::RunText(R"( +audio = Audio() - wi::lua::RunText("SUBMIX_TYPE_SOUNDEFFECT = 0"); - wi::lua::RunText("SUBMIX_TYPE_MUSIC = 1"); - wi::lua::RunText("SUBMIX_TYPE_USER0 = 2"); - wi::lua::RunText("SUBMIX_TYPE_USER1 = 3"); +SUBMIX_TYPE_SOUNDEFFECT = 0 +SUBMIX_TYPE_MUSIC = 1 +SUBMIX_TYPE_USER0 = 2 +SUBMIX_TYPE_USER1 = 3 - wi::lua::RunText("REVERB_PRESET_DEFAULT = 0"); - wi::lua::RunText("REVERB_PRESET_GENERIC = 1"); - wi::lua::RunText("REVERB_PRESET_FOREST = 2"); - wi::lua::RunText("REVERB_PRESET_PADDEDCELL = 3"); - wi::lua::RunText("REVERB_PRESET_ROOM = 4"); - wi::lua::RunText("REVERB_PRESET_BATHROOM = 5"); - wi::lua::RunText("REVERB_PRESET_LIVINGROOM = 6"); - wi::lua::RunText("REVERB_PRESET_STONEROOM = 7"); - wi::lua::RunText("REVERB_PRESET_AUDITORIUM = 8"); - wi::lua::RunText("REVERB_PRESET_CONCERTHALL = 9"); - wi::lua::RunText("REVERB_PRESET_CAVE = 10"); - wi::lua::RunText("REVERB_PRESET_ARENA = 11"); - wi::lua::RunText("REVERB_PRESET_HANGAR = 12"); - wi::lua::RunText("REVERB_PRESET_CARPETEDHALLWAY = 13"); - wi::lua::RunText("REVERB_PRESET_HALLWAY = 14"); - wi::lua::RunText("REVERB_PRESET_STONECORRIDOR = 15"); - wi::lua::RunText("REVERB_PRESET_ALLEY = 16"); - wi::lua::RunText("REVERB_PRESET_CITY = 17"); - wi::lua::RunText("REVERB_PRESET_MOUNTAINS = 18"); - wi::lua::RunText("REVERB_PRESET_QUARRY = 19"); - wi::lua::RunText("REVERB_PRESET_PLAIN = 20"); - wi::lua::RunText("REVERB_PRESET_PARKINGLOT = 21"); - wi::lua::RunText("REVERB_PRESET_SEWERPIPE = 22"); - wi::lua::RunText("REVERB_PRESET_UNDERWATER = 23"); - wi::lua::RunText("REVERB_PRESET_SMALLROOM = 24"); - wi::lua::RunText("REVERB_PRESET_MEDIUMROOM = 25"); - wi::lua::RunText("REVERB_PRESET_LARGEROOM = 26"); - wi::lua::RunText("REVERB_PRESET_MEDIUMHALL = 27"); - wi::lua::RunText("REVERB_PRESET_LARGEHALL = 28"); - wi::lua::RunText("REVERB_PRESET_PLATE = 29"); +REVERB_PRESET_DEFAULT = 0 +REVERB_PRESET_GENERIC = 1 +REVERB_PRESET_FOREST = 2 +REVERB_PRESET_PADDEDCELL = 3 +REVERB_PRESET_ROOM = 4 +REVERB_PRESET_BATHROOM = 5 +REVERB_PRESET_LIVINGROOM = 6 +REVERB_PRESET_STONEROOM = 7 +REVERB_PRESET_AUDITORIUM = 8 +REVERB_PRESET_CONCERTHALL = 9 +REVERB_PRESET_CAVE = 10 +REVERB_PRESET_ARENA = 11 +REVERB_PRESET_HANGAR = 12 +REVERB_PRESET_CARPETEDHALLWAY = 13 +REVERB_PRESET_HALLWAY = 14 +REVERB_PRESET_STONECORRIDOR = 15 +REVERB_PRESET_ALLEY = 16 +REVERB_PRESET_CITY = 17 +REVERB_PRESET_MOUNTAINS = 18 +REVERB_PRESET_QUARRY = 19 +REVERB_PRESET_PLAIN = 20 +REVERB_PRESET_PARKINGLOT = 21 +REVERB_PRESET_SEWERPIPE = 22 +REVERB_PRESET_UNDERWATER = 23 +REVERB_PRESET_SMALLROOM = 24 +REVERB_PRESET_MEDIUMROOM = 25 +REVERB_PRESET_LARGEROOM = 26 +REVERB_PRESET_MEDIUMHALL = 27 +REVERB_PRESET_LARGEHALL = 28 +REVERB_PRESET_PLATE = 29 +)"); Sound_BindLua::Bind(); SoundInstance_BindLua::Bind(); diff --git a/WickedEngine/wiImageParams_BindLua.cpp b/WickedEngine/wiImageParams_BindLua.cpp index c2306561c..6a407b604 100644 --- a/WickedEngine/wiImageParams_BindLua.cpp +++ b/WickedEngine/wiImageParams_BindLua.cpp @@ -470,32 +470,35 @@ namespace wi::lua initialized = true; Luna::Register(wi::lua::GetLuaState()); - wi::lua::RunText("STENCILMODE_DISABLED = 0"); - wi::lua::RunText("STENCILMODE_EQUAL = 1"); - wi::lua::RunText("STENCILMODE_LESS = 2"); - wi::lua::RunText("STENCILMODE_LESSEQUAL = 3"); - wi::lua::RunText("STENCILMODE_GREATER = 4"); - wi::lua::RunText("STENCILMODE_GREATEREQUAL = 5"); - wi::lua::RunText("STENCILMODE_NOT = 6"); - wi::lua::RunText("STENCILMODE_ALWAYS = 7"); + wi::lua::RunText(R"( +STENCILMODE_DISABLED = 0 +STENCILMODE_EQUAL = 1 +STENCILMODE_LESS = 2 +STENCILMODE_LESSEQUAL = 3 +STENCILMODE_GREATER = 4 +STENCILMODE_GREATEREQUAL = 5 +STENCILMODE_NOT = 6 +STENCILMODE_ALWAYS = 7 - wi::lua::RunText("STENCILREFMODE_ENGINE = 0"); - wi::lua::RunText("STENCILREFMODE_USER = 1"); - wi::lua::RunText("STENCILREFMODE_ALL = 2"); +STENCILREFMODE_ENGINE = 0 +STENCILREFMODE_USER = 1 +STENCILREFMODE_ALL = 2 - wi::lua::RunText("SAMPLEMODE_CLAMP = 0"); - wi::lua::RunText("SAMPLEMODE_WRAP = 1"); - wi::lua::RunText("SAMPLEMODE_MIRROR = 2"); +SAMPLEMODE_CLAMP = 0 +SAMPLEMODE_WRAP = 1 +SAMPLEMODE_MIRROR = 2 - wi::lua::RunText("QUALITY_NEAREST = 0"); - wi::lua::RunText("QUALITY_LINEAR = 1"); - wi::lua::RunText("QUALITY_ANISOTROPIC = 2"); - wi::lua::RunText("QUALITY_BICUBIC = 3"); +QUALITY_NEAREST = 0 +QUALITY_LINEAR = 1 +QUALITY_ANISOTROPIC = 2 +QUALITY_BICUBIC = 3 + +BLENDMODE_OPAQUE = 0 +BLENDMODE_ALPHA = 1 +BLENDMODE_PREMULTIPLIED = 2 +BLENDMODE_ADDITIVE = 3 +)"); - wi::lua::RunText("BLENDMODE_OPAQUE = 0"); - wi::lua::RunText("BLENDMODE_ALPHA = 1"); - wi::lua::RunText("BLENDMODE_PREMULTIPLIED = 2"); - wi::lua::RunText("BLENDMODE_ADDITIVE = 3"); } } diff --git a/WickedEngine/wiInput_BindLua.cpp b/WickedEngine/wiInput_BindLua.cpp index 132a16efa..8e21bf1ef 100644 --- a/WickedEngine/wiInput_BindLua.cpp +++ b/WickedEngine/wiInput_BindLua.cpp @@ -188,70 +188,72 @@ namespace wi::lua { initialized = true; Luna::Register(wi::lua::GetLuaState()); - wi::lua::RunText("input = Input()"); - wi::lua::RunText("MOUSE_BUTTON_LEFT = 1"); - wi::lua::RunText("MOUSE_BUTTON_RIGHT = 2"); - wi::lua::RunText("MOUSE_BUTTON_MIDDLE = 3"); + wi::lua::RunText(R"( +input = Input() - wi::lua::RunText("KEYBOARD_BUTTON_UP = 4"); - wi::lua::RunText("KEYBOARD_BUTTON_DOWN = 5"); - wi::lua::RunText("KEYBOARD_BUTTON_LEFT = 6"); - wi::lua::RunText("KEYBOARD_BUTTON_RIGHT = 7"); - wi::lua::RunText("KEYBOARD_BUTTON_SPACE = 8"); - wi::lua::RunText("KEYBOARD_BUTTON_RSHIFT = 9"); - wi::lua::RunText("KEYBOARD_BUTTON_LSHIFT = 10"); - wi::lua::RunText("KEYBOARD_BUTTON_F1 = 11"); - wi::lua::RunText("KEYBOARD_BUTTON_F2 = 12"); - wi::lua::RunText("KEYBOARD_BUTTON_F3 = 13"); - wi::lua::RunText("KEYBOARD_BUTTON_F4 = 14"); - wi::lua::RunText("KEYBOARD_BUTTON_F5 = 15"); - wi::lua::RunText("KEYBOARD_BUTTON_F6 = 16"); - wi::lua::RunText("KEYBOARD_BUTTON_F7 = 17"); - wi::lua::RunText("KEYBOARD_BUTTON_F8 = 18"); - wi::lua::RunText("KEYBOARD_BUTTON_F9 = 19"); - wi::lua::RunText("KEYBOARD_BUTTON_F10 = 20"); - wi::lua::RunText("KEYBOARD_BUTTON_F11 = 21"); - wi::lua::RunText("KEYBOARD_BUTTON_F12 = 22"); - wi::lua::RunText("KEYBOARD_BUTTON_ENTER = 23"); - wi::lua::RunText("KEYBOARD_BUTTON_ESCAPE = 24"); - wi::lua::RunText("KEYBOARD_BUTTON_HOME = 25"); - wi::lua::RunText("KEYBOARD_BUTTON_RCONTROL = 26"); - wi::lua::RunText("KEYBOARD_BUTTON_LCONTROL = 27"); - wi::lua::RunText("KEYBOARD_BUTTON_DELETE = 28"); - wi::lua::RunText("KEYBOARD_BUTTON_BACK = 29"); - wi::lua::RunText("KEYBOARD_BUTTON_PAGEDOWN = 30"); - wi::lua::RunText("KEYBOARD_BUTTON_PAGEUP = 31"); +MOUSE_BUTTON_LEFT = 1 +MOUSE_BUTTON_RIGHT = 2 +MOUSE_BUTTON_MIDDLE = 3 - wi::lua::RunText("GAMEPAD_BUTTON_UP = 257"); - wi::lua::RunText("GAMEPAD_BUTTON_LEFT = 258"); - wi::lua::RunText("GAMEPAD_BUTTON_DOWN = 259"); - wi::lua::RunText("GAMEPAD_BUTTON_RIGHT = 260"); - wi::lua::RunText("GAMEPAD_BUTTON_1 = 261"); - wi::lua::RunText("GAMEPAD_BUTTON_2 = 262"); - wi::lua::RunText("GAMEPAD_BUTTON_3 = 263"); - wi::lua::RunText("GAMEPAD_BUTTON_4 = 264"); - wi::lua::RunText("GAMEPAD_BUTTON_5 = 265"); - wi::lua::RunText("GAMEPAD_BUTTON_6 = 266"); - wi::lua::RunText("GAMEPAD_BUTTON_7 = 267"); - wi::lua::RunText("GAMEPAD_BUTTON_8 = 268"); - wi::lua::RunText("GAMEPAD_BUTTON_9 = 269"); - wi::lua::RunText("GAMEPAD_BUTTON_10 = 270"); - wi::lua::RunText("GAMEPAD_BUTTON_11 = 271"); - wi::lua::RunText("GAMEPAD_BUTTON_12 = 272"); - wi::lua::RunText("GAMEPAD_BUTTON_13 = 273"); - wi::lua::RunText("GAMEPAD_BUTTON_14 = 274"); +KEYBOARD_BUTTON_UP = 4 +KEYBOARD_BUTTON_DOWN = 5 +KEYBOARD_BUTTON_LEFT = 6 +KEYBOARD_BUTTON_RIGHT = 7 +KEYBOARD_BUTTON_SPACE = 8 +KEYBOARD_BUTTON_RSHIFT = 9 +KEYBOARD_BUTTON_LSHIFT = 10 +KEYBOARD_BUTTON_F1 = 11 +KEYBOARD_BUTTON_F2 = 12 +KEYBOARD_BUTTON_F3 = 13 +KEYBOARD_BUTTON_F4 = 14 +KEYBOARD_BUTTON_F5 = 15 +KEYBOARD_BUTTON_F6 = 16 +KEYBOARD_BUTTON_F7 = 17 +KEYBOARD_BUTTON_F8 = 18 +KEYBOARD_BUTTON_F9 = 19 +KEYBOARD_BUTTON_F10 = 20 +KEYBOARD_BUTTON_F11 = 21 +KEYBOARD_BUTTON_F12 = 22 +KEYBOARD_BUTTON_ENTER = 23 +KEYBOARD_BUTTON_ESCAPE = 24 +KEYBOARD_BUTTON_HOME = 25 +KEYBOARD_BUTTON_RCONTROL = 26 +KEYBOARD_BUTTON_LCONTROL = 27 +KEYBOARD_BUTTON_DELETE = 28 +KEYBOARD_BUTTON_BACK = 29 +KEYBOARD_BUTTON_PAGEDOWN = 30 +KEYBOARD_BUTTON_PAGEUP = 31 - //Analog - wi::lua::RunText("GAMEPAD_ANALOG_THUMBSTICK_L = 0"); - wi::lua::RunText("GAMEPAD_ANALOG_THUMBSTICK_R = 1"); - wi::lua::RunText("GAMEPAD_ANALOG_TRIGGER_L = 2"); - wi::lua::RunText("GAMEPAD_ANALOG_TRIGGER_R = 3"); +GAMEPAD_BUTTON_UP = 257 +GAMEPAD_BUTTON_LEFT = 258 +GAMEPAD_BUTTON_DOWN = 259 +GAMEPAD_BUTTON_RIGHT = 260 +GAMEPAD_BUTTON_1 = 261 +GAMEPAD_BUTTON_2 = 262 +GAMEPAD_BUTTON_3 = 263 +GAMEPAD_BUTTON_4 = 264 +GAMEPAD_BUTTON_5 = 265 +GAMEPAD_BUTTON_6 = 266 +GAMEPAD_BUTTON_7 = 267 +GAMEPAD_BUTTON_8 = 268 +GAMEPAD_BUTTON_9 = 269 +GAMEPAD_BUTTON_10 = 270 +GAMEPAD_BUTTON_11 = 271 +GAMEPAD_BUTTON_12 = 272 +GAMEPAD_BUTTON_13 = 273 +GAMEPAD_BUTTON_14 = 274 + +GAMEPAD_ANALOG_THUMBSTICK_L = 0 +GAMEPAD_ANALOG_THUMBSTICK_R = 1 +GAMEPAD_ANALOG_TRIGGER_L = 2 +GAMEPAD_ANALOG_TRIGGER_R = 3 + +TOUCHSTATE_PRESSED = 0 +TOUCHSTATE_RELEASED = 1 +TOUCHSTATE_MOVED = 2 +)"); - //Touch - wi::lua::RunText("TOUCHSTATE_PRESSED = 0"); - wi::lua::RunText("TOUCHSTATE_RELEASED = 1"); - wi::lua::RunText("TOUCHSTATE_MOVED = 2"); } Touch_BindLua::Bind(); diff --git a/WickedEngine/wiLua.cpp b/WickedEngine/wiLua.cpp index 7109942b0..319d682d7 100644 --- a/WickedEngine/wiLua.cpp +++ b/WickedEngine/wiLua.cpp @@ -250,46 +250,6 @@ namespace wi::lua return Success(); } - void RegisterLibrary(const std::string& tableName, const luaL_Reg* functions) - { - if (luaL_newmetatable(lua_internal().m_luaState, tableName.c_str()) != 0) - { - //table is not yet present - lua_pushvalue(lua_internal().m_luaState, -1); - lua_setfield(lua_internal().m_luaState, -2, "__index"); // Object.__index = Object - AddFuncArray(functions); - } - } - bool RegisterObject(const std::string& tableName, const std::string& name, void* object) - { - RegisterLibrary(tableName, nullptr); - - // does this call need to be checked? eg. userData == nullptr? - void** userData = static_cast(lua_newuserdata(lua_internal().m_luaState, sizeof(void*))); - *(userData) = object; - - luaL_setmetatable(lua_internal().m_luaState, tableName.c_str()); - lua_setglobal(lua_internal().m_luaState, name.c_str()); - - return true; - } - void AddFunc(const std::string& name, lua_CFunction function) - { - lua_pushcfunction(lua_internal().m_luaState, function); - lua_setfield(lua_internal().m_luaState, -2, name.c_str()); - } - void AddFuncArray(const luaL_Reg* functions) - { - if (functions != nullptr) - { - luaL_setfuncs(lua_internal().m_luaState, functions, 0); - } - } - void AddInt(const std::string& name, int data) - { - lua_pushinteger(lua_internal().m_luaState, data); - lua_setfield(lua_internal().m_luaState, -2, name.c_str()); - } void SetDeltaTime(double dt) { diff --git a/WickedEngine/wiLua.h b/WickedEngine/wiLua.h index 8e5c11eb3..e250326aa 100644 --- a/WickedEngine/wiLua.h +++ b/WickedEngine/wiLua.h @@ -35,16 +35,6 @@ namespace wi::lua bool RunText(const std::string& script); //register function to use in scripts bool RegisterFunc(const std::string& name, lua_CFunction function); - //register class - void RegisterLibrary(const std::string& tableName, const luaL_Reg* functions); - //register object - bool RegisterObject(const std::string& tableName, const std::string& name, void* object); - //add function to the previously registered object - void AddFunc(const std::string& name, lua_CFunction function); - //add function array to the previously registered object - void AddFuncArray(const luaL_Reg* functions); - //add int member to registered object - void AddInt(const std::string& name, int data); //set delta time to use with lua void SetDeltaTime(double dt); diff --git a/WickedEngine/wiMath_BindLua.cpp b/WickedEngine/wiMath_BindLua.cpp index ff12af270..96fdbeb9a 100644 --- a/WickedEngine/wiMath_BindLua.cpp +++ b/WickedEngine/wiMath_BindLua.cpp @@ -458,7 +458,7 @@ namespace wi::lua { initialized = true; Luna::Register(wi::lua::GetLuaState()); - wi::lua::RunText("vector = Vector()"); + Luna::push_global(wi::lua::GetLuaState(), "vector"); } } @@ -816,7 +816,7 @@ namespace wi::lua { initialized = true; Luna::Register(wi::lua::GetLuaState()); - wi::lua::RunText("matrix = Matrix()"); + Luna::push_global(wi::lua::GetLuaState(), "matrix"); } } diff --git a/WickedEngine/wiMath_BindLua.h b/WickedEngine/wiMath_BindLua.h index 8a752be10..958018ff9 100644 --- a/WickedEngine/wiMath_BindLua.h +++ b/WickedEngine/wiMath_BindLua.h @@ -15,7 +15,7 @@ namespace wi::lua static Luna::FunctionType methods[]; static Luna::PropertyType properties[]; - Vector_BindLua(); + Vector_BindLua() = default; Vector_BindLua(const XMFLOAT3& vector); Vector_BindLua(const XMFLOAT4& vector); Vector_BindLua(const XMVECTOR& vector); @@ -81,7 +81,7 @@ namespace wi::lua static Luna::FunctionType methods[]; static Luna::PropertyType properties[]; - Matrix_BindLua(); + Matrix_BindLua() = default; Matrix_BindLua(const XMMATRIX& matrix); Matrix_BindLua(const XMFLOAT4X4& matrix); Matrix_BindLua(lua_State* L); diff --git a/WickedEngine/wiNetwork_BindLua.cpp b/WickedEngine/wiNetwork_BindLua.cpp index 27663bb52..e7a4fdff9 100644 --- a/WickedEngine/wiNetwork_BindLua.cpp +++ b/WickedEngine/wiNetwork_BindLua.cpp @@ -21,8 +21,7 @@ namespace wi::lua { initialized = true; Luna::Register(wi::lua::GetLuaState()); - - wi::lua::RunText("network = Network()"); + Luna::push_global(wi::lua::GetLuaState(), "network"); } } diff --git a/WickedEngine/wiNetwork_BindLua.h b/WickedEngine/wiNetwork_BindLua.h index 949b2f44e..d7d5a1118 100644 --- a/WickedEngine/wiNetwork_BindLua.h +++ b/WickedEngine/wiNetwork_BindLua.h @@ -12,6 +12,7 @@ namespace wi::lua static Luna::FunctionType methods[]; static Luna::PropertyType properties[]; + Network_BindLua() = default; Network_BindLua(lua_State* L) {} static void Bind(); diff --git a/WickedEngine/wiPhysics_BindLua.cpp b/WickedEngine/wiPhysics_BindLua.cpp index 09c1e9b5d..2bdca4549 100644 --- a/WickedEngine/wiPhysics_BindLua.cpp +++ b/WickedEngine/wiPhysics_BindLua.cpp @@ -357,11 +357,12 @@ namespace wi::lua { initialized = true; Luna::Register(wi::lua::GetLuaState()); + Luna::push_global(wi::lua::GetLuaState(), "physics"); - wi::lua::RunText("physics = Physics()"); - - wi::lua::RunText("ACTIVATION_STATE_ACTIVE = 0"); - wi::lua::RunText("ACTIVATION_STATE_INACTIVE = 1"); + wi::lua::RunText(R"( +ACTIVATION_STATE_ACTIVE = 0 +ACTIVATION_STATE_INACTIVE = 1 +)"); } } } diff --git a/WickedEngine/wiPhysics_BindLua.h b/WickedEngine/wiPhysics_BindLua.h index c87d7a27f..a9c16f127 100644 --- a/WickedEngine/wiPhysics_BindLua.h +++ b/WickedEngine/wiPhysics_BindLua.h @@ -12,6 +12,7 @@ namespace wi::lua static Luna::FunctionType methods[]; static Luna::PropertyType properties[]; + Physics_BindLua() = default; Physics_BindLua(lua_State* L) {} int SetEnabled(lua_State* L); diff --git a/WickedEngine/wiRenderPath2D_BindLua.cpp b/WickedEngine/wiRenderPath2D_BindLua.cpp index b3cb9c1a7..8096090fe 100644 --- a/WickedEngine/wiRenderPath2D_BindLua.cpp +++ b/WickedEngine/wiRenderPath2D_BindLua.cpp @@ -1,4 +1,5 @@ #include "wiRenderPath2D_BindLua.h" +#include "wiRenderPath3D_BindLua.h" #include "wiSprite_BindLua.h" #include "wiSpriteFont_BindLua.h" @@ -25,6 +26,8 @@ namespace wi::lua lunamethod(RenderPath2D_BindLua, SetFontOrder), lunamethod(RenderPath_BindLua, GetLayerMask), lunamethod(RenderPath_BindLua, SetLayerMask), + + lunamethod(RenderPath2D_BindLua, CopyFrom), { NULL, NULL } }; Luna::PropertyType RenderPath2D_BindLua::properties[] = { @@ -415,6 +418,41 @@ namespace wi::lua return 0; } + int RenderPath2D_BindLua::CopyFrom(lua_State* L) + { + if (component == nullptr) + { + wi::lua::SError(L, "CopyFrom(RenderPath other) component is null!"); + return 0; + } + if (wi::lua::SGetArgCount(L) > 0) + { + RenderPath3D_BindLua* other3D = Luna::lightcheck(L, 1); + if (other3D != nullptr) + { + *component = *other3D->component; + return 0; + } + RenderPath2D_BindLua* other2D = Luna::lightcheck(L, 1); + if (other2D != nullptr) + { + *component = *other2D->component; + return 0; + } + RenderPath_BindLua* other = Luna::lightcheck(L, 1); + if (other != nullptr) + { + *component = *other->component; + return 0; + } + + wi::lua::SError(L, "CopyFrom(RenderPath other) parameter is not a RenderPath3D!"); + } + else + wi::lua::SError(L, "CopyFrom(RenderPath other) not enough arguments!"); + return 0; + } + void RenderPath2D_BindLua::Bind() { static bool initialized = false; diff --git a/WickedEngine/wiRenderPath2D_BindLua.h b/WickedEngine/wiRenderPath2D_BindLua.h index 306f1e2a2..f24c7d284 100644 --- a/WickedEngine/wiRenderPath2D_BindLua.h +++ b/WickedEngine/wiRenderPath2D_BindLua.h @@ -43,6 +43,8 @@ namespace wi::lua int SetSpriteOrder(lua_State* L); int SetFontOrder(lua_State* L); + int CopyFrom(lua_State* L); + static void Bind(); }; diff --git a/WickedEngine/wiRenderPath3D.cpp b/WickedEngine/wiRenderPath3D.cpp index f95c79906..7f1c314b2 100644 --- a/WickedEngine/wiRenderPath3D.cpp +++ b/WickedEngine/wiRenderPath3D.cpp @@ -1010,7 +1010,7 @@ namespace wi }; device->RenderPassBegin(rp, arraysize(rp), cmd); - wi::renderer::DrawScene(visibility_reflection, RENDERPASS_PREPASS, cmd, wi::renderer::DRAWSCENE_OPAQUE | wi::renderer::DRAWSCENE_IMPOSTOR); + wi::renderer::DrawScene(visibility_reflection, RENDERPASS_PREPASS, cmd, wi::renderer::DRAWSCENE_OPAQUE | wi::renderer::DRAWSCENE_IMPOSTOR | wi::renderer::DRAWSCENE_SKIP_PLANAR_REFLECTION_OBJECTS); device->RenderPassEnd(cmd); @@ -1085,8 +1085,8 @@ namespace wi }; device->RenderPassBegin(rp, arraysize(rp), cmd); - wi::renderer::DrawScene(visibility_reflection, RENDERPASS_MAIN, cmd, wi::renderer::DRAWSCENE_OPAQUE | wi::renderer::DRAWSCENE_IMPOSTOR); - wi::renderer::DrawScene(visibility_reflection, RENDERPASS_MAIN, cmd, wi::renderer::DRAWSCENE_TRANSPARENT); // separate renderscene, to be drawn after opaque and transparent sort order + wi::renderer::DrawScene(visibility_reflection, RENDERPASS_MAIN, cmd, wi::renderer::DRAWSCENE_OPAQUE | wi::renderer::DRAWSCENE_IMPOSTOR | wi::renderer::DRAWSCENE_SKIP_PLANAR_REFLECTION_OBJECTS); + wi::renderer::DrawScene(visibility_reflection, RENDERPASS_MAIN, cmd, wi::renderer::DRAWSCENE_TRANSPARENT | wi::renderer::DRAWSCENE_SKIP_PLANAR_REFLECTION_OBJECTS); // separate renderscene, to be drawn after opaque and transparent sort order wi::renderer::DrawSky(*scene, cmd); if (scene->weather.IsRealisticSky() && scene->weather.IsRealisticSkyAerialPerspective()) @@ -1101,9 +1101,15 @@ namespace wi } // Blend the volumetric clouds on top: + // For planar reflections, we don't use upsample, because there is no linear depth here if (scene->weather.IsVolumetricClouds()) { - wi::renderer::Postprocess_VolumetricClouds_Upsample(volumetriccloudResources_reflection, cmd); + device->EventBegin("Volumetric Clouds Reflection Blend", cmd); + wi::image::Params fx; + fx.enableFullScreen(); + fx.blendFlag = BLENDMODE_PREMULTIPLIED; + wi::image::Draw(&volumetriccloudResources_reflection.texture_reproject[volumetriccloudResources_reflection.frame % 2], fx, cmd); + device->EventEnd(cmd); } device->RenderPassEnd(cmd); diff --git a/WickedEngine/wiRenderPath3D_BindLua.cpp b/WickedEngine/wiRenderPath3D_BindLua.cpp index 567fd33bf..2a62b1300 100644 --- a/WickedEngine/wiRenderPath3D_BindLua.cpp +++ b/WickedEngine/wiRenderPath3D_BindLua.cpp @@ -60,6 +60,8 @@ namespace wi::lua lunamethod(RenderPath3D_BindLua, SetFSR2Enabled), lunamethod(RenderPath3D_BindLua, SetFSR2Sharpness), lunamethod(RenderPath3D_BindLua, SetFSR2Preset), + + lunamethod(RenderPath2D_BindLua, CopyFrom), { NULL, NULL } }; Luna::PropertyType RenderPath3D_BindLua::properties[] = { diff --git a/WickedEngine/wiRenderPath_BindLua.cpp b/WickedEngine/wiRenderPath_BindLua.cpp index 53dec0e96..77920ffb8 100644 --- a/WickedEngine/wiRenderPath_BindLua.cpp +++ b/WickedEngine/wiRenderPath_BindLua.cpp @@ -27,7 +27,7 @@ namespace wi::lua if (argc > 0) { int mask = wi::lua::SGetInt(L, 1); - component->setlayerMask(*reinterpret_cast(&mask)); + component->setlayerMask(uint32_t(mask)); } else wi::lua::SError(L, "SetLayerMask(uint mask) not enough arguments!"); diff --git a/WickedEngine/wiRenderPath_BindLua.h b/WickedEngine/wiRenderPath_BindLua.h index b6ed2c191..0ea53a205 100644 --- a/WickedEngine/wiRenderPath_BindLua.h +++ b/WickedEngine/wiRenderPath_BindLua.h @@ -18,8 +18,8 @@ namespace wi::lua RenderPath_BindLua(lua_State* L) {} virtual ~RenderPath_BindLua() = default; - virtual int GetLayerMask(lua_State* L); - virtual int SetLayerMask(lua_State* L); + int GetLayerMask(lua_State* L); + int SetLayerMask(lua_State* L); static void Bind(); }; diff --git a/WickedEngine/wiRenderer.cpp b/WickedEngine/wiRenderer.cpp index 265e6cfa8..af7e3a2db 100644 --- a/WickedEngine/wiRenderer.cpp +++ b/WickedEngine/wiRenderer.cpp @@ -2518,7 +2518,7 @@ void RenderMeshes( RENDERPASS renderPass, uint32_t filterMask, CommandList cmd, - bool tessellation = false, + uint32_t flags = 0, const Frustum* frusta = nullptr, uint32_t frustum_count = 1 ) @@ -2531,7 +2531,12 @@ void RenderMeshes( wi::jobsystem::Wait(object_pso_job_ctx); RenderPassInfo renderpass_info = device->GetRenderPassInfo(cmd); - tessellation = tessellation && device->CheckCapability(GraphicsDeviceCapability::TESSELLATION); + const bool tessellation = + (flags & DRAWSCENE_TESSELLATION) && + GetTessellationEnabled() && + device->CheckCapability(GraphicsDeviceCapability::TESSELLATION) + ; + const bool skip_planareflection_objects = flags & DRAWSCENE_SKIP_PLANAR_REFLECTION_OBJECTS; // Do we need to compute a light mask for this pass on the CPU? const bool forwardLightmaskRequest = @@ -2598,6 +2603,9 @@ void RenderMeshes( } const MaterialComponent& material = vis.scene->materials[subset.materialIndex]; + if (skip_planareflection_objects && material.HasPlanarReflection()) + continue; + bool subsetRenderable = filterMask & material.GetFilterMask(); if (renderPass == RENDERPASS_SHADOW || renderPass == RENDERPASS_SHADOWCUBE) @@ -5203,7 +5211,7 @@ void DrawShadowmaps( device->BindViewports(arraysize(vp), vp, cmd); renderQueue.sort_opaque(); - RenderMeshes(vis, renderQueue, RENDERPASS_SHADOWCUBE, FILTER_OPAQUE, cmd, false, frusta, frustum_count); + RenderMeshes(vis, renderQueue, RENDERPASS_SHADOWCUBE, FILTER_OPAQUE, cmd, 0, frusta, frustum_count); if (GetTransparentShadowsEnabled() && transparentShadowsRequested) { RenderMeshes(vis, renderQueue, RENDERPASS_SHADOWCUBE, FILTER_TRANSPARENT | FILTER_WATER, cmd, false, frusta, frustum_count); @@ -5235,18 +5243,18 @@ void DrawScene( { const bool opaque = flags & FILTER_OPAQUE; const bool transparent = flags & DRAWSCENE_TRANSPARENT; - const bool tessellation = (flags & DRAWSCENE_TESSELLATION) && GetTessellationEnabled(); const bool hairparticle = flags & DRAWSCENE_HAIRPARTICLE; const bool impostor = flags & DRAWSCENE_IMPOSTOR; const bool occlusion = (flags & DRAWSCENE_OCCLUSIONCULLING) && GetOcclusionCullingEnabled(); const bool ocean = flags & DRAWSCENE_OCEAN; + const bool skip_planar_reflection_objects = flags & DRAWSCENE_SKIP_PLANAR_REFLECTION_OBJECTS; device->EventBegin("DrawScene", cmd); device->BindShadingRate(ShadingRate::RATE_1X1, cmd); BindCommonResources(cmd); - if (ocean && vis.scene->weather.IsOceanEnabled()) + if (ocean && !skip_planar_reflection_objects && vis.scene->weather.IsOceanEnabled()) { if (!occlusion || !vis.scene->ocean.IsOccluded()) { @@ -5313,7 +5321,7 @@ void DrawScene( { renderQueue.sort_opaque(); } - RenderMeshes(vis, renderQueue, renderPass, filterMask, cmd, tessellation); + RenderMeshes(vis, renderQueue, renderPass, filterMask, cmd, flags); } if (impostor) @@ -7041,7 +7049,7 @@ void RefreshEnvProbes(const Visibility& vis, CommandList cmd) if (!renderQueue.empty()) { - RenderMeshes(vis, renderQueue, RENDERPASS_ENVMAPCAPTURE, FILTER_ALL, cmd, false, frusta, arraysize(frusta)); + RenderMeshes(vis, renderQueue, RENDERPASS_ENVMAPCAPTURE, FILTER_ALL, cmd, 0, frusta, arraysize(frusta)); } } @@ -7592,7 +7600,7 @@ void VXGI_Voxelize( #else const uint32_t frustum_count = 3; // just used to replicate 3 times for main axes, but not with real frustums #endif // VOXELIZATION_GEOMETRY_SHADER_ENABLED - RenderMeshes(vis, renderQueue, RENDERPASS_VOXELIZE, FILTER_OPAQUE, cmd, false, nullptr, frustum_count); + RenderMeshes(vis, renderQueue, RENDERPASS_VOXELIZE, FILTER_OPAQUE, cmd, 0, nullptr, frustum_count); device->RenderPassEnd(cmd); { @@ -9482,7 +9490,7 @@ void SurfelGI( void DDGI( const wi::scene::Scene& scene, - wi::graphics::CommandList cmd, + CommandList cmd, uint8_t instanceInclusionMask ) { @@ -13371,7 +13379,7 @@ void CreateVolumetricCloudResources(VolumetricCloudResources& res, XMUINT2 resol desc.width = resolution.x / 4; desc.height = resolution.y / 4; desc.format = Format::R16G16B16A16_FLOAT; - desc.layout = ResourceState::SHADER_RESOURCE_COMPUTE; + desc.layout = ResourceState::SHADER_RESOURCE; device->CreateTexture(&desc, nullptr, &res.texture_cloudRender); device->SetName(&res.texture_cloudRender, "texture_cloudRender"); desc.format = Format::R32G32_FLOAT; @@ -13492,15 +13500,6 @@ void Postprocess_VolumetricClouds( cmd ); - { - GPUBarrier barriers[] = { - GPUBarrier::Memory(), - GPUBarrier::Image(&res.texture_cloudRender, ResourceState::UNORDERED_ACCESS, res.texture_cloudRender.desc.layout), - GPUBarrier::Image(&res.texture_cloudDepth, ResourceState::UNORDERED_ACCESS, res.texture_cloudDepth.desc.layout), - }; - device->Barrier(barriers, arraysize(barriers), cmd); - } - device->EventEnd(cmd); } @@ -13510,10 +13509,24 @@ void Postprocess_VolumetricClouds( postprocess.resolution_rcp.x = 1.0f / postprocess.resolution.x; postprocess.resolution_rcp.y = 1.0f / postprocess.resolution.y; volumetricclouds_frame = (float)res.frame; + res.frame++; // before temporal_output index is computed! int temporal_output = res.frame % 2; int temporal_history = 1 - temporal_output; + { + GPUBarrier barriers[] = { + GPUBarrier::Image(&res.texture_cloudRender, ResourceState::UNORDERED_ACCESS, res.texture_cloudRender.desc.layout), + GPUBarrier::Image(&res.texture_cloudDepth, ResourceState::UNORDERED_ACCESS, res.texture_cloudDepth.desc.layout), + + GPUBarrier::Image(&res.texture_reproject[temporal_output], res.texture_reproject[temporal_output].desc.layout, ResourceState::UNORDERED_ACCESS), + GPUBarrier::Image(&res.texture_reproject_depth[temporal_output], res.texture_reproject_depth[temporal_output].desc.layout, ResourceState::UNORDERED_ACCESS), + GPUBarrier::Image(&res.texture_reproject_additional[temporal_output], res.texture_reproject_additional[temporal_output].desc.layout, ResourceState::UNORDERED_ACCESS), + GPUBarrier::Image(&res.texture_cloudMask, res.texture_cloudMask.desc.layout, ResourceState::UNORDERED_ACCESS), + }; + device->Barrier(barriers, arraysize(barriers), cmd); + } + // Cloud reprojection pass: { device->EventBegin("Volumetric Cloud Reproject", cmd); @@ -13534,16 +13547,6 @@ void Postprocess_VolumetricClouds( }; device->BindUAVs(uavs, 0, arraysize(uavs), cmd); - { - GPUBarrier barriers[] = { - GPUBarrier::Image(&res.texture_reproject[temporal_output], res.texture_reproject[temporal_output].desc.layout, ResourceState::UNORDERED_ACCESS), - GPUBarrier::Image(&res.texture_reproject_depth[temporal_output], res.texture_reproject_depth[temporal_output].desc.layout, ResourceState::UNORDERED_ACCESS), - GPUBarrier::Image(&res.texture_reproject_additional[temporal_output], res.texture_reproject_additional[temporal_output].desc.layout, ResourceState::UNORDERED_ACCESS), - GPUBarrier::Image(&res.texture_cloudMask, res.texture_cloudMask.desc.layout, ResourceState::UNORDERED_ACCESS), - }; - device->Barrier(barriers, arraysize(barriers), cmd); - } - device->Dispatch( (res.texture_reproject[temporal_output].GetDesc().width + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, (res.texture_reproject[temporal_output].GetDesc().height + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE, @@ -13551,20 +13554,20 @@ void Postprocess_VolumetricClouds( cmd ); - { - GPUBarrier barriers[] = { - GPUBarrier::Memory(), - GPUBarrier::Image(&res.texture_reproject[temporal_output], ResourceState::UNORDERED_ACCESS, res.texture_reproject[temporal_output].desc.layout), - GPUBarrier::Image(&res.texture_reproject_depth[temporal_output], ResourceState::UNORDERED_ACCESS, res.texture_reproject_depth[temporal_output].desc.layout), - GPUBarrier::Image(&res.texture_reproject_additional[temporal_output], ResourceState::UNORDERED_ACCESS, res.texture_reproject_additional[temporal_output].desc.layout), - GPUBarrier::Image(&res.texture_cloudMask, ResourceState::UNORDERED_ACCESS, res.texture_cloudMask.desc.layout), - }; - device->Barrier(barriers, arraysize(barriers), cmd); - } - device->EventEnd(cmd); } + { + GPUBarrier barriers[] = { + GPUBarrier::Memory(), + GPUBarrier::Image(&res.texture_reproject[temporal_output], ResourceState::UNORDERED_ACCESS, res.texture_reproject[temporal_output].desc.layout), + GPUBarrier::Image(&res.texture_reproject_depth[temporal_output], ResourceState::UNORDERED_ACCESS, res.texture_reproject_depth[temporal_output].desc.layout), + GPUBarrier::Image(&res.texture_reproject_additional[temporal_output], ResourceState::UNORDERED_ACCESS, res.texture_reproject_additional[temporal_output].desc.layout), + GPUBarrier::Image(&res.texture_cloudMask, ResourceState::UNORDERED_ACCESS, res.texture_cloudMask.desc.layout), + }; + device->Barrier(barriers, arraysize(barriers), cmd); + } + // Rebind original cameras for other effects after this: BindCameraCB(camera, camera_previous, camera_reflection, cmd); @@ -13600,7 +13603,6 @@ void Postprocess_VolumetricClouds_Upsample( // Cloud upsample pass: { - device->EventBegin("Volumetric Cloud Upsample", cmd); device->BindPipelineState(&PSO_volumetricclouds_upsample, cmd); device->PushConstants(&postprocess, sizeof(postprocess), cmd); @@ -13608,12 +13610,8 @@ void Postprocess_VolumetricClouds_Upsample( device->BindResource(&res.texture_reproject_depth[temporal_output], 1, cmd); device->Draw(3, 0, cmd); - - device->EventEnd(cmd); } - res.frame++; - wi::profiler::EndRange(range); device->EventEnd(cmd); } @@ -14945,9 +14943,9 @@ void Postprocess_NormalsFromDepth( device->EventEnd(cmd); } void Postprocess_Underwater( - const wi::graphics::Texture& input, - const wi::graphics::Texture& output, - wi::graphics::CommandList cmd + const Texture& input, + const Texture& output, + CommandList cmd ) { device->EventBegin("Postprocess_Underwater", cmd); diff --git a/WickedEngine/wiRenderer.h b/WickedEngine/wiRenderer.h index 3bbd68f65..a2147f6f7 100644 --- a/WickedEngine/wiRenderer.h +++ b/WickedEngine/wiRenderer.h @@ -194,6 +194,7 @@ namespace wi::renderer DRAWSCENE_HAIRPARTICLE = 1 << 4, DRAWSCENE_IMPOSTOR = 1 << 5, DRAWSCENE_OCEAN = 1 << 6, + DRAWSCENE_SKIP_PLANAR_REFLECTION_OBJECTS = 1 << 7, }; // Draw the world from a camera. You must call BindCameraCB() at least once in this frame prior to this diff --git a/WickedEngine/wiRenderer_BindLua.cpp b/WickedEngine/wiRenderer_BindLua.cpp index f18a07969..4f2fde54b 100644 --- a/WickedEngine/wiRenderer_BindLua.cpp +++ b/WickedEngine/wiRenderer_BindLua.cpp @@ -403,9 +403,6 @@ namespace wi::lua::renderer wi::lua::RegisterFunc("SetGameSpeed", SetGameSpeed); wi::lua::RegisterFunc("GetGameSpeed", GetGameSpeed); - wi::lua::RunText("GetScreenWidth = function() return main.GetCanvas().GetLogicalWidth() end"); - wi::lua::RunText("GetScreenHeight = function() return main.GetCanvas().GetLogicalHeight() end"); - wi::lua::RegisterFunc("SetShadowProps2D", SetShadowProps2D); wi::lua::RegisterFunc("SetShadowPropsCube", SetShadowPropsCube); wi::lua::RegisterFunc("SetDebugBoxesEnabled", SetDebugBoxesEnabled); @@ -426,13 +423,18 @@ namespace wi::lua::renderer wi::lua::RegisterFunc("DrawDebugText", DrawDebugText); wi::lua::RegisterFunc("PutWaterRipple", PutWaterRipple); - wi::lua::RunText("DEBUG_TEXT_DEPTH_TEST = 1"); - wi::lua::RunText("DEBUG_TEXT_CAMERA_FACING = 2"); - wi::lua::RunText("DEBUG_TEXT_CAMERA_SCALING = 4"); - - wi::lua::RegisterFunc("ClearWorld", ClearWorld); wi::lua::RegisterFunc("ReloadShaders", ReloadShaders); + + wi::lua::RunText(R"( +GetScreenWidth = function() return main.GetCanvas().GetLogicalWidth() end +GetScreenHeight = function() return main.GetCanvas().GetLogicalHeight() end + +DEBUG_TEXT_DEPTH_TEST = 1 +DEBUG_TEXT_CAMERA_FACING = 2 +DEBUG_TEXT_CAMERA_SCALING = 4 +)"); + } } }; diff --git a/WickedEngine/wiSpriteFont_BindLua.cpp b/WickedEngine/wiSpriteFont_BindLua.cpp index 57fd00343..14d70fc0e 100644 --- a/WickedEngine/wiSpriteFont_BindLua.cpp +++ b/WickedEngine/wiSpriteFont_BindLua.cpp @@ -332,12 +332,14 @@ namespace wi::lua initialized = true; Luna::Register(wi::lua::GetLuaState()); + wi::lua::RunText(R"( +WIFALIGN_LEFT = 0 +WIFALIGN_CENTER = 1 +WIFALIGN_RIGHT = 2 +WIFALIGN_TOP = 3 +WIFALIGN_BOTTOM = 4 +)"); - wi::lua::RunText("WIFALIGN_LEFT = 0"); - wi::lua::RunText("WIFALIGN_CENTER = 1"); - wi::lua::RunText("WIFALIGN_RIGHT = 2"); - wi::lua::RunText("WIFALIGN_TOP = 3"); - wi::lua::RunText("WIFALIGN_BOTTOM = 4"); } } diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 033997030..fd60fd618 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wi::version // minor features, major updates, breaking compatibility changes const int minor = 71; // minor bug fixes, alterations, refactors, updates - const int revision = 151; + const int revision = 152; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);