From 68675c6a606cd85b522bd4024d3ea519d0119568 Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 30 Jan 2020 13:52:46 +0100 Subject: Updated web examples to latest raylib --- examples/web/shaders/shaders_julia_set.data | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'examples/web/shaders/shaders_julia_set.data') diff --git a/examples/web/shaders/shaders_julia_set.data b/examples/web/shaders/shaders_julia_set.data index bc9ecd6..bce25db 100644 --- a/examples/web/shaders/shaders_julia_set.data +++ b/examples/web/shaders/shaders_julia_set.data @@ -11,7 +11,9 @@ 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. +// 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 // Square a complex number vec2 ComplexSquare(vec2 z) @@ -55,23 +57,22 @@ void main() // NOTE: fragTexCoord already comes as normalized screen coordinates but offset must be normalized before scaling and zoom vec2 z = vec2((fragTexCoord.x + offset.x/screenDims.x)*2.5/zoom, (fragTexCoord.y + offset.y/screenDims.y)*1.5/zoom); - int iterations = 0; - for (int i = 0; i < MAX_ITERATIONS; i++) + int iter = 0; + for (int iterations = 0; iterations < 60; iterations++) { - iterations = i; - z = ComplexSquare(z) + c; // Iterate function - if (dot(z, z) > 4.0) break; + + iter = iterations; } - + // Another few iterations decreases errors in the smoothing calculation. // See http://linas.org/art-gallery/escape/escape.html for more information. z = ComplexSquare(z) + c; z = ComplexSquare(z) + c; // This last part smooths the color (again see link above). - float smoothVal = float(iterations) + 1.0 - (log(log(length(z)))/log(2.0)); + float smoothVal = float(iter) + 1.0 - (log(log(length(z)))/log(2.0)); // Normalize the value so it is between 0 and 1. float norm = smoothVal/float(MAX_ITERATIONS); -- cgit v1.2.3