Lit Screenshot for README.md

This commit is contained in:
2025-04-22 01:11:39 -05:00
parent 4794be2d7f
commit e71ab30c23
5 changed files with 77 additions and 11 deletions

View File

@@ -5,4 +5,6 @@ A program and codebase for rapid iteration of GLSL programs.
* Hot Reload
* This Dick
* Public Domain
* Public Domain
![](mandelbrot.png)

View File

@@ -49,8 +49,10 @@ public:
Shader::OnCompilationErrorMessage += [this](std::string type, std::string infoLog) {
auto log_lines = string_expand(infoLog, '\n');
console->Log(type, Colors::Red);
std::cerr << type << std::endl;
for (auto line: log_lines) {
console->Log(line, Colors::Red);
std::cerr << line << std::endl;
}
};
@@ -171,7 +173,7 @@ public:
console->Log(std::format("OpenGL Vendor: {}", GetGLVendor()));
console->Log(std::format("OpenGL Version: {}", GetGLVersion()));
console->Log(std::format("GLSL Version: {}", GetGLSLVersion()));
auto ext_list = GetGLExtensionList();
/*auto ext_list = GetGLExtensionList();
// TODO: output 3 at a time.
console->Log("GL-Extensions: ");
@@ -187,7 +189,7 @@ public:
console->Log(formatted_output);
formatted_output = "";
}
}
}*/
return true;
}

BIN
mandelbrot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 KiB

View File

@@ -4,20 +4,71 @@
precision mediump float;
#endif
#define PI 3.14159265359
uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;
void main()
{
uniform vec2 u_translation;
uniform float u_zoom;
vec2 I = gl_FragCoord.xy;
#define N 48.
#define B 4.
//vec2 uv = gl_FragCoord.xy / u_resolution.xy;
//vec3 col = 0.5 + 0.5*cos(u_time+uv.xyx+vec3(0,2,4));
//gl_FragColor = vec4(col, 1.0);
vec3 pal(in float t, in vec3 a, in vec3 b, in vec3 c, in vec3 d) {
return a + b*cos(6.28318*(c*t+d));
}
vec2 c = ( 2.*I - R) / R.y, z = 0./R;
float iterate(vec2 p) {
vec2 z = vec2(0), c = p;
float i;
for (i=0.; i < N; i++ ) {
z = mat2(z, -z.y, z.x) * z + c;
if (dot(z, z) > B*B) break;
}
}
//return i;
// Compute the iteration smoothly, instead of in integers.
if (p.y < 0.f) return i;
return i - log(log(dot(z, z)) / log(B)) / log(2.);;
}
void main() {
vec2 R = u_resolution.xy;
vec2 uv = 1.2 * (2. * gl_FragCoord.xy - R - 1.) / R.y - vec2(.4, 0.);
//vec2 z = vec2(0), c = uv;
//float i;
//for (i = 0.; i < N; i++) {
// z = mat2(z, -z.y, z.x) * z + c;
// if (dot(z, z) > B*B) break;
//}
float n = iterate(uv) / N;
vec3 col = pal(fract(n + 0.5), vec3(.5), vec3(.5), vec3(1), vec3(.0, .1, .2));
//if (n == 1.) {n = 0; }
gl_FragColor = vec4(n == 1. ? vec3(0) : col, 1.);
//vec2 st = gl_FragCoord.xy/u_resolution.xy;
//vec3 color = vec3(0.0);
//vec3 pct = vec3(st.x);
// pct.r = smoothstep(0.0,1.0, st.x);
// pct.g = sin(st.x*PI);
// pct.b = pow(st.x,0.5);
//color = mix(colorA, colorB, pct);
// Plot transition lines for each channel
// color = mix(color,vec3(1.0,0.0,0.0),plot(st,pct.r));
// color = mix(color,vec3(0.0,1.0,0.0),plot(st,pct.g));
// color = mix(color,vec3(0.0,0.0,1.0),plot(st,pct.b));
// gl_FragColor = vec4(color,1.0);
}

11
shaders/random.glsl Normal file
View File

@@ -0,0 +1,11 @@
/// Generates and returns a pseudorandom number. (sic)
float random(in vec2 st) {
return fract(sin(dot(st.xy, vec2(12.989, 78.233))) * 43758.543);
}
float rseed = 0.;
vec2 random2() {
vec2 seed = vec2(rseed++, rseed++);
return vec2(random(seed + 0.342), random(seed + 0.756));
}