From 3eeaf9daf148f1a55120ce2a2df4210708883cb8 Mon Sep 17 00:00:00 2001 From: Josh Colclough Date: Wed, 25 Oct 2023 21:26:53 +0100 Subject: [PATCH] Add colour cycles to the shader to show finer details. Works well with high iteration numbers --- examples/shaders/resources/shaders/glsl100/julia_set.fs | 6 ++++-- examples/shaders/resources/shaders/glsl330/julia_set.fs | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/examples/shaders/resources/shaders/glsl100/julia_set.fs b/examples/shaders/resources/shaders/glsl100/julia_set.fs index 44d083459..56c266f52 100644 --- a/examples/shaders/resources/shaders/glsl100/julia_set.fs +++ b/examples/shaders/resources/shaders/glsl100/julia_set.fs @@ -13,7 +13,9 @@ uniform float zoom; // Zoom of the scale. // NOTE: Maximum number of shader for-loop iterations depend on GPU, // for example, on RasperryPi for this examply only supports up to 60 -const int MAX_ITERATIONS = 48; // Max iterations to do +const int MAX_ITERATIONS = 48; // Max iterations to do. + +const float COLOR_CYCLES = 1; // Number of times the palette repeats. // Square a complex number vec2 ComplexSquare(vec2 z) @@ -79,5 +81,5 @@ void main() // If in set, color black. 0.999 allows for some float accuracy error. if (norm > 0.999) gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - else gl_FragColor = vec4(Hsv2rgb(vec3(norm, 1.0, 1.0)), 1.0); + else gl_FragColor = vec4(Hsv2rgb(vec3(norm * COLOR_CYCLES, 1.0, 1.0)), 1.0); } diff --git a/examples/shaders/resources/shaders/glsl330/julia_set.fs b/examples/shaders/resources/shaders/glsl330/julia_set.fs index c5ee0da60..878f7c8dc 100644 --- a/examples/shaders/resources/shaders/glsl330/julia_set.fs +++ b/examples/shaders/resources/shaders/glsl330/julia_set.fs @@ -12,7 +12,8 @@ uniform vec2 c; // c.x = real, c.y = imaginary component. Equati uniform vec2 offset; // Offset of the scale. uniform float zoom; // Zoom of the scale. -const int MAX_ITERATIONS = 255; // Max iterations to do. +const int MAX_ITERATIONS = 255; // Max iterations to do. +const float COLOR_CYCLES = 2; // Number of times the palette repeats. Can show higher detail for higher iteration numbers. // Square a complex number vec2 ComplexSquare(vec2 z) @@ -77,5 +78,5 @@ void main() // If in set, color black. 0.999 allows for some float accuracy error. if (norm > 0.999) finalColor = vec4(0.0, 0.0, 0.0, 1.0); - else finalColor = vec4(Hsv2rgb(vec3(norm, 1.0, 1.0)), 1.0); + else finalColor = vec4(Hsv2rgb(vec3(norm * COLOR_CYCLES, 1.0, 1.0)), 1.0); }