Compare commits

...

4 Commits

7 changed files with 117 additions and 30 deletions

View File

@ -2,26 +2,48 @@
## 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
This small demo is based on [Azur](https://gitea.planet-casio.com/Lephenixnoir/Azur). It uses its ultra fast rendering pipeline with specific a specific high speed quadratic calculation algorithm written by Lephenixnoir a,d able to handle both :
- Mandelbrot's set calculations : `Z_(n+1) = Z_n^2 + C` with `Z_0 = 0 + 0 i` and `C` covering the complex plan
![image](https://gitea.planet-casio.com/Slyvtt/MandAzur/src/branch/master/images/fxlink-image-2023.01.19-20h38-1.png)
- Julia's set calculations : `Z_(n+1) = Z_n^2 + C` with `C = A + B i` and `Z_n` covering the complex plan
![image](https://gitea.planet-casio.com/Slyvtt/MandAzur/src/branch/master/images/fxlink-image-2023.01.19-20h38-2.png)
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 ?
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
[**OPTN**]/[**VARS**] : switch resolution
- [ ] [OPTN] : set resolution scale to 1, the fractals are computed on a 396x224 grid
- [ ] [VARS] : set resolution scale to 0.5 (2x2 pixels), the fractals are computed on a 198x112 grid (much faster but lower quality)
Have fun !!!
- [**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
- [**OPTN**]/[**VARS**] : switch resolution
- [OPTN] : set resolution scale to 1, the fractals are computed on a 396x224 grid
- [VARS] : set resolution scale to 0.5 (2x2 pixels), the fractals are computed on a 198x112 grid (much faster but lower quality)
For the Julia set only :
- [**SHIFT**]+[**Directional Cross**] : change the value of the C value (`C = A + B i`)
- [**SHIFT+LEFT**] : A = A - 0.002
- [**SHIFT+RIGHT**] : A = A + 0.002
- [**SHIFT+DOWN**] : B = B - 0.002
- [**SHIFT+UP**] : B = B + 0.002
A and B are constrained in the range [-2.000 .. 2.000]
If you have a running session of `fxlink` :
- [**7**] to [**9**] to export the calculator screen to fxlink :
- [**7**] : take a screenshot
- [**8**] : start video output (not : this is just rendered in a SDL2 window, not recorded, OBS/ffmpeg may be your very best friends to do so)
- [**9**] : stop video output
Have fun !!!

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -6,7 +6,7 @@ void azrp_mandelbrot_init( void );
void azrp_mandelbrot_close( void );
void azrp_mandelbrot_USBDEBUG( void );
void azrp_julia( void );
void azrp_julia( float cr, float ci );
void azrp_julia_init( void );
void azrp_julia_close( void );
void azrp_julia_USBDEBUG( void );

View File

@ -58,12 +58,14 @@ struct command {
libnum::num xmax;
libnum::num ymin;
libnum::num ymax;
libnum::num cr;
libnum::num ci;
libnum::num xinc;
libnum::num yinc;
};
void azrp_julia( void )
void azrp_julia( float cr, float ci )
{
prof_enter(azrp_perf_cmdgen);
@ -77,6 +79,9 @@ void azrp_julia( void )
cmd.ymax = libnum::num(1.12f);
cmd.xinc = libnum::num((2*1.98f)/azrp_width);
cmd.yinc = libnum::num((2*1.12f)/azrp_height);
cmd.cr = libnum::num(cr);
cmd.ci = libnum::num(ci);
int fragmin = 0;
int fragcount = (azrp_height >> 4) + 1;
@ -84,9 +89,6 @@ 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 )
{
@ -98,8 +100,8 @@ void azrp_shader_julia( void *uniforms, void *comnd, void *fragment )
libnum::num zr, zr2;
libnum::num zi, zi2;
libnum::num cr = libnum::num(-0.480f);
libnum::num ci = libnum::num(0.600f);
libnum::num cr = cmd->cr;
libnum::num ci = cmd->ci;
libnum::num zrsave = cmd->xmin;
libnum::num zisave = cmd->ymax - libnum::num(cmd->current_frag*16)*cmd->yinc;

View File

@ -35,6 +35,7 @@ int SCALE_PIXEL=2;
uint8_t texttodraw=2;
uint8_t Mandel_Julia_Switch = 1;
float Cr, Ci;
void do_nothing( void )
@ -48,6 +49,40 @@ static void update( float dt )
}
static void hook_prefrag(int id, void *fragment, int size)
{
if(!screenshot && !record)
return;
/* Screenshot takes precedence */
char const *type = screenshot ? "image" : "video";
int pipe = usb_ff_bulk_output();
if(id == 0) {
usb_fxlink_header_t h;
usb_fxlink_image_t sh;
int size = azrp_width * azrp_height * 2;
usb_fxlink_fill_header(&h, "fxlink", type, size + sizeof sh);
sh.width = htole32(azrp_width);
sh.height = htole32(azrp_height);
sh.pixel_format = htole32(USB_FXLINK_IMAGE_RGB565);
usb_write_sync(pipe, &h, sizeof h, 4, false);
usb_write_sync(pipe, &sh, sizeof sh, 4, false);
}
usb_write_sync(pipe, fragment, size, 4, false);
if(id == azrp_frag_count - 1) {
usb_commit_sync(pipe);
screenshot = false;
}
}
static void get_inputs( void )
{
key_event_t ev;
@ -56,13 +91,14 @@ static void get_inputs( void )
}
if(keydown(KEY_SHIFT)) { }
if(keydown(KEY_EXIT)) {exitToOS = true; };
if(keydown(KEY_7)) {screenshot = true;};
if(keydown(KEY_8)) {record = !record; };
if(keydown(KEY_9)) {textoutput = true;};
if(keydown(KEY_8)) {record = true; };
if(keydown(KEY_9)) {record = false; };
if(keydown(KEY_DEL)) {textoutput = true;};
if(keydown(KEY_OPTN))
{
@ -72,6 +108,7 @@ static void get_inputs( void )
azrp_shader_image_rgb16_configure();
azrp_shader_image_p8_configure();
azrp_shader_image_p4_configure();
azrp_hook_set_prefrag(hook_prefrag);
azrp_mandelbrot_init();
azrp_julia_init();
@ -85,11 +122,32 @@ static void get_inputs( void )
azrp_shader_image_rgb16_configure();
azrp_shader_image_p8_configure();
azrp_shader_image_p4_configure();
azrp_hook_set_prefrag(hook_prefrag);
azrp_mandelbrot_init();
azrp_julia_init();
};
if(Mandel_Julia_Switch==2)
{
if(keydown(KEY_SHIFT) && keydown(KEY_LEFT))
{
if(Cr>-2.0f) Cr-=0.002;
}
else if(keydown(KEY_SHIFT) && keydown(KEY_RIGHT))
{
if(Cr<2.0f) Cr+=0.002;
}
else if(keydown(KEY_SHIFT) && keydown(KEY_DOWN))
{
if(Ci>-2.0f) Ci-=0.002;
}
else if(keydown(KEY_SHIFT) && keydown(KEY_UP))
{
if(Ci<2.0f) Ci+=0.002;
}
}
if(keydown(KEY_F1)) {texttodraw=0;}
if(keydown(KEY_F2)) {texttodraw=1;}
if(keydown(KEY_F3)) {texttodraw=2;}
@ -101,6 +159,10 @@ static void get_inputs( void )
int main(void)
{
Cr = -0.480f;
Ci = 0.600f;
exitToOS = false;
float elapsedTime = 0.0f;
@ -115,6 +177,7 @@ int main(void)
azrp_shader_image_rgb16_configure();
azrp_shader_image_p8_configure();
azrp_shader_image_p4_configure();
azrp_hook_set_prefrag(hook_prefrag);
azrp_mandelbrot_init();
azrp_julia_init();
@ -153,10 +216,11 @@ int main(void)
azrp_clear( C_BLACK );
if (Mandel_Julia_Switch==1) azrp_mandelbrot();
else if(Mandel_Julia_Switch==2) azrp_julia();
else if(Mandel_Julia_Switch==2) azrp_julia(Cr,Ci);
else do_nothing();
if (texttodraw>=1) Azur_draw_text(1,01, " FPS = %.0f - Render = %.0f", (float) (1000000.0f / elapsedTime), (float) time_render / 1000.0f );
if (texttodraw>=1 && Mandel_Julia_Switch==2) Azur_draw_text(1,11, " Cr = %.3f - Ci = %.3f", Cr, Ci );
if (texttodraw>=2) Azur_draw_text(1,31, "Update = %.0f mc secs", (float) time_update );
if (texttodraw>=2) Azur_draw_text(1,41, "Render = %.0f mc secs", (float) time_render );
if (texttodraw>=2) Azur_draw_text(1,51, ">Total = %.3f ml secs", (float) elapsedTime / 1000.0f );
@ -173,6 +237,7 @@ int main(void)
elapsedTime = ((float) (time_update+time_render));
/*
if (screenshot && usb_is_open())
{
usb_fxlink_screenshot(false);
@ -183,6 +248,7 @@ int main(void)
{
usb_fxlink_videocapture(false);
}
*/
if (textoutput && usb_is_open())
{

View File

@ -84,9 +84,6 @@ void azrp_mandelbrot( void )
prof_leave(azrp_perf_cmdgen);
}
extern "C" {
extern int mandelbrot(int32_t cr, int32_t ci, uint32_t t_squared, int steps);
}
void azrp_shader_mandelbrot( void *uniforms, void *comnd, void *fragment )
{