Recent

Author Topic: Octopus Tentacles: Bgrabmp ellipse too slow but GL does it  (Read 1603 times)

Boleeman

  • Hero Member
  • *****
  • Posts: 1108
Octopus Tentacles: Bgrabmp ellipse too slow but GL does it
« on: July 29, 2025, 11:42:31 am »
Hi all.

I tried making an octopus tentacles animation but I am finding the movement of the tentacles very sluggish.

The alpha changes as the tentacles sway.

Not sure how to improve the speed of the tentacles movement to make a hypnotic movement?
« Last Edit: July 30, 2025, 03:30:18 pm by Boleeman »

Gigatron

  • Sr. Member
  • ****
  • Posts: 369
  • Amiga Rulez !!
    • Gigatron Shader Network Demo
Re: Octopus Tentacles: Lazarus tentacles too slow
« Reply #1 on: July 29, 2025, 04:03:27 pm »
Hi all.

I tried making an octopus tentacles animation but I am finding the movement of the tentacles very sluggish.

The alpha changes as the tentacles sway.

Not sure how to improve the speed of the tentacles movement to make a hypnotic movement?

Nice @Boleeman

To test the glCanvas quick conversion to gl version of this cool fx;

Regards
Coding faster than Light !

Thaddy

  • Hero Member
  • *****
  • Posts: 18729
  • To Europe: simply sell USA bonds: dollar collapses
Re: Octopus Tentacles: Lazarus tentacles too slow
« Reply #2 on: July 30, 2025, 09:37:19 am »
Nice!
Nice conversion to glcanvas too...
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

Boleeman

  • Hero Member
  • *****
  • Posts: 1108
Re: Octopus Tentacles: Lazarus tentacles too slow
« Reply #3 on: July 30, 2025, 03:29:35 pm »
Wow GigaTron.

Looks like GL is the way to go for Ellipse animations.
That's the exact effect that I was trying to achieve.

For some reasonTBgrabmp does not handle ellipse animations well, but its really good at stationary renders.

Thanks Gigatron.

Boleeman

  • Hero Member
  • *****
  • Posts: 1108
Re: Octopus Tentacles: Bgrabmp ellipse too slow but GL does it
« Reply #4 on: July 30, 2025, 03:52:04 pm »
Actually Gigtron, not sure if you could possibly help with another ellipse animation?

I had another project of a Burning sun that uses ellipses, but it also has Canvas2D to do ctx.Translate(x, y);
Not sure if you could possibly work out how to do it in GL?

The effect should be a really nice trippy burning Sun, but I could not get this to animate properly.

« Last Edit: July 30, 2025, 03:55:37 pm by Boleeman »

Gigatron

  • Sr. Member
  • ****
  • Posts: 369
  • Amiga Rulez !!
    • Gigatron Shader Network Demo
Re: Octopus Tentacles: Bgrabmp ellipse too slow but GL does it
« Reply #5 on: July 30, 2025, 05:16:19 pm »
Actually Gigtron, not sure if you could possibly help with another ellipse animation?

I had another project of a Burning sun that uses ellipses, but it also has Canvas2D to do ctx.Translate(x, y);
Not sure if you could possibly work out how to do it in GL?

The effect should be a really nice trippy burning Sun, but I could not get this to animate properly.

Hi, i have not all gl functions to translate rotate like ctx Canvas2D; but this conversion is not bad i think;

Regards
Coding faster than Light !

Gigatron

  • Sr. Member
  • ****
  • Posts: 369
  • Amiga Rulez !!
    • Gigatron Shader Network Demo
Re: Octopus Tentacles: Bgrabmp ellipse too slow but GL does it
« Reply #6 on: July 31, 2025, 02:50:32 am »
Hi

With the new version of the glcanvas  the code is more understandable and easy,
support of ctx.save, ctx.restore, ctx.translate, ctx.rotate + 3D cubes ;

