From ae810e1a9c68d05bee254ef570fbb0e783e25931 Mon Sep 17 00:00:00 2001 From: skal Date: Tue, 10 Feb 2026 17:47:15 +0100 Subject: feat: Add ShaderToy conversion tools MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add automated conversion pipeline for ShaderToy shaders to demo effects: - convert_shadertoy.py: Automated code generation script - Manual templates: Header, implementation, and WGSL boilerplate - Example shader: Test case for conversion workflow - README: Complete conversion guide with examples Handles basic GLSL→WGSL conversion (types, uniforms, mainImage extraction). Manual fixes needed for fragColor returns and complex type inference. Organized under tools/shadertoy/ for maintainability. Co-Authored-By: Claude Sonnet 4.5 --- tools/shadertoy/template.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tools/shadertoy/template.h (limited to 'tools/shadertoy/template.h') diff --git a/tools/shadertoy/template.h b/tools/shadertoy/template.h new file mode 100644 index 0000000..2e4af5f --- /dev/null +++ b/tools/shadertoy/template.h @@ -0,0 +1,41 @@ +// This file is part of the 64k demo project. +// ShaderToy effect boilerplate - REPLACE THIS LINE WITH DESCRIPTION +// TODO: Update description, rename class, adjust parameters + +#ifndef SHADERTOY_EFFECT_H_ +#define SHADERTOY_EFFECT_H_ + +#include "gpu/effect.h" +#include "gpu/effects/post_process_helper.h" +#include "gpu/uniform_helper.h" + +// TODO: Rename class to match your effect (e.g., TunnelEffect, PlasmaEffect) +class ShaderToyEffect : public Effect { + public: + // TODO: Add constructor parameters for tunable values + ShaderToyEffect(const GpuContext& ctx); + ~ShaderToyEffect() override; + + void init(MainSequence* demo) override; + void render(WGPURenderPassEncoder pass, float time, float beat, + float intensity, float aspect_ratio) override; + + private: + // TODO: Add effect-specific parameters here + // Must match WGSL struct exactly - use padding for 16-byte alignment + struct ShaderToyParams { + float param1; + float param2; + float _pad[2]; // Padding to 16 bytes + }; + static_assert(sizeof(ShaderToyParams) == 16, + "ShaderToyParams must be 16 bytes for WGSL alignment"); + + MainSequence* demo_ = nullptr; + WGPURenderPipeline pipeline_ = nullptr; + WGPUBindGroup bind_group_ = nullptr; + WGPUSampler sampler_ = nullptr; + UniformBuffer params_; +}; + +#endif /* SHADERTOY_EFFECT_H_ */ -- cgit v1.2.3