Use of flickering in games is usually used to simulate transparency, not flickering.
That works at 60fps, but at 30fps it isn't right.
My idea was to blend one frame effects into two frame effects.
Making a 60fps clip which is safe to reduce to 30fps.
Still plenty of artifacts, but I think it is a step in the right direction, do you agree?
http://www.youtube.com/watch?v=tjrRqrOQ1O8http://www.mediafire.com/?3l6x53xq9999q8m
function deblink(clip clp){
# blend on the frame it blinks in and out
blink=clp.ng_blinkmask_new
blink2=mt_logic(blink.selectevery(1,-1), blink, mode="or").converttorgb32
layer(clp, clp.trim(1,0).mask(blink2), level=127)
}
function ng_blinkmask_new(clip c,int "ml"){
ml=default(ml,128)
src=c.ConvertToYv12
super=MSuper(src, pel=1)
fvec =MAnalyse(super, isb=false, blksize=4)
bvec =MAnalyse(super, isb=true , blksize=4)
fmask=Mmask(src,fvec,kind=1,ml=ml).mt_binarize(u=-128,v=-128)
bmask=Mmask(src,bvec,kind=1,ml=ml).mt_binarize(u=-128,v=-128)
eo0_to =fmask.selectevery(2,1)
oe_from=bmask.selectevery(2,1)
front =mt_logic(eo0_to,oe_from,mode="and")
oe_to =fmask.selectevery(2,2)
eo_from=bmask.selectevery(2,2)
back =mt_logic(oe_to,eo_from,mode="and")
ee_src=src.selecteven
ee_super=MSuper(ee_src, pel=1)
ee_fvec =MAnalyse(ee_super, isb=false, blksize=4)
ee_bvec =MAnalyse(ee_super, isb=true , blksize=4)
ee_fmask=Mmask(ee_src,ee_fvec,kind=1,ml=ml).mt_binarize(u=-128,v=-128)
ee_bmask=Mmask(ee_src,ee_bvec,kind=1,ml=ml).mt_binarize(u=-128,v=-128)
ee_to =ee_fmask.trim(1,0)
ee_from=ee_bmask
ee =mt_logic(ee_to,ee_from,mode="or")
oo_src=src.selectodd
oo_super=MSuper(oo_src, pel=1)
oo_fvec =MAnalyse(oo_super, isb=false, blksize=4)
oo_bvec =MAnalyse(oo_super, isb=true , blksize=4)
oo_fmask=Mmask(oo_src,oo_fvec,kind=1,ml=ml).mt_binarize(u=-128,v=-128)
oo_bmask=Mmask(oo_src,oo_bvec,kind=1,ml=ml).mt_binarize(u=-128,v=-128)
oo_to =oo_fmask.trim(1,0)
oo_from=oo_bmask
oo =mt_logic(oo_to,oo_from,mode="or")
#to e0-o1, from o1-e2, nothing e0-e2
even_blink=mt_logic(front,ee.mt_invert,mode="and")
#to o1-e2, from e2-o3, nothing o1-o3
odd_blink =mt_logic(back,oo.mt_invert,mode="and")
blinkmask=interleave(even_blink, odd_blink)
return blinkmask
}
I don't think I agree with this. It's been a while, but I did play some classic console games on conventional CRT TVs back in the day. When my dude took damage, I flickered. Now, I wasn't doing careful observation, nor was I comparing with frame advance in an emulator to know which flicker pattern I was supposed to be observing (there are so many), but I think the expected user viewing result with a lot of these flicker patterns was in fact flicker.
Joined: 4/17/2010
Posts: 11473
Location: Lake Chargoggagoggmanchauggagoggchaubunagungamaugg
This almost made my cry the tears of happiness! Finally we can get really close to cheating this ugly yutube and displaying on it ALL motion and "transparency" we see on emulators, yay!
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
To me, at 60fps, "on one, off one" looks like transparency and "on two, off two" looks like flickering.
Changing both to "on one, off one" at 30fps is the wrong thing to aim for IMO.
If you download the roadrunner clip it has the three side by side (on/off, 60fps, blended). I think the blended looks more like the 60fps, would you disagree?
I would disagree, but that's not necessarily relevant, as I admit the 60fps flicker probably looked different on a CRT TV 20 years ago than it does on my LCD today.
I find this all very frustrating because of course there's an obvious best solution: stick with original 60fps. I hate youtube ><
I'd say there are definitely examples were 30Hz flickering was used for transparency, e.g. the water surface in Sonic games or Zelda:L.A.'s credits.
And I guess that most developers intended the flickering to be perceived as transparency even when the player was hit.
Joined: 4/17/2010
Posts: 11473
Location: Lake Chargoggagoggmanchauggagoggchaubunagungamaugg
One sees blinking either if it's not 30Hz blinking, or not ~60 Hz monitor (consider that the original TVs weren't exactly 60/50fps, as well as the consoles). The same goes to 25-50Hz.
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
Joined: 6/25/2007
Posts: 732
Location: Vancouver, British Columbia, Canada
Yes. If {1 frame off, 1 frame on} at 60 fps looks like transparency to you, your monitor sucks. Get a monitor with a lower response time. The one on the left looks far better to me. The one on the right just looks wrong, as there's no flicker, unlike the original.
Joined: 4/17/2010
Posts: 11473
Location: Lake Chargoggagoggmanchauggagoggchaubunagungamaugg
Lex wrote:
nanogyth wrote:
natt wrote:
but I think the expected user viewing result with a lot of these flicker patterns was in fact flicker.
To me, at 60fps, "on one, off one" looks like transparency and "on two, off two" looks like flickering.
Changing both to "on one, off one" at 30fps is the wrong thing to aim for IMO.
If you download the roadrunner clip it has the three side by side (on/off, 60fps, blended). I think the blended looks more like the 60fps, would you disagree?
Yes. If {1 frame off, 1 frame on} at 60 fps looks like transparency to you, your monitor sucks. Get a monitor with a lower response time. The one on the left looks far better to me. The one on the right just looks wrong, as there's no flicker, unlike the original.
I turned my monitor's framerate from 75 to 60 just to see retro games as they must look.
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
Here's a comparison of several algorithms. (One I could've included but forgot was the simple SelectEven...)
What I noticed is that Deblink doesn't show shaking in the exploding-Mother-Brain scene of the intro, so there's still no single algorithm for everything.
If {1 frame off, 1 frame on} at 60 fps looks like transparency to you, your monitor sucks.
Yes, that is definitely a possibility =_=
creaothceann wrote:
nanogyth wrote:
Still plenty of artifacts, but I think it is a step in the right direction
Do you think they're too obvious or that you can fix them? If not then it could be added to the site as an alternative to 50/50 blending and TASBlend.
It is an imperfect solution to a hard problem. A useful tool that can complement the others, but not something which should be blindly applied in all situations.
First thing to add is functionality similar to TASblend
function deblink2(clip clp, float "ratio"){
ratio = default(ratio, 2.0 / 3)
opacity1 = round((1 - ratio) * 257)
opacity2 = round(( ratio) * 257)
# blend on the frame it blinks in and out
blink=clp.ng_blinkmask_new
blink2=mt_logic(blink.selectevery(1,-1), blink, mode="or").converttorgb32
even = layer(clp, clp.trim(1,0).mask(blink2), level=opacity1)
odd = layer(clp, clp.trim(1,0).mask(blink2), level=opacity2)
interleave(even.selectevery(4,0),even.selectevery(4,1),
\ odd.selectevery(4,2),odd.selectevery(4,3))
}
That seems to work pretty well. Can slide between no flicker at .5 and full flicker at 1.0
Then there are some issues with the blinkmask not picking up all the motion. (roadrunners toes get chopped off)
function deblink3(clip clp, float "ratio", int "radius"){
radius = default(radius, 1)
ratio = default(ratio, 2.0 / 3)
opacity1 = round((1 - ratio) * 257)
opacity2 = round(( ratio) * 257)
# blend on the frame it blinks in and out
blink=clp.ng_blinkmask_new
blink2=mt_logic(blink.mt_expand(mode=mt_circle(radius)), clp.shake, mode="and")
blink3=mt_logic(blink, blink2, mode="or")
blink4=mt_logic(blink3.selectevery(1,-1), blink3, mode="or")
masked_clp=clp.trim(1,0).mask(blink4.converttorgb32)
even = layer(clp, masked_clp, level=opacity1)
odd = layer(clp, masked_clp, level=opacity2)
interleave(even.selectevery(4,0),even.selectevery(4,1),
\ odd.selectevery(4,2),odd.selectevery(4,3))
}
function shake(clip c){
e0=c.selectevery(1,0)
o1=c.selectevery(1,1)
e2=c.selectevery(1,2)
mt_logic(ng_diff(e0,o1),ng_same(e0,e2),mode="and")
}
function ng_diff(clip A, clip B, int "thr"){
thr=default(thr,0)
TAD=ng_TAD(A,B)
return mt_binarize(TAD, threshold=thr)
}
function ng_same(clip A, clip B, int "thr"){
thr=default(thr,0)
TAD=ng_TAD(A,B)
return mt_binarize(TAD, threshold=thr, upper=true)
}
function ng_TAD(clip A, clip B){
R=ng_AD(A .showRed("YV12"),B .showRed("YV12"))
G=ng_AD(A.showGreen("YV12"),B.showGreen("YV12"))
B=ng_AD(A .showBlue("YV12"),B .showBlue("YV12"))
return ng_plus(R, ng_plus(G, B))
}
function ng_AD(clip A, clip B){
return mt_lutxy(A,B,"x y - abs")
}
function ng_plus(clip A, clip B){
return mt_lutxy(A,B,"x y +")
}
What I noticed is that Deblink doesn't show shaking in the exploding-Mother-Brain scene of the intro, so there's still no single algorithm for everything.
Yah, frustration over that scene is why I gave up working on this stuff the last time.
It is in black/white (so color is no help for matching), the intensity changed with time, and the shake pattern skips a frame in the middle =_=
function deblink4(clip c, ...) {
c
s = ng_DetectScene
return (s == "SNES Super Metroid Intro Mother Brain") ? ng_SNES_Super_Metroid_Intro_Mother_Brain
\: (s == #... ... ...
}
function ng_DetectScene(clip c) {
#... ... ...
}
function ng_SNES_Super_Metroid_Intro_Mother_Brain(clip c) {
c.TASBlend
}
I think Deblink is better when set to full transparency (and better than TASBlend except in a few cases). Only one case in Super Metroid comes to mind where I think the 1-on-1-off pattern is meant to simulate flickering: the title screen. The elevator and the hit effect is for transparency and the flickering of the stars in the space cutscenes is for darkening, imo.
Another example: Chrono Trigger uses 1-on-1-off for transparency (lightning) and 2-on-2-off for flickering (underground sewer).
Joined: 4/17/2010
Posts: 11473
Location: Lake Chargoggagoggmanchauggagoggchaubunagungamaugg
nanogyth:
Please provide the latest version of new deblink script so that I may add it to my main script. I mean formulate it to make it possible to just apply it to AVISource and pull the result via "return last".
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
I think this is the latest version I have. Just copy the functions Deblink and ng_BlinkMask, and call Deblink in your script.
"return last" should almost never be required, and when it is (if your script ends with a comment) you can just put "last" there.
http://pastebin.com/zV5tZEU4
deblink3 is flashy, deblink4 is softer, deblink4(0.5) is the softest.
Depends what you're trying to highlight, flashy is good for damage, soft is good for transparency. (deblink3=deblink4(1.0) but faster)
This youtube was made with deblink3
http://www.youtube.com/watch?v=PYhA56CTzO0
I like deblink as returning a 60fps clip so that you can choose between selecteven or selectodd, because sometimes one looks better than the other.
Joined: 4/17/2010
Posts: 11473
Location: Lake Chargoggagoggmanchauggagoggchaubunagungamaugg
I am going to encode Sonic.
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
Joined: 4/17/2010
Posts: 11473
Location: Lake Chargoggagoggmanchauggagoggchaubunagungamaugg
"I don't know what "m23" means", line 28. Deblink 3 works okay.
Also, I thought to use you partial blending method. Both selectodd and selecteven with deblink3 look rather bad.
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.