It is currently Sun Jan 21, 2018 9:51 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Pattern for Fading out
PostPosted: Thu Dec 28, 2017 2:52 am 
Offline
User avatar

Joined: Sun Sep 26, 2010 10:29 pm
Posts: 40
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


Top
 Profile  
 
PostPosted: Thu Dec 28, 2017 5:36 am 
Offline
User avatar

Joined: Thu Mar 31, 2016 11:15 am
Posts: 240
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.


Top
 Profile  
 
PostPosted: Thu Dec 28, 2017 6:29 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1910
Location: DIGDUG
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.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Thu Dec 28, 2017 10:43 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10232
Location: Rio de Janeiro - Brazil
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).


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group