// Raytraced Quaternion Julia Sets.
// Written by Nils Liaaen Corneliusen 2019.
// https://www.ignorantus.com
// License: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication license

#ifndef QUATH
#define QUATH

#include "vec.h"
#include "bmp.h"

/*
#define ITERATIONS         10
#define BOUNDING_RADIUS_2   3.0f
#define ESCAPE_THRESHOLD   10.0f
#define DEL                 0.0001f
#define EPSILON             0.0075f;

*/

#define ITERATIONS_NORM    10

#define ITERATIONS_INTER    60
#define BOUNDING_RADIUS_2   3.0f
#define ESCAPE_THRESHOLD    4.0f
//#define DEL                 0.000075f
#define DEL                 0.0001f
#define EPSILON               0.00001000f
//#define EPSILON             0.00125f

struct QuatInfo {
	int width, height;
	float frame;

	v3 start_pos;
	v4 mu_pos;
	v3 obj_col;
	float rot_xz;
	float epsilon;
	float ax;
	float ay;

	bmp_argb *dst;
};
#if 1
#define WIDTH (1920*2)
#define HEIGHT (1080*2)
#else
#define WIDTH 1920
#define HEIGHT 1080
#endif

#define THREADS 14
#define BLOCKW 16
#define BLOCKH 16

#define XBLOCKS (((WIDTH+BLOCKW-1)&~(BLOCKW-1))/BLOCKW)
#define YBLOCKS (((HEIGHT+BLOCKH-1)&~(BLOCKH-1))/BLOCKH)

#define TOTAL_BLOCKS (XBLOCKS*YBLOCKS)

void quatBlock( QuatInfo &tqi, int ulx, int uly, int w, int h );


#endif
