From b346a4a8582dbaafa8c91cca5af0036f51a16869 Mon Sep 17 00:00:00 2001 From: Cody Glassman Date: Tue, 10 Sep 2024 16:58:27 +0000 Subject: [PATCH] Add frame number to available postprocess uniforms --- CMakeLists.txt | 2 +- apps/openmw/mwrender/postprocessor.cpp | 2 ++ components/fx/stateupdater.hpp | 9 ++++++++- docs/source/reference/postprocessing/omwfx.rst | 2 ++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 411f3e4681..759ada4f6d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,7 +83,7 @@ set(OPENMW_VERSION_MAJOR 0) set(OPENMW_VERSION_MINOR 49) set(OPENMW_VERSION_RELEASE 0) set(OPENMW_LUA_API_REVISION 68) -set(OPENMW_POSTPROCESSING_API_REVISION 1) +set(OPENMW_POSTPROCESSING_API_REVISION 2) set(OPENMW_VERSION_COMMITHASH "") set(OPENMW_VERSION_TAGHASH "") diff --git a/apps/openmw/mwrender/postprocessor.cpp b/apps/openmw/mwrender/postprocessor.cpp index 59559d70e7..623edcb82c 100644 --- a/apps/openmw/mwrender/postprocessor.cpp +++ b/apps/openmw/mwrender/postprocessor.cpp @@ -323,6 +323,8 @@ namespace MWRender mStateUpdater->setSimulationTime(static_cast(stamp->getSimulationTime())); mStateUpdater->setDeltaSimulationTime(static_cast(stamp->getSimulationTime() - mLastSimulationTime)); + // Use a signed int because 'uint' type is not supported in GLSL 120 without extensions + mStateUpdater->setFrameNumber(static_cast(stamp->getFrameNumber())); mLastSimulationTime = stamp->getSimulationTime(); for (const auto& dispatchNode : mCanvases[frameId]->getPasses()) diff --git a/components/fx/stateupdater.hpp b/components/fx/stateupdater.hpp index 9b7a25286a..33a7a09fe6 100644 --- a/components/fx/stateupdater.hpp +++ b/components/fx/stateupdater.hpp @@ -89,6 +89,8 @@ namespace fx void setDeltaSimulationTime(float time) { mData.get() = time; } + void setFrameNumber(int frame) { mData.get() = frame; } + void setWindSpeed(float speed) { mData.get() = speed; } void setWeatherTransition(float transition) @@ -233,6 +235,11 @@ namespace fx static constexpr std::string_view sName = "deltaSimulationTime"; }; + struct FrameNumber : std140::Int + { + static constexpr std::string_view sName = "frameNumber"; + }; + struct WindSpeed : std140::Float { static constexpr std::string_view sName = "windSpeed"; @@ -267,7 +274,7 @@ namespace fx = std140::UBO; + FrameNumber, WindSpeed, WeatherTransition, WeatherID, NextWeatherID, IsUnderwater, IsInterior>; UniformData mData; bool mUseUBO; diff --git a/docs/source/reference/postprocessing/omwfx.rst b/docs/source/reference/postprocessing/omwfx.rst index e5246bec8e..60fd2663c4 100644 --- a/docs/source/reference/postprocessing/omwfx.rst +++ b/docs/source/reference/postprocessing/omwfx.rst @@ -107,6 +107,8 @@ Builtin Uniforms +-------------+------------------------------+--------------------------------------------------+ | float | ``omw.deltaSimulationTime`` | The change in `omw.simulationTime` | +-------------+------------------------------+--------------------------------------------------+ +| int | ``omw.frameNumber`` | The current frame number | ++-------------+------------------------------+--------------------------------------------------+ | float | ``omw.windSpeed`` | The current wind speed | +-------------+------------------------------+--------------------------------------------------+ | float | ``omw.weatherTransition`` | The transition factor between weathers [0, 1] |