Color Wheel (~400 colors, low-res and hi-res)

For Scene Demos that display animations, graphics, and music. Also for tech demos of graphics capability of VERA or the audio capabilities of the PSG, FM, or PCM audio channels.
Post Reply
Jeffrey
Posts: 57
Joined: Fri Feb 19, 2021 9:46 am

General - CX16 Color Wheel (~400 colors, low-res and hi-res)

Post by Jeffrey »

This is a demo showing a colorwheel with around 400 colors.

# Low res screenshot
low-res_screenshot.png
low-res_screenshot.png (23.97 KiB) Viewed 1785 times
# High res screenshot
high-res_screenshot.png
high-res_screenshot.png (27.42 KiB) Viewed 1785 times
This was done by re-creating the original image by re-drawing all polygons (diamonds) and sorting all colors from top to bottom (which is 396 colors excluding black and white). Then re-arrange the color indexes so that the top 142 polygons and the bottom 142 polygons share the same palette indexes.

This is then loaded into VRAM and (for each frame) when the scanline is at the middle of the screen the 142 palette entries are changed on-the-fly. At the end of the frame it is changed back again.

For the high-res version (640x480) two tilemaps are used: L0 for the first 18 row of (16x16px) tiles and L1 for the remaining rows, by re-using the tiles at the top (but v-flipping them).

This then creates a nice and colorful image on the X16 that would normally not be possible to show. No dithering was needed.
Attachments
color_wheel_src.zip
(1.09 MiB) Downloaded 354 times
WHEEL-LORES.zip
(6.93 KiB) Downloaded 349 times
WHEEL-HIRES.zip
(12.76 KiB) Downloaded 347 times
Last edited by Jeffrey on Mon Feb 05, 2024 10:34 am, edited 2 times in total.
Jeffrey
Posts: 57
Joined: Fri Feb 19, 2021 9:46 am

Re: Color Wheel (~400 colors, low-res and hi-res)

Post by Jeffrey »

To give you an idea what are the top and bottom 142 polygons look here:
image-6.png
image-6.png (54.44 KiB) Viewed 2127 times
The top 142 yellow polygons share the same palette indexes as the bottom cyan polygons. In the gap between them, the palette is modified each frame. And at the end of each frame (so below the cyan polygons) the palette is changed back again.

The difficulty/challenge with the hi-res version is that the pixels needed to be exactly the same for the top and bottom polygons, so tiles could be used that were flipped, since a bitmap of 640x480 @ 8bpp is impossible on VERA (not enough vram). But that was tricky because those polygons had to be sorted in reseverse while still correctly attaching to the middle polygons.

Anyway. It is more tricky than it looks ;)
User avatar
desertfish
Posts: 1075
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Re: Color Wheel (~400 colors, low-res and hi-res)

Post by desertfish »

How did you draw the polygons?
Jeffrey
Posts: 57
Joined: Fri Feb 19, 2021 9:46 am

Re: Color Wheel (~400 colors, low-res and hi-res)

Post by Jeffrey »

desertfish wrote: Mon Jan 29, 2024 7:31 pm How did you draw the polygons?
I drew them in Python (pygame) first to re-create the original image/bitmap. Then I tiled it so the X16 could fit it into vram.

This was to make sure that I had 396 colors. The problem with the original image is that its basicly a jpeg with many thousands of colors. I first tried to reduce those colors, but was getting bad results. So I ended up redrawing the image myself. Which also have me great control over the order of the polygons/colors.

As to how: I figured out that each diamond had the same length on each side. And each circle/layer of diamonds consisted of 36 evenly distributed polygons: every 10 degrees.

As it turns out, what I had to do is first to create 11 layers of 36 points. You start with middle point as first "layer" then the inner layer (simply 36 points around this middle point).

Each next layer of points is then created by doing this:

- you are at a certain angle (out of 36) and you want to create a new point in layer n
- you take the point at layer n-2 at the same angle (this is your base point)
- you take the 2 points that are closest to that angle (both 5 degrees away from your angle: one left the other right) in layer n-1.
- this basicly gives you 2 vectors: base->left and base->right vector.
- you add those 2 vectors and add that new vector to your base point. You now have your new point.
- you iterate to the next angle

You then use all these points to create all of the diamonds and color them (which, for now, I still pick from the original image).
voidstar
Posts: 448
Joined: Thu Apr 15, 2021 8:05 am

Re: Color Wheel (~400 colors, low-res and hi-res)

Post by voidstar »

Does this override the interrupt handler, or use $0400 - $07FF for anything in particular?

Running it seems to stop my own handler, so was just curious.
Post Reply