A.D.A. Amiga Demoscene Archive

        Welcome guest!

  

  

  

log in with SceneID

  

Demos Amiga Demoscene Archive Forum / Coding / Sanity / Roots rotozoom (again)

 

Author Message
kuro
Member
#1 - Posted: 8 Jun 2016 12:37
Reply Quote
Following on from this thread: http://ada.untergrund.net/?p=boardthread&id=134

I'm determined to understand the 256x256 rotozoom from Roots 2.0. It's 1x1 pixel, 1 frame and uses a 16x16 texture. One thing I noticed, that others didn't seem to, there is a perspective effect. If you look when zoomed far out at the start, the texture is a little larger in the centre of the screen than at the edges, which are further away from the viewer.

We know this isn't a C2P routine, it uses pre-calculated bitplanes. Maybe I need to rip them from memory for examination, along with the copper list. It's interesting that the routine is 256x256 and not 320x256, since there should be no real limit on the size due to chip mem bandwidth etc. My guess is that it's a memory constraint, due to the size of the pre-calculated data.

Let's think this through, starting with a 1 bitplane effect, working with a checkboard. Y zooming is trivial, just use the copper to skip/repeat scanlines. X zooming is trivial, just use the copper to pick a different pre-calculated line depending on the zoom level.

How about rotation? As Kalms points out in that thread, the maths are not hard to understand. Calculate the starting point at the far left for each scan line, and the delta X/Y for each pixel. But how do you do that with bitmaps?

Consider that the ratio of 1 to 0 pixels has to change when the image is rotated. Imagine a 45 degree rotation of our checkboard. It looks like this:


000010000000010000
000111000000111000
001111100001111100
011111110011111110
111111111111111111
011111110011111110
001111100001111100
000111000000111000
000010000000010000


(this is zoomed out somewhat)

So you need pre-calculated bitmaps with the different ratios of 1/0 bits, at different zoom levels... There will be some repetition, so maybe you can do a LUT to cut down the number of lines you store. Oh, but there is the perspective effect, so I'm not sure.

Still, it's going to be a lot... For smooth zooming and rotation you will need say 256 zoom levels, 256 possible angles. You only really need 1/8th of the angles if you do some horizontal shifting, so say 32. Each scanline is 32 bytes + 4 for shifting.

36 * 256 * 32 = 288k. Okay, that's not too bad.

Does this seem right? I'm not sure about the 1/8th thing for angles, I need to test it. And then think about how to extend it to more bitplanes, which should be possible just by combining zoom levels. might need more than 256 levels though.

Maybe a better way to think of it is not in terms of angles and zoom levels, but of 1 to 0 ratios. You calculate that ratio per line, and then each bitplane is just the previous ratio / 2. How many ratios do you need to pre-calc to get a smooth effect? It moves so fast small errors won't be too noticeable I think.
kuro
Member
#2 - Posted: 8 Jun 2016 13:02
Reply Quote
Oh yeah, and the other hint is, you can't scroll bitplanes individually. So maybe that explains why the camera doesn't move on the X or Z axis. In fact, it doesn't exactly move on the Y axis either... When it rotates about X, you notice that when level the "ceiling" is the same distance away as the floor. It's more like just zooming with a fixed lens.

The genius of Chaos is making it look like it moves, and distracting you by introducing zooming and then rotation on Y and finally on X one at a time, followed by some texture fades.
Blueberry
Member
#3 - Posted: 15 Jun 2016 22:49
Reply Quote
Here is my guess:

Imagine you are zooming and rotating (around two axes, like in the demo) a one-dimensional, repeating, 16-color gradient. Any one scanline of that will then just be a scaled and shifted version of the gradient. I.e. when the gradient is horizontal (vertical lines), then the scanline gradient will have the same scale as the zoom factor. When the gradient is vertical (horizontal lines), the scanline gradient will be scaled to infinity. In general it will be scaled by zoom/sin(v) where v is the gradient's angle from vertical.

Thus, you can make such a zoomed and rotated gradient by precalculating differently zoomed scanline versions of the gradient and then selecting and shifting the right one for each scanline.

Now put two of those gradients - one in the odd bitplanes and one in the even bitplanes - rotated 90 degrees from each other. Because you can shift the odd and even bitplanes separately, this is possible. You will then have your 256 color zoomed and rotated color block - putting your texture into the palette.

 

  Please log in to comment

  

  

  

 

A.D.A. Amiga Demoscene Archive, Version 3.0