This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Pattern for Fading out

Pattern for Fading out
by on (#210849)
Hello everyone,
I am looking for a pattern for fading out a whole background smoothly. I fooled around a bit with the color bits of PPU_MASK, but without any result.
Since the background I want to fade out only contians white letters on black ground, my next approach will be to change the color palette step by step
to darker greyish colors.
Anyway, I guess there is a more efficient way to fade out backgrounds. Can anybody help? I would appreciate example code in C since I did not make the step to assembly, yet.

Regards Sebastian
Re: Pattern for Fading out
by on (#210851)
You can darken a palette entry by subtracting 16 from its value. If the result is negative, set it to black (0x0F).

Do this to each palette entry repeatedly and you have a fade-out effect.
Re: Pattern for Fading out
by on (#210852)
Yes. keep a copy of the active palette in RAM and keep changing it.

Or use the neslib, which has a brightness function. (and a delay function). have a loop which delays a bit, darken by 1, repeat till 0.
Re: Pattern for Fading out
by on (#210864)
Fading on the NES is indeed accomplished by darkening/brightening the palette over time. The challenge is to do it smoothly when there are only 4 levels of brightness to work with. The color emphasis bits can be used to create intermediary steps if you turn all 3 bits on, since that darkens the palette slightly, but this trick backfires on RGB PPUs, where turning all 3 color emphasis bits on makes the screen completely white.

Another way to create smoother fading sequences is to animate the hue in addition to the brightness: slide towards blue when fading to black, towards yellow when fading to white.

One more technique that worked reasonably well for me is to stagger the brightness changes, instead of changing all colors at once: when fading out, only darken the $0x colors, making them black. On the next step, darken only colors $1x, making them $0x. Then darken $2x, then finally $3x, so what took just 1 frame with the typical "subtract $10" technique, takes 4 frames with the staggered method. The next round of updates has only 3 steps, since there are no $3x colors anymore, and each round has fewer steps, but in the end you have a 4 + 3 + 2 + 1 = 10-step fade sequence instead of a 4-step one, and it does look smoother (as long as the image contains colors of varied brightness levels).