Files
fn_registry/cpp/apps/shaders_lab/seed_shaders.h
T
egutierrez 4610bb4a99 feat(shaders_lab): uniform annotations → auto-generated ImGui controls
- cpp/functions/gfx/uniform_parser: regex-based parser of @slider/@color/@toggle/@xy annotations (+ inline tests)
- cpp/functions/gfx/uniform_panel: ImGui widgets + value store + glUniform* apply
- shader_canvas: optional uniforms callback invoked per-frame
- gl_loader: +glUniform1i/3f/4f
- seed plasma: demo uniforms u_speed + u_color
- rebuild Windows .exe

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-24 21:02:35 +02:00

86 lines
2.3 KiB
C

#pragma once
// GLSL 330 fragment shader bodies (no #version, no out, no uniform declarations).
// compile_fragment() prepends those automatically.
static const char* PLASMA = R"glsl(
uniform float u_speed; // @slider min=0.1 max=5 default=1
uniform vec3 u_color; // @color default=0.5,0.2,0.8
void main() {
vec2 uv = gl_FragCoord.xy / u_resolution;
float t = u_time * u_speed;
vec3 c = u_color * (0.5 + 0.5 * cos(t + uv.xyx + vec3(0.0, 2.0, 4.0)));
fragColor = vec4(c, 1.0);
}
)glsl";
static const char* CIRCLE = R"glsl(
void main() {
vec2 uv = gl_FragCoord.xy / u_resolution;
vec2 center = vec2(0.5);
float t = u_time;
// Animated center
center += vec2(sin(t * 0.7), cos(t * 0.5)) * 0.2;
float d = length(uv - center);
// Concentric rings
float rings = sin(d * 40.0 - t * 3.0) * 0.5 + 0.5;
// Radial glow
float glow = exp(-d * 4.0);
vec3 col = mix(
vec3(0.05, 0.1, 0.3),
vec3(0.2, 0.7, 1.0),
rings * glow + glow * 0.4
);
fragColor = vec4(col, 1.0);
}
)glsl";
static const char* CHECKER = R"glsl(
void main() {
vec2 uv = gl_FragCoord.xy / u_resolution;
float t = u_time;
// Animated scale and rotation
float scale = 8.0 + sin(t * 0.4) * 3.0;
float angle = t * 0.2;
float ca = cos(angle), sa = sin(angle);
vec2 p = uv - 0.5;
p = vec2(ca * p.x - sa * p.y, sa * p.x + ca * p.y);
p = p * scale + 0.5;
vec2 cell = floor(p);
float checker = mod(cell.x + cell.y, 2.0);
// Color gradient per cell
float hue = fract((cell.x + cell.y) * 0.1 + t * 0.05);
vec3 col_a = vec3(hue, 0.7, 0.9);
vec3 col_b = vec3(fract(hue + 0.5), 0.5, 0.7);
// Simple HSV to RGB
vec3 col = mix(col_b, col_a, checker);
// hue is already [0,1], apply saturation/value manually
float h = col.x * 6.0;
int i = int(h);
float f = h - float(i);
float p2 = col.z * (1.0 - col.y);
float q2 = col.z * (1.0 - col.y * f);
float t2 = col.z * (1.0 - col.y * (1.0 - f));
vec3 rgb;
if (i == 0) rgb = vec3(col.z, t2, p2);
else if (i == 1) rgb = vec3(q2, col.z, p2);
else if (i == 2) rgb = vec3(p2, col.z, t2);
else if (i == 3) rgb = vec3(p2, q2, col.z);
else if (i == 4) rgb = vec3(t2, p2, col.z);
else rgb = vec3(col.z, p2, q2);
fragColor = vec4(rgb, 1.0);
}
)glsl";