diff --git a/include/merian-nodes/nodes/shadertoy/shadertoy.hpp b/include/merian-nodes/nodes/shadertoy/shadertoy.hpp index d8c39ef..013e1a7 100644 --- a/include/merian-nodes/nodes/shadertoy/shadertoy.hpp +++ b/include/merian-nodes/nodes/shadertoy/shadertoy.hpp @@ -4,7 +4,6 @@ #include "merian-nodes/nodes/compute_node/compute_node.hpp" -#include "merian/utils/stopwatch.hpp" #include "merian/vk/shader/shader_compiler.hpp" #include "merian/vk/shader/shader_hotreloader.hpp" #include "merian/vk/shader/shader_module.hpp" @@ -22,11 +21,13 @@ class Shadertoy : public AbstractCompute { glm::vec2 iResolution{}; float iTime{}; float iTimeDelta{}; - float iFrame{}; + int32_t iFrame{}; + glm::vec4 iMouse{}; + glm::vec4 iDate{}; }; public: - Shadertoy(const ContextHandle context); + Shadertoy(const ContextHandle& context); std::vector describe_outputs(const NodeIOLayout& io_layout) override; diff --git a/src/merian-nodes/nodes/shadertoy/shadertoy.cpp b/src/merian-nodes/nodes/shadertoy/shadertoy.cpp index e970961..eccb681 100644 --- a/src/merian-nodes/nodes/shadertoy/shadertoy.cpp +++ b/src/merian-nodes/nodes/shadertoy/shadertoy.cpp @@ -21,7 +21,9 @@ layout(push_constant) uniform constants { vec2 iResolution; float iTime; float iTimeDelta; - float iFrame; + int iFrame; + vec4 iMouse; + vec4 iDate; }; )"; @@ -61,7 +63,7 @@ void mainImage(out vec4 fragColor, in vec2 fragCoord) { class ShadertoyInjectCompiler : public ShaderCompiler { public: - ShadertoyInjectCompiler(const ShaderCompilerHandle forwarding_compiler) + ShadertoyInjectCompiler(const ShaderCompilerHandle& forwarding_compiler) : forwarding_compiler(forwarding_compiler) {} ~ShadertoyInjectCompiler() {} @@ -78,7 +80,7 @@ class ShadertoyInjectCompiler : public ShaderCompiler { const ShaderCompilerHandle forwarding_compiler; }; -Shadertoy::Shadertoy(const ContextHandle context) +Shadertoy::Shadertoy(const ContextHandle& context) : AbstractCompute(context, sizeof(PushConstant)), shader_glsl(default_shader) { ShaderCompilerHandle shaderc_compiler = nullptr; @@ -133,7 +135,15 @@ const void* Shadertoy::get_push_constant([[maybe_unused]] GraphRun& run, [[maybe_unused]] const NodeIO& io) { constant.iTimeDelta = static_cast(run.get_time_delta()); constant.iTime = static_cast(run.get_elapsed()); - constant.iFrame++; + constant.iFrame = static_cast(run.get_total_iteration()); + + const auto now = std::chrono::system_clock::now(); + const auto now_d = std::chrono::floor(now); + const std::chrono::year_month_day ymd(now_d); + constant.iDate.x = static_cast(static_cast(ymd.year())); + constant.iDate.y = static_cast(static_cast(ymd.month())); + constant.iDate.y = static_cast(static_cast(ymd.day())); + constant.iDate.w = std::chrono::duration_cast>(now - now_d).count(); return &constant; } @@ -222,9 +232,8 @@ AbstractCompute::NodeStatusFlags Shadertoy::properties(Properties& config) { if (needs_reconnect) { return NEEDS_RECONNECT; - } else { - return {}; } + return {}; } } // namespace merian_nodes