nesdev.com
http://forums.nesdev.com/

Pattern for Fading out
http://forums.nesdev.com/viewtopic.php?f=2&t=16866
Page 1 of 1

Author:  -Basti- [ Thu Dec 28, 2017 2:52 am ]
Post subject:  Pattern for Fading out

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

Author:  pubby [ Thu Dec 28, 2017 5:36 am ]
Post subject:  Re: Pattern for Fading out

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.

Author:  dougeff [ Thu Dec 28, 2017 6:29 am ]
Post subject:  Re: Pattern for Fading out

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.

Author:  tokumaru [ Thu Dec 28, 2017 10:43 am ]
Post subject:  Re: Pattern for Fading out

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).

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/