From bb9b7d23a1ca8e2afa8c8636d7312adc700d9a34 Mon Sep 17 00:00:00 2001 From: Andreas Grois Date: Thu, 15 Mar 2018 22:34:52 +0100 Subject: Fix endless loop in shader and make framerate adaptive It seems forcing points outside the cardioid and bulb with a bad random generator can take really long... Also, now framerate adjusts based on time it takes to render frames. --- BuddhaTest/Shaders/BuddhaCompute.glsl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'BuddhaTest/Shaders') diff --git a/BuddhaTest/Shaders/BuddhaCompute.glsl b/BuddhaTest/Shaders/BuddhaCompute.glsl index fcc9010..26c7ad0 100644 --- a/BuddhaTest/Shaders/BuddhaCompute.glsl +++ b/BuddhaTest/Shaders/BuddhaCompute.glsl @@ -172,18 +172,18 @@ bool isInMainBulb(vec2 v) vec2 getStartValue(uint seed, uint yDecoupler) { uint hash = seed; - bool pointUnusable; - vec2 point; - do + + for(uint i = 0; i < 5;++i) { float x = hash1(hash,hash); hash = (hash ^ intHash(yDecoupler)); float y = hash1(hash,hash); vec2 random = vec2(x,y); - point = vec2(random.x * 3.5-2.5,random.y*1.55); - pointUnusable = (isInMainBulb(point) || isInMainCardioid(point)); - }while(pointUnusable); - return point; + vec2 point = vec2(random.x * 3.5-2.5,random.y*1.55); + if(!(isInMainBulb(point) || isInMainCardioid(point))) + return point; + } + return vec2(0); } bool isGoingToBeDrawn(in vec2 offset, in uint totalIterations, inout vec2 lastVal, inout uint iterationsLeftThisFrame, inout uint doneIterations, out bool result) -- cgit v1.2.3