#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <memory>
#include <unordered_map>
#include <chrono>
#include <cmath>
#include <stdexcept>
#include <filesystem>
#define GL_SILENCE_DEPRECATION
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <nlohmann/json.hpp>
#include <cpp-base64/base64.h>
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
namespace ShaderToy {
enum class NodeClass { RenderOutput, GLSLShader, Texture, CubeMap, LastFrame, Keyboard, Unknown };
enum class NodeType { Image, CubeMap, Sound };
enum class Filter { Mipmap, Linear, Nearest };
enum class Wrap { Clamp, Repeat };
struct Node {
std::string name;
Node() = default;
virtual ~Node() = default;
virtual NodeClass getNodeClass() const = 0;
virtual NodeType getNodeType() const = 0;
};
struct RenderOutput final : Node {
NodeClass getNodeClass() const override { return NodeClass::RenderOutput; }
NodeType getNodeType() const override { return NodeType::Image; }
};
struct Keyboard final : Node {
NodeClass getNodeClass() const override { return NodeClass::Keyboard; }
NodeType getNodeType() const override { return NodeType::Image; }
};
struct GLSLShader final : Node {
std::string source;
NodeType nodeType;
GLSLShader(std::string src, NodeType type) : source(std::move(src)), nodeType(type) {}
NodeClass getNodeClass() const override { return NodeClass::GLSLShader; }
NodeType getNodeType() const override { return nodeType; }
};
struct LastFrame final : Node {
std::string refNodeName;
Node* refNode = nullptr;
NodeType nodeType;
LastFrame(std::string refNodeNameVal, NodeType nodeTypeVal)
: refNodeName(std::move(refNodeNameVal)), nodeType(nodeTypeVal) {}
NodeClass getNodeClass() const override { return NodeClass::LastFrame; }
NodeType getNodeType() const override { return nodeType; }
};
struct Texture final : Node {
uint32_t width;
uint32_t height;
std::vector<uint32_t> pixel;
Texture(uint32_t w, uint32_t h, std::vector<uint32_t> data) : width(w), height(h), pixel(std::move(data)) {}
NodeClass getNodeClass() const override { return NodeClass::Texture; }
NodeType getNodeType() const override { return NodeType::Image; }
};
struct CubeMap final : Node {
uint32_t size;
std::vector<uint32_t> pixel;
CubeMap(uint32_t x, std::vector<uint32_t> data) : size(x), pixel(std::move(data)) {}
NodeClass getNodeClass() const override { return NodeClass::CubeMap; }
NodeType getNodeType() const override { return NodeType::CubeMap; }
};
struct Link final {
Node* start;
Node* end;
Filter filter;
Wrap wrapMode;
uint32_t slot;
};
struct ShaderToyTransmissionFormat final {
using Metadata = std::unordered_map<std::string, std::string>;
Metadata metadata;
std::vector<std::unique_ptr<Node>> nodes;
std::vector<Link> links;
void load(const std::string& filePath) {
std::ifstream file{ filePath };
if(!file) {
std::cerr << "Cannot open file " << filePath << std::endl;
throw std::runtime_error("file not found");
}
try {
nlohmann::json json;
file >> json;
json.at("metadata").get_to(metadata);
std::unordered_map<std::string, Node*> nodeMap;
for(auto node : json.at("nodes")) {
std::unique_ptr<Node> nodeVal;
auto nodeClass = node.at("class").get<std::string>();
if(nodeClass == "RenderOutput"){
nodeVal = std::make_unique<RenderOutput>();
} else if(nodeClass == "GLSLShader") {
auto type = node.at("type").get<std::string>();
nodeVal = std::make_unique<GLSLShader>(node.at("source").get<std::string>(),
type == "Image" ? NodeType::Image : NodeType::CubeMap );
} else if(nodeClass == "Texture") {
auto width = node.at("width").get<uint32_t>();
auto height = node.at("height").get<uint32_t>();
auto base64Data = node.at("data").get<std::string>();
auto decodedData = base64_decode(base64Data);
const auto begin = reinterpret_cast<const uint32_t*>(decodedData.data());
const auto end = begin + static_cast<ptrdiff_t>(width) * height;
nodeVal = std::make_unique<Texture>(width, height, std::vector<uint32_t>{ begin, end });
} else if (nodeClass == "CubeMap") {
auto size = node.at("size").get<uint32_t>();
auto base64Data = node.at("data").get<std::string>();
auto decodedData = base64_decode(base64Data);
const auto begin = reinterpret_cast<const uint32_t*>(decodedData.data());
const auto end = begin + static_cast<ptrdiff_t>(size) * size * 6;
nodeVal = std::make_unique<CubeMap>(size, std::vector<uint32_t>{ begin, end });
} else if (nodeClass == "LastFrame") {
auto type = node.at("type").get<std::string>();
nodeVal = std::make_unique<LastFrame>(node.at("ref").get<std::string>(),
type == "Image" ? NodeType::Image : NodeType::CubeMap );
} else if (nodeClass == "Keyboard") {
nodeVal = std::make_unique<Keyboard>();
} else {
std::cerr << "Unknown node class " << nodeClass << std::endl;
throw std::runtime_error("unknown node class");
}
nodeVal->name = node.at("name").get<std::string>();
nodeMap.emplace(nodeVal->name, nodeVal.get());
nodes.push_back(std::move(nodeVal));
}
for (auto& node : nodes) {
if(node->getNodeClass() == NodeClass::LastFrame){
auto& lastFrame = dynamic_cast<LastFrame&>(*node);
lastFrame.refNode = nodeMap.at(lastFrame.refNodeName);
}
}
for(auto link : json.at("links")) {
auto start = link.at("start").get<std::string>();
auto end = link.at("end").get<std::string>();
auto filter = link.at("filter").get<std::string>();
auto wrapMode = link.at("wrapMode").get<std::string>();
auto slot = link.at("slot").get<uint32_t>();
links.push_back(Link{ nodeMap.at(start), nodeMap.at(end),
filter == "Mipmap" ? Filter::Mipmap : (filter == "Nearest" ? Filter::Nearest : Filter::Linear),
wrapMode == "Repeat" ? Wrap::Repeat : Wrap::Clamp, slot });
}
}
catch (const std::exception& ex) {
std::cerr << "Failed to parse STTF file: " << ex.what() << std::endl;
throw;
}
}
};
struct Channel {
GLuint tex{};
bool isCube{};
std::optional<ImVec2> size;
Filter filter;
Wrap wrapMode;
uint32_t slot;
};
struct RenderPass {
GLuint program{};
std::vector<GLuint> frameBuffers;
NodeType type;
std::vector<Channel> channels;
GLint iResolutionLocation;
GLint iTimeLocation;
GLint iTimeDeltaLocation;
GLint iFrameRateLocation;
GLint iFrameLocation;
GLint iMouseLocation;
GLint iDateLocation;
std::vector<GLint> iChannelLocations;
std::vector<GLint> iChannelResolutionLocations;
RenderPass(const std::string& vertexSrc, const std::string& pixelSrc, NodeType type, std::vector<GLuint> fbs, std::vector<Channel> chans)
: type(type), frameBuffers(std::move(fbs)), channels(std::move(chans))
{
const auto vertexShader = glCreateShader(GL_VERTEX_SHADER);
auto vGuard = scopeExit([&] { glDeleteShader(vertexShader); });
const char* vertexSrcData = vertexSrc.c_str();
glShaderSource(vertexShader, 1, &vertexSrcData, nullptr);
glCompileShader(vertexShader);
checkShaderCompileError(vertexShader, "VERTEX");
const auto pixelShader = glCreateShader(GL_FRAGMENT_SHADER);
auto pGuard = scopeExit([&] { glDeleteShader(pixelShader); });
const char* pixelSrcData = pixelSrc.c_str();
glShaderSource(pixelShader, 1, &pixelSrcData, nullptr);
glCompileShader(pixelShader);
checkShaderCompileError(pixelShader, "PIXEL");
program = glCreateProgram();
auto programGuard = scopeFail([&] { glDeleteProgram(program); });
glAttachShader(program, vertexShader);
auto vBindGuard = scopeExit([&] { glDetachShader(program, vertexShader); });
glAttachShader(program, pixelShader);
auto pBindGuard = scopeExit([&] { glDetachShader(program, pixelShader); });
glLinkProgram(program);
checkShaderCompileError(program, "PROGRAM");
iResolutionLocation = glGetUniformLocation(program, "iResolution");
iTimeLocation = glGetUniformLocation(program, "iTime");
iTimeDeltaLocation = glGetUniformLocation(program, "iTimeDelta");
iFrameRateLocation = glGetUniformLocation(program, "iFrameRate");
iFrameLocation = glGetUniformLocation(program, "iFrame");
iMouseLocation = glGetUniformLocation(program, "iMouse");
iDateLocation = glGetUniformLocation(program, "iDate");
for (const auto& channel : channels) {
iChannelLocations.push_back(glGetUniformLocation(program, ("iChannel" + std::to_string(channel.slot)).c_str()));
iChannelResolutionLocations.push_back(glGetUniformLocation(program, ("iChannelResolution" + std::to_string(channel.slot)).c_str()));
}
}
~RenderPass() {
glDeleteProgram(program);
}
void render(const ImVec2& frameBufferSize, const ImVec2& clipMin, const ImVec2& clipMax, const ImVec2& canvasSize,
const double time, const double timeDelta, const double frameRate, const int frame, const ImVec4& mouse, const ImVec4& date,
const GLuint vao, const GLuint vbo)
{
const ImVec2 cubeMapSize{ 1024, 1024 };
const auto screenBase = clipMin;
const auto screenSize = ImVec2{ clipMax.x - clipMin.x, clipMax.y - clipMin.y };
for (uint32_t idx = 0; idx < frameBuffers.size(); ++idx)
{
const auto buffer = frameBuffers[idx];
ImVec2 size, base, fbSize, uniformSize;
if (buffer)
{
base = { 0, 0 };
size = type == NodeType::CubeMap ? cubeMapSize : screenSize;
fbSize = size;
uniformSize = type == NodeType::CubeMap ? cubeMapSize : canvasSize;
glViewport(0, 0, static_cast<GLsizei>(size.x), static_cast<GLsizei>(size.y));
glDisable(GL_SCISSOR_TEST);
glBindFramebuffer(GL_FRAMEBUFFER, buffer);
}
else
{
glViewport(0, 0, static_cast<GLsizei>(frameBufferSize.x), static_cast<GLsizei>(frameBufferSize.y));
glEnable(GL_SCISSOR_TEST);
glScissor(static_cast<GLint>(clipMin.x), static_cast<GLint>(frameBufferSize.y - clipMax.y),
static_cast<GLint>(clipMax.x - clipMin.x), static_cast<GLint>(clipMax.y - clipMin.y));
base = screenBase;
size = screenSize;
fbSize = frameBufferSize;
uniformSize = canvasSize;
}
glUseProgram(program);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBindVertexArray(vao);
if(type == NodeType::Image){
struct Vertex {
ImVec2 pos;
ImVec2 coord;
};
std::array vertices{
Vertex{ ImVec2{ base.x, base.y + size.y }, ImVec2{ 0.0, 0.0 } },
Vertex{ ImVec2{ base.x, base.y }, ImVec2{ 0.0, uniformSize.y } },
Vertex{ ImVec2{ base.x + size.x, base.y }, ImVec2{ uniformSize.x, uniformSize.y } },
Vertex{ ImVec2{ base.x + size.x, base.y + size.y }, ImVec2{ uniformSize.x, 0.0 } },
};
for (auto& [pos, coord] : vertices)
{
pos.x = pos.x / fbSize.x * 2.0f - 1.0f;
pos.y = 1.0f - pos.y / fbSize.y * 2.0f;
}
glBufferData(GL_ARRAY_BUFFER, 4 * sizeof(Vertex), vertices.data(), GL_STREAM_DRAW);
} else {
struct VertexCubeMap final {
ImVec2 pos;
ImVec2 coord;
std::array<float, 3> point;
};
constexpr std::array<std::array<float, 3>, 8> cubeMapVertexPos = {
{ -1.0f, -1.0f, -1.0f }, { -1.0f, -1.0f, 1.0f },
{ -1.0f, 1.0f, -1.0f }, { -1.0f, 1.0f, 1.0f },
{ 1.0f, -1.0f, -1.0f }, { 1.0f, -1.0f, 1.0f },
{ 1.0f, 1.0f, -1.0f }, { 1.0f, 1.0f, 1.0f }
};
constexpr uint32_t cubeMapVertexIndex[6][4] = {
{ 4, 6, 7, 5 }, // right
{ 1, 3, 2, 0 }, // left
{ 2, 3, 7, 6 }, // top
{ 1, 0, 4, 5 }, // bottom
{ 5, 7, 3, 1 }, // back
{ 0, 2, 6, 4 } // front
};
std::array vertices{
VertexCubeMap{ ImVec2{ base.x, base.y + size.y }, ImVec2{ 0.0, 0.0 }, cubeMapVertexPos[cubeMapVertexIndex[idx][0]] },
VertexCubeMap{ ImVec2{ base.x, base.y }, ImVec2{ 0.0, uniformSize.y }, cubeMapVertexPos[cubeMapVertexIndex[idx][1]] },
VertexCubeMap{ ImVec2{ base.x + size.x, base.y }, ImVec2{ uniformSize.x, uniformSize.y }, cubeMapVertexPos[cubeMapVertexIndex[idx][2]] },
VertexCubeMap{ ImVec2{ base.x + size.x, base.y + size.y }, ImVec2{ uniformSize.x, 0.0 }, cubeMapVertexPos[cubeMapVertexIndex[idx][3]] },
};
for (auto& [pos, coord, point] : vertices)
{
pos.x = pos.x / fbSize.x * 2.0f - 1.0f;
pos.y = 1.0f - pos.y / fbSize.y * 2.0f;
}
glBufferData(GL_ARRAY_BUFFER, 4 * sizeof(VertexCubeMap), vertices.data(), GL_STREAM_DRAW);
}
for (size_t i = 0; i < channels.size(); ++i) {
auto& channel = channels[i];
if(iChannelLocations[i] == -1)
continue;
glUniform1i(iChannelLocations[i], static_cast<GLint>(channel.slot));
const auto texSize = channel.size.value_or(channel.isCube ? cubeMapSize : size);
if(iChannelResolutionLocations[i] != -1)
glUniform3f(iChannelResolutionLocations[i], texSize.x, texSize.y, 1.0f);
glActiveTexture(GL_TEXTURE0 + channel.slot);
const auto type = channel.isCube ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D;
glBindTexture(type, channel.tex);
if (glGetError() != GL_NO_ERROR)
continue;
const GLint wrapMode = [&] {
switch (channel.wrapMode) {
case Wrap::Clamp:
return GL_CLAMP_TO_EDGE;
case Wrap::Repeat:
return GL_REPEAT;
}
throw std::runtime_error("invalid wrap mode");
}();
const GLint minFilter = [&] {
switch (channel.filter) {
case Filter::Mipmap:
return GL_LINEAR_MIPMAP_LINEAR;
case Filter::Nearest:
return GL_NEAREST;
case Filter::Linear:
return GL_LINEAR;
}
throw std::runtime_error("invalid min filter");
}();
const GLint magFilter = [&] {
switch (channel.filter) {
case Filter::Nearest:
return GL_NEAREST;
case Filter::Mipmap:
[[fallthrough]];
case Filter::Linear:
return GL_LINEAR;
}
throw std::runtime_error("invalid mag filter");
}();
if (channel.filter == Filter::Mipmap)
glGenerateMipmap(type);
glTexParameteri(type, GL_TEXTURE_WRAP_S, wrapMode);
glTexParameteri(type, GL_TEXTURE_WRAP_T, wrapMode);
glTexParameteri(type, GL_TEXTURE_MIN_FILTER, minFilter);
glTexParameteri(type, GL_TEXTURE_MAG_FILTER, magFilter);
}
if (iResolutionLocation != -1)
glUniform3f(iResolutionLocation, uniformSize.x, uniformSize.y, 0.0f);
if (iTimeLocation != -1)
glUniform1f(iTimeLocation, static_cast<float>(time));
if (iTimeDeltaLocation != -1)
glUniform1f(iTimeDeltaLocation, static_cast<float>(timeDelta));
if (iFrameRateLocation != -1)
glUniform1f(iFrameRateLocation, static_cast<float>(frameRate));
if (iFrameLocation != -1)
glUniform1i(iFrameLocation, frame);
if (iMouseLocation != -1)
glUniform4f(iMouseLocation, mouse.x, mouse.y, mouse.z, mouse.w);
if (iDateLocation != -1)
glUniform4f(iDateLocation, date.x, date.y, date.z, date.w);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
if (buffer)
glBindFramebuffer(GL_FRAMEBUFFER, GL_NONE);
}
glActiveTexture(GL_TEXTURE0);
}
};
static void checkShaderCompileError(const GLuint shader, const std::string_view type) {
GLint success;
std::vector<GLchar> buffer;
GLint size;
if(type != "PROGRAM") {
glGetShaderiv(shader, GL_COMPILE_STATUS, &success);
if(!success) {
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &size);
buffer.resize(static_cast<size_t>(size));
glGetShaderInfoLog(shader, static_cast<GLsizei>(buffer.size()), nullptr, buffer.data());
std::cerr << buffer.data() << std::endl;
throw std::runtime_error("shader compile error");
}
} else {
glGetProgramiv(shader, GL_LINK_STATUS, &success);
if(!success) {
glGetProgramiv(shader, GL_INFO_LOG_LENGTH, &size);
buffer.resize(static_cast<size_t>(size));
glGetProgramInfoLog(shader, static_cast<GLsizei>(buffer.size()), nullptr, buffer.data());
std::cerr << buffer.data() << std::endl;
throw std::runtime_error("shader link error");
}
}
}
class GLTextureObject final {
GLuint mTex{};
ImVec2 mSize;
public:
GLTextureObject(const uint32_t width, const uint32_t height, const uint32_t* data)
: mSize{ static_cast<float>(width), static_cast<float>(height) } {
glGenTextures(1, &mTex);
glBindTexture(GL_TEXTURE_2D, mTex);
if (data) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, static_cast<GLsizei>(width), static_cast<GLsizei>(height), 0, GL_RGBA,
GL_UNSIGNED_BYTE, data);
glGenerateMipmap(GL_TEXTURE_2D);
}
glBindTexture(GL_TEXTURE_2D, GL_NONE);
}
~GLTextureObject() {
glDeleteTextures(1, &mTex);
}
[[nodiscard]] GLuint getTexture() const {
return mTex;
}
[[nodiscard]] ImVec2 size() const {
return mSize;
}
};
class GLCubeMapObject final {
GLuint mTex{};
ImVec2 mSize;
public:
GLCubeMapObject(const uint32_t size, const uint32_t* data)
: mSize{ static_cast<float>(size), static_cast<float>(size) } {
glGenTextures(1, &mTex);
glBindTexture(GL_TEXTURE_CUBE_MAP, mTex);
if(data){
const auto offset = static_cast<ptrdiff_t>(size) * static_cast<ptrdiff_t>(size);
for(int32_t idx = 0; idx < 6; ++idx) {
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + idx, 0, GL_RGBA, static_cast<GLsizei>(size), static_cast<GLsizei>(size),
0, GL_RGBA, GL_UNSIGNED_BYTE, data + idx * offset);
}
glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
}
glBindTexture(GL_TEXTURE_CUBE_MAP, GL_NONE);
}
~GLCubeMapObject() {
glDeleteTextures(1, &mTex);
}
[[nodiscard]] GLuint getTexture() const {
return mTex;
}
[[nodiscard]] ImVec2 size() const {
return mSize;
}
};
class ShaderToyPlayer {
GLFWwindow* window = nullptr;
GLuint mVAOImage{};
GLuint mVAOCubeMap{};
GLuint mVBO{};
std::vector<std::unique_ptr<GLTextureObject>> textures;
std::vector<std::unique_ptr<GLCubeMapObject>> cubeMaps;
std::vector<std::unique_ptr<RenderPass>> renderPasses;
std::unique_ptr<ShaderToyTransmissionFormat> sttf;
std::unordered_map<std::string, GLuint> frameBufferMap;
ImVec2 canvasSize{};
double time = 0;
double timeDelta = 0;
double frameRate = 60;
int frame = 0;
ImVec4 mouse{ 0.0f, 0.0f, -1.0f, -1.0f };
ImVec4 date;
public:
ShaderToyPlayer(const std::string& jsonPath) {
if (!glfwInit()) {
throw std::runtime_error("failed to init glfw");
}
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
window = glfwCreateWindow(1280, 720, "ShaderToy Player", nullptr, nullptr);
if (!window) {
glfwTerminate();
throw std::runtime_error("failed to create glfw window");
}
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
if (glewInit() != GLEW_OK) {
glfwTerminate();
throw std::runtime_error("failed to init glew");
}
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
[Redacted Person](1, &mVBO);
glBindBuffer(GL_ARRAY_BUFFER, mVBO);
glGenVertexArrays(1, &mVAOImage);
glBindVertexArray(mVAOImage);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, (void*)0);
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, (void*)(sizeof(float) * 2));
glBindVertexArray(0);
glGenVertexArrays(1, &mVAOCubeMap);
glBindVertexArray(mVAOCubeMap);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 8, (void*)0);
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 8, (void*)(sizeof(float) * 2));
glEnableVertexAttribArray(2);
glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(float) * 8, (void*)(sizeof(float) * 4));
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, GL_NONE);
try {
sttf = std::make_unique<ShaderToyTransmissionFormat>();
sttf->load(jsonPath);
canvasSize = {1280, 720};
for(const auto& node : sttf->nodes){
if(node->getNodeClass() == NodeClass::Texture){
const auto& tex = dynamic_cast<const Texture&>(*node);
textures.push_back(std::make_unique<GLTextureObject>(tex.width, tex.height, tex.pixel.data()));
}
else if(node->getNodeClass() == NodeClass::CubeMap){
const auto& cube = dynamic_cast<const CubeMap&>(*node);
cubeMaps.push_back(std::make_unique<GLCubeMapObject>(cube.size, cube.pixel.data()));
}
}
for (const auto& node : sttf->nodes)
{
if (node->getNodeClass() == NodeClass::GLSLShader)
{
const auto& shaderNode = dynamic_cast<const GLSLShader&>(*node);
std::string vertexSrc = R"(
#version 410 core
layout (location = 0) in vec2 pos;
layout (location = 1) in vec2 texCoord;
#ifdef INTERFACE_SHADERTOY_CUBE_MAP
layout (location = 2) in vec3 point;
#endif
layout (location = 0) out vec2 f_fragCoord;
#ifdef INTERFACE_SHADERTOY_CUBE_MAP
layout (location = 1) out vec3 f_point;
#endif
void main() {
gl_Position = vec4(pos, 1.0f, 1.0f);
f_fragCoord = texCoord;
#ifdef INTERFACE_SHADERTOY_CUBE_MAP
f_point = point;
#endif
}
)";
std::string pixelSrc = R"(
#version 410 core
layout (location = 0) in vec2 f_fragCoord;
#ifdef INTERFACE_SHADERTOY_CUBE_MAP
layout (location = 1) in vec3 f_point;
#endif
layout (location = 0) out vec4 out_frag_color;
uniform vec3 iResolution; // viewport resolution (in pixels)
uniform float iTime; // shader playback time (in seconds)
uniform float iTimeDelta;