• September 26, 2022, 11:48:00 AM

Author Topic: (Solved) Camera2D rotation and skew  (Read 263 times)

0 Members and 1 Guest are viewing this topic.

Online claude

  • 3f
  • ******
  • Posts: 2269
    • mathr.co.uk
(Solved) Camera2D rotation and skew
« on: August 14, 2019, 11:17:00 PM »
As is known, "hidden treasures" in 2D escape time fractals can be revealed by stretching skewed regions.

I tried implementing this in a frag, but there is a big problem - when the transform is enabled, the mouse interactions don't match up to the image, so sensible navigation is often impossible (the higher the StretchAmount the harder it is, while non-zero RotateAngle adds another smaller layer of confusion).

So, I would need to modify the core FragM Camera2D code. It needs to be automatically enabled for compatible frags with sane defaults (no errors or GUI for frags that don't have those uniforms).

Here's my current Camera2D vertex code:

Code: [Select]
#vertex

out vec2 coord;
out vec2 viewCoord;

#group Camera

uniform float Zoom; slider[0,1,1e16] NotLockable
uniform float ZoomFactor; slider[-100,0,100]
uniform vec2 pixelSize;

uniform bool EnableTransform; checkbox[true]
uniform float RotateAngle; slider[-360,0,360]
uniform float StretchAngle; slider[-360,0,360]
uniform float StretchAmount; slider[-100,0,100]

void main(void)
{
  mat2 transform = mat2(1.0, 0.0, 0.0, 1.0);
  if (EnableTransform)
  {
    float b = radians(RotateAngle);
    float bc = cos(b);
    float bs = sin(b);
    float a = radians(StretchAngle);
    float ac = cos(a);
    float as = sin(a);
    float s = sqrt(pow(2.0, StretchAmount));
    mat2 m1 = mat2(ac, as, -as, ac);
    mat2 m2 = mat2(s, 0.0, 0.0, 1.0 / s);
    mat2 m3 = mat2(ac, -as, as, ac);
    mat2 m4 = mat2(bc, bs, -bs, bc);
    transform = m1 * m2 * m3 * m4;
  }
  float ar = float(pixelSize.y / pixelSize.x);
  coord = transform * ((gl_ProjectionMatrix * gl_Vertex).xy * vec2(ar, 1.0)) / (float(Zoom) * pow(2.0, ZoomFactor));
  viewCoord = gl_Vertex.xy;
  gl_Position =  gl_Vertex;
}

#endvertex
(adding of Center is done in the fragment part).

Thoughts?

Linkback: https://fractalforums.org/index.php?topic=3003.0
« Last Edit: August 25, 2019, 04:25:14 PM by claude, Reason: Prefix to solved as pull request is merged »

Online claude

  • 3f
  • ******
  • Posts: 2269
    • mathr.co.uk
Re: Camera2D rotation and skew
« Reply #1 on: August 15, 2019, 11:07:11 PM »
I modified the core of FragM's Camera2D to support this and made a pull request.

Attached is an unskewed view from under the bow of a mini-ship in DoubleTest.frag with my modifications to the (Progressive)2D(-4).frag code and core.


xx
Camera2D zoom animation

Started by claude on Fragmentarium

0 Replies
259 Views
Last post August 14, 2019, 02:52:55 PM
by claude
xx
Menger sponge and T Rotation Folding

Started by Nintendokater on Fractal movie gallery

1 Replies
228 Views
Last post February 23, 2019, 05:08:29 AM
by Tas_mania
question
(solved) Where to find the adjustment slide?

Started by sallymp3951 on Noob's Corner

0 Replies
647 Views
Last post November 23, 2021, 01:58:39 PM
by sallymp3951
question
[Solved] Color interpolation

Started by galac on Programming

5 Replies
778 Views
Last post March 02, 2019, 08:03:11 AM
by mclarekin
xx
Rotation Mutation (0.0.1)...

Started by Chris_M_Thomasson on Fractal movie gallery

2 Replies
103 Views
Last post June 19, 2022, 12:54:20 AM
by Chris_M_Thomasson