diff options
author | Andreas Grois <andi@grois.info> | 2018-03-15 22:34:52 +0100 |
---|---|---|
committer | Andreas Grois <andi@grois.info> | 2018-03-15 22:34:52 +0100 |
commit | bb9b7d23a1ca8e2afa8c8636d7312adc700d9a34 (patch) | |
tree | b30bc01efe728a8b7887061b02af8e4a5af9f770 /BuddhaTest/Shaders/BuddhaCompute.glsl | |
parent | af0d5f4988bf94c4bf918b306f72f8604395715b (diff) |
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.
Diffstat (limited to 'BuddhaTest/Shaders/BuddhaCompute.glsl')
-rw-r--r-- | BuddhaTest/Shaders/BuddhaCompute.glsl | 14 |
1 files changed, 7 insertions, 7 deletions
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)
|