glSaveMatrix;
glRestoreMatrix;
glTranslateMatrix(rayX, rayY, 0);
glRotateMatrix(-i + rot, 0, 0, 1); // Z rotation   

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  9.   OpenGLContext, Math, glcanvas;
  10.  
  11. type
  12.   { TForm1 }
  13.   TForm1 = class(TForm)
  14.     OpenGLControl1: TOpenGLControl;
  15.     Panel1: TPanel;
  16.     Timer1: TTimer;
  17.     procedure FormCreate(Sender: TObject);
  18.     procedure OpenGLControl1Paint(Sender: TObject);
  19.     procedure Timer1Timer(Sender: TObject);
  20.   private
  21.     num, rot: Single;
  22.   public
  23.   end;
  24.  
  25. var
  26.   Form1: TForm1;
  27.  
  28. implementation
  29.  
  30. {$R *.lfm}
  31.  
  32. { TForm1 }
  33.  
  34. procedure TForm1.Timer1Timer(Sender: TObject);
  35. begin
  36.   OpenGLControl1.Invalidate;
  37. end;
  38.  
  39. procedure TForm1.FormCreate(Sender: TObject);
  40. begin
  41.   glInit(OpenGLControl1);
  42.   if not OpenGLControl1.MakeCurrent then raise Exception.Create('OpenGL context makeCurrent Error');
  43.   num := 0;
  44.   rot := 0;
  45. end;
  46.  
  47. procedure TForm1.OpenGLControl1Paint(Sender: TObject);
  48. var
  49.   i, q: Integer;
  50.   a, d: Single;
  51.   cx, cy: Integer;
  52.   rayX, rayY: Single;
  53. begin
  54.   if not OpenGLControl1.MakeCurrent then Exit;
  55.   glFillScreen(OpenGLControl1, 0.0, 0.0, 0.0, 1.0);
  56.  
  57.   cx := OpenGLControl1.Width div 2;
  58.   cy := OpenGLControl1.Height div 2;
  59.  
  60.   glSaveMatrix;                    // sun
  61.   glTranslateMatrix(cx, cy, 0);
  62.  
  63.   for i := -180 to 179 do
  64.     if i mod 12 = 0 then
  65.     begin
  66.       rayX := sin(DegToRad(i)) * 15;
  67.       rayY := cos(DegToRad(i)) * 15;
  68.  
  69.       glSaveMatrix;
  70.       glTranslateMatrix(rayX, rayY, 0);
  71.       glRotateMatrix(-i + rot, 0, 0, 1); // Z rotation
  72.  
  73.       for q := 0 to 195 do
  74.         if q mod 5 = 0 then
  75.         begin
  76.           d := 40 - (q / 200) * 40;
  77.           a := sin(DegToRad(-i + q + num)) * 2;
  78.           glEllipse(a, q * 1.7, d, d, 20, 1.0, 0.6, 0.0, 0.1, true);
  79.         end;
  80.  
  81.       glRestoreMatrix;    // rays
  82.     end;
  83.  
  84.   glRestoreMatrix;  // sun
  85.   glSaveMatrix;
  86.   glFilled3DCube(OpenGLControl1, -80, 0, 0,  50, 1.0, 1.0, 1.0, 1.0, rot, -rot, rot, 0.0, 0.0, 1.0);
  87.   glWired3DCube(OpenGLControl1,  -80, 0, 0,  50, 1.0,0.0,0.0, 1.0, rot, -rot, rot, 4.0);
  88.   glRestoreMatrix;
  89.   glFilled3DCube(OpenGLControl1, 80, 0, 0, 50, 0.0,0.5,1.0, 1.0, rot, rot, rot, 1.0, 0.0, 0.0);
  90.   glWired3DCube(OpenGLControl1, 80, 0, 0,  50, 0.5,0.5,0.5, 1.0, rot, rot, rot, 4.0);
  91.   num += 11.5;  // deg
  92.   rot += 1.15;  // deg
  93.  
  94.   OpenGLControl1.SwapBuffers;
  95. end;
  96.  
  97. end.

 
Coding faster than Light !

Boleeman

  • Hero Member
  • *****
  • Posts: 1108
Re: Octopus Tentacles: Bgrabmp ellipse too slow but GL does it
« Reply #7 on: July 31, 2025, 10:56:17 am »
Thanks for helping out Gigatron.


I used a := sin(DegToRad(-i + q + num)) * 10; to make the rendering wobble a bit more.
Now need to try to make an alpha trail from the vertices to make it look like heat is coming from it, like a heat trail from the Sun.

I will need to learn a bit more about GL from your latest code.

Wondered if GL also does conic gradient? as TBgrabmp only has linear and radial gradient.

Thanks Gigatron for your help.


 

TinyPortal © 2005-2018