SAJewers wrote:Someone please tell me how the Fog was done in Snow Bits.
Long technical explanation incoming (this isn't sort of a question where you can easily explain what's happening, despite simplicity of a question).
SNES doesn't do alpha transparency, it was too expensive at a time.
However, it did provide ways to approximate it. One of those is pseudo-hires mode, but not too interesting - it essentially did cause SNES to render 512 pixels for each scanline, skipping rendering of every other pixel. This mode was for instance used in Kirby's Dream Land 3. It is not supported by ZSNES (ZSNES is pretty bad, just saying).
Then there were color addition/subtraction modes. SNES renders stuff on two screens (that are distinct from background layers), and you can for instance say that Layer 1 is on sub screen, Layer 2 is on main screen, while sprites are on sub screen too. This is determined by TS and TM properties (also TSW and TMW in windowing area, but that's a different feature). Main screen is drawn over subscreen.
- properties.png (32.4 KiB) Viewed 4935 times
In Super Mario World, level mode determines SNES register values, such as TM and TS. For instance, level mode 00 renders Layer 2 on sub screen, and everything else on main screen. This effectively causes priority on Layer 2 to be ignored.
Or say, level mode 02 (layer 2 with interaction) has TS set 0, which means nothing is rendered on subscreen, and effectively ordering is determined by priorities and layers.
Why does main screen and sub screen does matter. Well, while main screen pixel is being written, a pixel on subscreen was already determined. This allows main screen to do effects basing on that pixel, done in PPU (Pixel Processing Unit). Such effects are available as CGADSUB effects.
CGADSUB hardware register allows PPU to do color math (addition, addition and halve, subtraction, subtraction and halve) while rendering selected layers on main screen (layers that are affected by color addition are specified in the register). Nocash SNES specs explains CGADSUB bits like that:
Code: Select all
7 Color Math Add/Subtract (0=Add; Main+Sub, 1=Subtract; Main-Sub)
6 Color Math "Div2" Half Result (0=No divide, 1=Divide result by 2)
5 Color Math when Main Screen = Backdrop (0=Off, 1=On) ;\
4 Color Math when Main Screen = OBJ/Palette4..7 (0=Off, 1=On) ; OFF: Show
- Color Math when Main Screen = OBJ/Palette0..3 (Always=Off) ; Raw Main,
3 Color Math when Main Screen = BG4 (0=Off, 1=On) ; or
2 Color Math when Main Screen = BG3 (0=Off, 1=On) ; ON: Show
1 Color Math when Main Screen = BG2 (0=Off, 1=On) ; Main+/-Sub
0 Color Math when Main Screen = BG1 (0=Off, 1=On) ;/
So, what does mode 1E do (so called horizontal translucent level)? Well, let's see.
TS = 0x16 = 0b10110 (sprites, Layer 3, Layer 2)
TM = 0x01 = 0b00001 (Layer 1)
CGADSUB = 0x21 = 0b100001 (Color addition on backdrop and BG1)
Okay, but what does that color addition do?
In short? It adds color together, by all of their parts - red, green and blue. Each color on SNES is 5-bit (to fit in 16-bits). So, if you add rgb(1, 2, 3) to rgb(2, 2, 2) you will get rgb(3, 4, 5) back. There is also additional part that if value overflows 5 bits, the maximum value for a given color is used. This is why you don't use translucent color mode with light background on light ground, as then everything becomes really bright (as all colors are close to white).
This however is not color transparency. Consider what happens if you add black to some color? Well, as it happens, something + rgb(0, 0, 0) = something. So essentially, adding black to a color doesn't change it.
What Snowy Bits did is that it did render itself with CGADSUB enabled on Layer 3 (this is vanilla as far Lunar Magic is concerned). Even Lunar Magic says it's CGADSUB, which is surprisingly technical as far stuff in that editor goes.
- cgadsub.png (40.42 KiB) Viewed 4935 times
As I mentioned before, CGADSUB is not true transparency. If you add black to a color, you still stay with color you had. Snowy Bits had palette ExAnimation where the mist color fades to black and back.
SNES also has color subtraction mode which subtracts color, and halve mode that divides the result of color math by two (color addition with halve mode is closer to true alpha transparency, and actually what Ghost Houses in Super Mario World did to have transparent ghosts). Also, you may have noticed that backdrop is affected by color addition too in my example. This is because, well, SNES always renders backdrop on main screen (in addition to sub screen). Main screen backdrop is usually black (fun fact: message boxes in Super Mario World actually reuse main screen backdrop color), which means that after color addition is done, it doesn't hide stuff on sub screen. Without backdrop CGADSUB, nothing on sub screen would be visible.