21
64-bit SDK programming / BBP_Glow plugin
« Last post by Patrice Terrier on January 05, 2026, 10:19:41 am »BBP_Glow
Converted from https://www.shadertoy.com/view/W3tSR4
Original created by Xor on 2025-08-23
Audio + color LUT + BBP_plugin integration by Patrice Terrier

Paste this in the BBProc section
Paste this in the GLSL.h section
Converted from https://www.shadertoy.com/view/W3tSR4
Original created by Xor on 2025-08-23
Audio + color LUT + BBP_plugin integration by Patrice Terrier

Paste this in the BBProc section
Code: [Select]
case BBP_CREATE:
// Host asks: "who are you and what do you render to?"
strcpy(BBP.title,"Volumetric Glow");
strcpy(BBP.author, "Xor (Shadertoy)");
BBP.version = MAKEWORD(1,0);
// Critical: This plugin renders using OpenGL into the host-provided GL context.
BBP.renderto = BBP_OPENGL;
// Default background ARGB used by host (informational/fallback).
BBP.backargb = bbpARGB(255,0,0,0);
break;Paste this in the GLSL.h section
Code: [Select]
static GLuint CompileShaderFromString() {
const char* CharBuffer =
"#version 330 core\n"
"\n"
"uniform vec3 iResolution;\n"
"uniform float iTime;\n"
"uniform float iAudio;\n" // smoothed audio level (0..~1)
"\n"
"out vec4 FragColor;\n"
"\n"
"#define STEPS 50.0\n"
"#define FOV 1.0\n"
"#define BASE_DENSITY 1.5\n"
"\n"
"float Audio01() {\n"
" float a = max(iAudio, 0.0);\n"
" a = 1.0 - exp(-1.8 * a);\n"
" return clamp(a, 0.0, 1.0);\n"
"}\n"
"\n"
"float volumeField(vec3 p, float density, float wfreq) {\n"
" float l = length(p);\n"
" vec3 v = cos(abs(p) * wfreq / max(4.0, l) + iTime);\n"
" return length(vec4(max(v, v.yzx) - 0.9, l - 4.0)) / density;\n"
"}\n"
"\n"
"vec3 rotate90(vec3 p, vec3 a) {\n"
" return a * dot(p, a) + cross(p, a);\n"
"}\n"
"\n"
"// MOIRE FIX: tiny stable per-pixel hash (no noise texture needed)\n"
"float hash12(vec2 p) {\n"
" vec3 p3 = fract(vec3(p.xyx) * 0.1031);\n"
" p3 += dot(p3, p3.yzx + 33.33);\n"
" return fract((p3.x + p3.y) * p3.z);\n"
"}\n"
"\n"
"void main() {\n"
" vec2 fragCoord = gl_FragCoord.xy;\n"
" vec2 center = 2.0 * fragCoord - iResolution.xy;\n"
"\n"
" float a = Audio01();\n"
"\n"
" float breathe = 1.0 - 0.08 * a;\n"
"\n"
" float density = BASE_DENSITY * (1.0 + 1.2 * a);\n"
" float wfreq = 8.0 * mix(1.0, 0.65, a);\n"
" float brightness = 0.002 * (1.0 + 0.6 * a);\n"
"\n"
" vec3 axis = normalize(cos(vec3(0.5 * iTime) + vec3(0.0, 2.0, 4.0)));\n"
"\n"
" vec3 dir = rotate90(normalize(vec3(center, FOV * iResolution.y)), axis);\n"
"\n"
" float camZ = -8.0 * mix(1.0, 0.92, a);\n"
" vec3 cam = rotate90(vec3(0.0, 0.0, camZ), axis);\n"
"\n"
" // Start point\n"
" vec3 pos = cam;\n"
"\n"
" // MOIRE FIX: jitter the start along the ray by a tiny amount (breaks band alignment)\n"
" float j = hash12(floor(fragCoord));\n"
" pos += dir * (j - 0.5) * 0.10;\n"
"\n"
" vec3 col = vec3(0.0);\n"
"\n"
" for (float i = 0.0; i < STEPS; i += 1.0) {\n"
" float vol = volumeField(pos * breathe, density, wfreq);\n"
" pos += dir * vol;\n"
" float inv = 1.0 / max(vol, 0.02);\n"
" col += (cos(pos.z / (1.0 + vol) + iTime + vec3(6.0, 1.0, 2.0)) + 1.2) * inv;\n"
" }\n"
"\n"
" col = tanh(brightness * col);\n"
" FragColor = vec4(col, 1.0);\n"
"}\n";
GLuint fs = CompileShader(GL_FRAGMENT_SHADER, CharBuffer);
return fs;
}
Recent Posts


