From 443c5aefca26cf0d0b2df8050aae6ce72f8f075d Mon Sep 17 00:00:00 2001 From: Hunter Kvalevog Date: Sun, 15 Feb 2026 11:07:23 -0600 Subject: shaders: Delete incomplete demos --- shaders/CMakeLists.txt | 2 - shaders/aero.cc | 31 ------------ shaders/aero.glsl | 128 ------------------------------------------------- shaders/polygon.cc | 27 ----------- shaders/polygon.glsl | 59 ----------------------- 5 files changed, 247 deletions(-) delete mode 100644 shaders/aero.cc delete mode 100644 shaders/aero.glsl delete mode 100644 shaders/polygon.cc delete mode 100644 shaders/polygon.glsl (limited to 'shaders') diff --git a/shaders/CMakeLists.txt b/shaders/CMakeLists.txt index a0227d5..2c061ce 100644 --- a/shaders/CMakeLists.txt +++ b/shaders/CMakeLists.txt @@ -8,8 +8,6 @@ include("${CMAKE_CURRENT_LIST_DIR}/../common/c_cpp/CMakeLists.txt") add_executable(shaders shaders.cc - aero.cc - polygon.cc subpixel.cc vfog.cc ) diff --git a/shaders/aero.cc b/shaders/aero.cc deleted file mode 100644 index 8b7e27b..0000000 --- a/shaders/aero.cc +++ /dev/null @@ -1,31 +0,0 @@ -#include "shaders.hh" - -static int u_checker = 16; -static float u_checker_c1[4] = { 0.9f, 0.9f, 0.9f, 1.0f }; -static float u_checker_c2[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; -static float u_ww = 500; -static float u_wh = 400; - -static void ui() -{ - ImGui::InputInt("Checker", &u_checker); - ImGui::SliderFloat("window w", &u_ww, 10, 1000); - ImGui::SliderFloat("window h", &u_wh, 10, 1000); -} - -static void uniforms(Shader* shader) -{ - GL(glUniform1i(shader->get_required_uniform("u_checker"), u_checker)); - GL(glUniform4fv(shader->get_required_uniform("u_checker_c1"), 1, u_checker_c1)); - GL(glUniform4fv(shader->get_required_uniform("u_checker_c2"), 1, u_checker_c2)); - GL(glUniform1f(shader->get_required_uniform("u_ww"), u_ww)); - GL(glUniform1f(shader->get_required_uniform("u_wh"), u_wh)); -} - -static Shader aero = { - .path = "aero.glsl", - .model = MODEL_QUAD, - .ui_fn = ui, - .uf_fn = uniforms, -}; -ENABLE_SHADER(aero); diff --git a/shaders/aero.glsl b/shaders/aero.glsl deleted file mode 100644 index b321af3..0000000 --- a/shaders/aero.glsl +++ /dev/null @@ -1,128 +0,0 @@ -#version 330 core - -// -------------------------------------------------------------------------------- -// Windows 7-style "aero" effect -// -// SPDX-License-Identifier: 0BSD -// -------------------------------------------------------------------------------- - -// -------------------------------------------------------------------------------- -// Uniforms -// -------------------------------------------------------------------------------- -uniform float u_time; -uniform vec2 u_res; - -uniform int u_checker; -uniform vec4 u_checker_c1; -uniform vec4 u_checker_c2; - -uniform float u_ww; -uniform float u_wh; - -// -------------------------------------------------------------------------------- -// Vertex outputs -// -------------------------------------------------------------------------------- -in vec2 v_p; -in vec2 v_t; - -// -------------------------------------------------------------------------------- -// Fragment outputs -// -------------------------------------------------------------------------------- -out vec4 f_c; - -// -------------------------------------------------------------------------------- -// Entry point -// -------------------------------------------------------------------------------- - -vec3 from_rgb(int r, int g, int b) -{ - return vec3(float(r) / 255.0f, float(g) / 255.0f, float(b) / 255.0f); -} - -vec3 checker(vec2 xy) -{ - vec2 p = floor(xy / u_checker); - float f = mod(p.x + p.y, 2.0f); - return mix(u_checker_c1, u_checker_c2, f).xyz; -} - -vec3 checker_blurred(vec2 xy) -{ - // 9-point Gaussian kernel - // Tried Kawase blur but got artifacts since I'm blurring a checkerboard. - // ref: https://www.rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling - // Mofified to sample in 8 directions + center - float weights[3] = float[](0.15217391f, 0.13043478f, 0.08152174f); - float r = 5.0f; - vec3 c = checker(xy) * weights[0]; - c += checker(xy + vec2(+r, 0.0f)) * weights[1]; - c += checker(xy + vec2(-r, 0.0f)) * weights[1]; - c += checker(xy + vec2(0.0f, +r)) * weights[1]; - c += checker(xy + vec2(0.0f, -r)) * weights[1]; - c += checker(xy + vec2(+r, +r)) * weights[2]; - c += checker(xy + vec2(-r, +r)) * weights[2]; - c += checker(xy + vec2(+r, -r)) * weights[2]; - c += checker(xy + vec2(-r, -r)) * weights[2]; - return c; -} - -vec3 window(vec2 bl, vec2 tr, vec2 xy) -{ - vec3 c1 = from_rgb(174, 199, 222); - vec3 c2 = from_rgb(227, 237, 246); - - float div = 0.3f; - float div_edge = tr.y - ((tr.y - bl.y) * div); - vec3 g1 = mix(c2, c1, 1.0f - (abs(xy.y - tr.y) / ((tr.y - bl.y) * div))); - vec3 g2 = mix(c2, c1, 1.0f - (abs(xy.y - tr.y) / (tr.y - bl.y))); - vec3 g = mix(g2, g1, step(div_edge, xy.y)); - - vec3 c = g; - // highlights - float hbr = 3.0f; - float hl = - step(tr.y - hbr, xy.y) + - (1.0f - step(bl.x + hbr, xy.x)); - hl = clamp(hl, 0.0f, 1.0f); - c += vec3(hl); - - // border - float br = 1.0f; - float border = - (1.0f - step(bl.x + br, xy.x)) + - step(tr.x - br, xy.x) + - (1.0f - step(bl.y + br, xy.y)) + - step(tr.y - br, xy.y); - border = clamp(border, 0.0f, 1.0f); - c *= (1.0f - border); - - vec3 content = checker_blurred(xy); - vec2 cbl = bl + vec2(25.0f); - vec2 ctr = tr - vec2(25.0f); - float l = step(cbl.x, xy.x); - float r = 1.0f - step(ctr.x, xy.x); - float b = step(cbl.y, xy.y); - float t = 1.0f - step(ctr.y, xy.y); - float hit = l * r * b * t; - - return mix(c, content, hit); -} - -void main() -{ - vec2 xy = gl_FragCoord.xy; - - vec2 bl = vec2((u_res.x - u_ww) / 2.0f + sin(u_time) * 500.0f, (u_res.y - u_wh) / 2.0f); - vec2 tr = bl + vec2(u_ww, u_wh); - - float l = step(bl.x, xy.x); - float r = 1.0f - step(tr.x, xy.x); - float b = step(bl.y, xy.y); - float t = 1.0f - step(tr.y, xy.y); - float hit = l * r * b * t; - - vec3 bg = checker(xy); - vec3 fg = window(bl, tr, xy); - - f_c = vec4(mix(bg, fg, hit), 1.0f); -} diff --git a/shaders/polygon.cc b/shaders/polygon.cc deleted file mode 100644 index c881475..0000000 --- a/shaders/polygon.cc +++ /dev/null @@ -1,27 +0,0 @@ -#include "shaders.hh" - -static int u_n = 3; -static float u_bg[4] = { 0, 0, 0, 1 }; -static float u_fg[4] = { 1, 1, 1, 1 }; - -static void ui() -{ - ImGui::SliderInt("N", &u_n, 3, 24); - ImGui::ColorPicker4("bg", u_bg); - ImGui::ColorPicker4("fg", u_fg); -} - -static void uniforms(Shader* shader) -{ - GL(glUniform1i(shader->get_required_uniform("u_n"), u_n)); - GL(glUniform4fv(shader->get_required_uniform("u_bg"), 1, u_bg)); - GL(glUniform4fv(shader->get_required_uniform("u_fg"), 1, u_fg)); -} - -static Shader polygon = { - .path = "polygon.glsl", - .model = MODEL_QUAD, - .ui_fn = ui, - .uf_fn = uniforms, -}; -ENABLE_SHADER(polygon); diff --git a/shaders/polygon.glsl b/shaders/polygon.glsl deleted file mode 100644 index a213f13..0000000 --- a/shaders/polygon.glsl +++ /dev/null @@ -1,59 +0,0 @@ -#version 330 core - -// -------------------------------------------------------------------------------- -// Regular polygon shader -// -// ref: https://thndl.com/square-shaped-shaders.html -// ref: https://thebookofshaders.com/07/ -// -// SPDX-License-Identifier: 0BSD -// -------------------------------------------------------------------------------- - -// -------------------------------------------------------------------------------- -// Uniforms -// -------------------------------------------------------------------------------- -uniform float u_time; -uniform vec2 u_res; -uniform int u_n; -uniform vec4 u_bg; -uniform vec4 u_fg; - -// -------------------------------------------------------------------------------- -// Vertex outputs -// -------------------------------------------------------------------------------- -in vec2 v_p; -in vec2 v_t; - -// -------------------------------------------------------------------------------- -// Fragment outputs -// -------------------------------------------------------------------------------- -out vec4 f_c; - -// -------------------------------------------------------------------------------- -// Entry point -// -------------------------------------------------------------------------------- - -#define PI 3.14159265359 - -void main() -{ - // Centered with square aspect ratio - vec2 st = gl_FragCoord.xy / u_res.xy; - float aspect = u_res.x / u_res.y; - if (aspect > 1.0f) { st.x = (st.x - 0.5f) * aspect + 0.5f; } - else { st.y = (st.y - 0.5f) / aspect + 0.5f; } - - // Remap [0, 1] to [-1, 1] - st = st * 2.0f - 1.0f; - - // Angle of pixel from center + rotation - float a = atan(st.y, st.x) + u_time * 0.2f; - - // Angle of each sector from center - float r = (PI * 2.0f) / float(u_n); - - // Polar polygon edge test. cos(theta) = dot product. - float d = cos(floor(0.5f + a / r) * r - a) * length(st); - - f_c = vec4(vec3(mix(u_bg, u_fg, 1.0f - step(0.5f, d))), 1.0f); -} -- cgit v1.2.3