Compare commits

...

3 Commits

Author SHA1 Message Date
Sylvain PILLOT 768028d45f Better addin Icons 2023-01-18 21:13:19 +01:00
Sylvain PILLOT b5c692d6be Working Julia and Mandelbrot SCALE 2x2 2023-01-18 20:59:23 +01:00
Sylvain PILLOT 6abe7a23cf fine tuning of parameters 2023-01-17 22:04:41 +01:00
8 changed files with 61 additions and 22 deletions

View File

@ -15,6 +15,7 @@ set(SOURCES
src/main.cpp
src/mandelbrot.s
src/mandelbrotshader.cpp
src/julia.s
src/juliashader.cpp
src/utilities.cpp
# ...

View File

@ -1,22 +1,24 @@
# A simple shader for AZUR aiming at computating the Mandelbrot or Julia set
# A simple shader for AZUR aiming at computing the Mandelbrot and the Julia fractal sets
This small demo is based on Azur.
It uses ultra fast rendering pipeline with specific shaders :
- Mandelbrot shader written in ASM by Lephe
- Julia shader written in C with the libnum fast fixed point arithmetic lib
## What is this addin doing ?
This small demo is based on [Azur](https://gitea.planet-casio.com/Lephenixnoir/Azur). It uses its ultra fast rendering pipeline with specific shaders :
- Mandelbrot shader written in ASM by Lephe'
- Julia shader written in C with the libnum fast fixed point arithmetic lib
Keys are :
- [EXIT] to leave to the Operating System
- [F1] to [F4] to show/switch off some informations on the screen :
o [F1] : hide everything
o [F2] : minimal output FPS + rendering time
o [F3] : detailed update/rendering time
o [F4] : memory usage
- [F5]/[F6] : switch fractal mode
o [F5] : set Mandelbrot fractal
o [F6] : set Julia fractal
Both Mandelbrot - *named as per Benoît MANDELBROT (1924-2010)* - and Julia - *named as per Gaston JULIA (1893-1978)* - fractals are based on the convergence determination of the equation `Z_(n+1) = Z_n^2 + C`.
## What can we do ?
Have fun !!!
Control keys are :
[**EXIT**] to leave to the Operating System
[**F1**] to [**F4**] to show/switch off some informations on the screen :
- [ ] [F1] : hide everything
- [ ] [F2] : minimal output FPS + rendering time
- [ ] [F3] : detailed update/rendering time
- [ ] [F4] : memory usage
[**F5**]/[**F6**] : switch fractal mode
- [ ] [F5] : set Mandelbrot fractal
- [ ] [F6] : set Julia fractal
Have fun !!!

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 32 KiB

31
src/julia.s Normal file
View File

@ -0,0 +1,31 @@
/*
int julia(int32_t cr, int32_t ci, uint32_t t_squared, int steps, int32_t zr, int32_t zi);
(Pour moi : t_squared = (2 * 2) << 16, steps = 50)
Si renvoie 0 -> dans la fractale
Sinon renvoie un nombre entre 1...steps indiquant la "distance" (pour le dégradé)
*/
.global _julia
.text
/* Iteration of z = z²+c with threshold checks
@r4 Real part of c, cr
@r5 Imaginary part of c, ci
@r6 Squared threshold t²
@r7 Number of steps
If c is in the set, returns 0. Otherwise, returns the remaining number of
iterations to be checked before the process finised. */
_julia:
mov.l r8, @-r15
mov.l r9, @-r15
mov.l r10, @-r15
mov.l r11, @-r15
.loop:
.end:
rts
nop

View File

@ -83,13 +83,16 @@ void azrp_julia( void )
prof_leave(azrp_perf_cmdgen);
}
extern "C" {
extern int julia(int32_t cr, int32_t ci, uint32_t t_squared, int steps, int32_t zr, int32_t zi);
}
void azrp_shader_julia( void *uniforms, void *comnd, void *fragment )
{
struct command *cmd = (struct command *) comnd;
uint16_t *frag = (uint16_t *) fragment;
int maxiter = 256;
int maxiter = 64;
libnum::num zr, zr2;
libnum::num zi, zi2;
@ -100,18 +103,21 @@ void azrp_shader_julia( void *uniforms, void *comnd, void *fragment )
libnum::num zrsave = cmd->xmin;
libnum::num zisave = cmd->ymax - libnum::num(cmd->current_frag*16)*cmd->yinc;
int u;
int offset = 0;
for( int j=0; j<16; j++)
{
for( int i=0; i<azrp_width; i++ )
{
zr = zrsave;
zi = zisave;
zr2 = zr * zr;
zi2 = zi * zi;
int u=0;
u=0;
while((zr2+zi2)<4 && (u<maxiter))
{
@ -119,7 +125,7 @@ void azrp_shader_julia( void *uniforms, void *comnd, void *fragment )
zr2 = zr * zr;
zi2 = zi * zi;
zr = zr2 - zi2 + cr;
zi = 2*zi*temp + ci;
zi = libnum::num(2)*zi*temp + ci;
u++;
}
@ -167,7 +173,6 @@ void azrp_shader_julia( void *uniforms, void *comnd, void *fragment )
zisave -= cmd->yinc;
offset += azrp_width;
}
cmd->current_frag++;

View File

@ -27,7 +27,7 @@ bool record = false;
bool textoutput = false;
bool exitToOS = false;
#define SCALE_PIXEL 1
#define SCALE_PIXEL 2
#define X_RESOL (DWIDTH / SCALE_PIXEL)
#define Y_RESOL (DHEIGHT / SCALE_PIXEL)

View File

@ -92,7 +92,7 @@ void azrp_shader_mandelbrot( void *uniforms, void *comnd, void *fragment )
struct command *cmd = (struct command *) comnd;
uint16_t *frag = (uint16_t *) fragment;
int maxiter = 60;
int maxiter = 64;
libnum::num zr, zi;