YesNoOk
avatar

Blur effect for sprites that are scaled in game. (Read 17987 times)

Started by inktrebuchet, December 18, 2018, 05:46:17 pm
Share this topic:
Blur effect for sprites that are scaled in game.
#1  December 18, 2018, 05:46:17 pm
  • ****
    • USA
    • twitter.com/inktrebuchet
I decided to make this after looking at some KOF13 screenshots. The sprites are scaled in game but have a blurry look to them, something MUGEN doesn't do. *This was more for fun than a serious piece of code, sprites look best with no blur in my opinion.

Example of KOFXIII sprite in game:




There is a SprPriority sctrl in this code that should really be controlled by a root var that controls all SprPriority. This would ensure the effect is always 1 layer above the player. Current code has the effect turn off during custom states, this could be changed for full games.

There are 3 versions of the blur effect(check "config" section), each scales according to the constants part of cns, examples:
xscale = 1  ; No blur
xscale = 1.2  ; slight blur
xscale = 1.5  ; Max blur
xscale = 1.8  ; slight blur

Spoiler: screenshot (click to see content)

This goes in [statedef -3]
Code:
;========================================================
;blur
;========================================================
[state -3, blur x1]
type = helper
trigger1 = ceil(Const(size.xscale)) != Const(size.xscale)
trigger1 = !numhelper(9999991)
name = "blur x1"
ID = 9999991
stateno = 786847
postype = p1
ownpal = 1
keyctrl = 0
supermovetime = 2147483647
pausemovetime = 2147483647
ignorehitpause = 1

[state -3, blur x2]
type = helper
trigger1 = ceil(Const(size.xscale)) != Const(size.xscale)
trigger1 = !numhelper(9999992)
name = "blur x2"
ID = 9999992
stateno = 786847
postype = p1
ownpal = 1
keyctrl = 0
supermovetime = 2147483647
pausemovetime = 2147483647
ignorehitpause = 1

[state -3, blur y1]
type = helper
trigger1 = ceil(Const(size.yscale)) != Const(size.yscale)
trigger1 = !numhelper(9999993)
name = "blur y1"
ID = 9999993
stateno = 786847
postype = p1
ownpal = 1
keyctrl = 0
supermovetime = 2147483647
pausemovetime = 2147483647
ignorehitpause = 1

[state -3, blur y2]
type = helper
trigger1 = ceil(Const(size.yscale)) != Const(size.yscale)
trigger1 = !numhelper(9999994)
name = "blur y2"
ID = 9999994
stateno = 786847
postype = p1
ownpal = 1
keyctrl = 0
supermovetime = 2147483647
pausemovetime = 2147483647
ignorehitpause = 1




This goes in CNS
Code:
;==========================================================================
;[Info]
;author = "Inktrebuchet"
;versiondate = 12/18/2018 
;==========================================================================
;goal = Create blur effect for scaled sprites. Inspired by KOFXIII scaled in game sprites.
;
;==========================================================================

[statedef 786847]
[state config]
type = varset
trigger1= !time
v = 0
;==========================================================================
; config
;==========================================================================
; change the value below to adjust effect.
;1 = scaled pixel offset at 50% transparency
;2 = no pixel offset, pixel scaled transparency
;3 = scaled pixel offset and scaled transparency.
;==========================================================================
value = 1
;==========================================================================

[State 786847, 0]
type = SprPriority
trigger1 = 1
value = 1  ;root,var(X)    ;This should always be 1 layer above the player, use a root var to keep track of SprPriority changing.
ignorehitpause = 1

[State 786847, 1]
type = NotHitBy
trigger1 = !Time
value = SCA
time = -1
ignorehitpause = 1

[state 786847, 2] ;option 1
type = Trans
trigger1 = var(0) = 1
trans = addalpha
alpha = 64, 192
ignorehitpause = 1

[state 786847, 3] ;option 2/3: part 1 (X)
type = Trans
trigger1 = ishelper(9999991) || ishelper(9999992)
trigger1 = var(0) = 2 || var(0) = 3
trigger1 = ceil(Const(size.xscale)) != Const(size.xscale)
trans = addalpha
alpha = cond(abs(cond(ceil(Const(size.xscale))>Const(size.xscale),ceil(Const(size.xscale)) - Const(size.xscale), Const(size.xscale) -floor(Const(size.xscale)))) > .5, 1 - abs(cond(ceil(Const(size.xscale))>Const(size.xscale),ceil(Const(size.xscale)) - Const(size.xscale), Const(size.xscale) -floor(Const(size.xscale)))), abs(cond(ceil(Const(size.xscale))>Const(size.xscale),ceil(Const(size.xscale)) - Const(size.xscale), Const(size.xscale) -floor(Const(size.xscale)))))  * 12.8 * 10 , 256 - (cond(abs(cond(ceil(Const(size.xscale))>Const(size.xscale),ceil(Const(size.xscale)) - Const(size.xscale), Const(size.xscale) -floor(Const(size.xscale)))) > .5, 1 - abs(cond(ceil(Const(size.xscale))>Const(size.xscale),ceil(Const(size.xscale)) - Const(size.xscale), Const(size.xscale) -floor(Const(size.xscale)))), abs(cond(ceil(Const(size.xscale))>Const(size.xscale),ceil(Const(size.xscale)) - Const(size.xscale), Const(size.xscale) -floor(Const(size.xscale)))))  * 12.8 * 10)
ignorehitpause = 1

[state 786847, 4] ;option 2/3: part 2 (Y)
type = Trans
trigger1 = ishelper(9999993) || ishelper(9999994)
trigger1 = var(0) = 2 || var(0) = 3
trigger1 = ceil(Const(size.yscale)) != Const(size.yscale)
trans = addalpha
alpha = cond(abs(cond(ceil(Const(size.yscale))>Const(size.yscale),ceil(Const(size.yscale)) - Const(size.yscale), Const(size.yscale) -floor(Const(size.yscale)))) > .5, 1 - abs(cond(ceil(Const(size.yscale))>Const(size.yscale),ceil(Const(size.yscale)) - Const(size.yscale), Const(size.yscale) -floor(Const(size.yscale)))), abs(cond(ceil(Const(size.yscale))>Const(size.yscale),ceil(Const(size.yscale)) - Const(size.yscale), Const(size.yscale) -floor(Const(size.yscale)))))  * 12.8 * 10 , 256 - (cond(abs(cond(ceil(Const(size.yscale))>Const(size.yscale),ceil(Const(size.yscale)) - Const(size.yscale), Const(size.yscale) -floor(Const(size.yscale)))) > .5, 1 - abs(cond(ceil(Const(size.yscale))>Const(size.yscale),ceil(Const(size.yscale)) - Const(size.yscale), Const(size.yscale) -floor(Const(size.yscale)))), abs(cond(ceil(Const(size.yscale))>Const(size.yscale),ceil(Const(size.yscale)) - Const(size.yscale), Const(size.yscale) -floor(Const(size.yscale)))))  * 12.8 * 10)
ignorehitpause = 1

[state 786847, 5]
type = changeanim
triggerall = PlayerIdExist(Root,ID)
triggerall = SelfAnimExist(root,anim)
trigger1 = anim != root,anim
trigger2 = root,animelemno(0) != animelemno(0)
value = root,anim
elem =root,animelemno(0)
ignorehitpause = 1

[state 786847, 6]
type = AssertSpecial
trigger1 = !SelfAnimExist(root,anim)
flag = invisible
ignorehitpause = 1

;Option 1 or 3-------------
[State 786847, 7]
type = BindToRoot
trigger1 = PlayerIdExist(Root,ID)
trigger1 = ishelper(9999991)
trigger1 = var(0) = 1 || var(0) = 3
time = 1
facing = 1
pos = cond(abs(ceil(Const(size.xscale)) - Const(size.xscale)) >= .5 , (Const(size.xscale) - (Const(size.xscale) * abs(ceil(Const(size.xscale)) - Const(size.xscale))))*2 , (Const(size.xscale) * abs(ceil(Const(size.xscale)) - Const(size.xscale)))*2) ,0
ignorehitpause = 1

[State 786847, 8]
type = BindToRoot
trigger1 = PlayerIdExist(Root,ID)
trigger1 = ishelper(9999992)
trigger1 = var(0) = 1 || var(0) = 3
time = 1
facing = 1
pos = -cond(abs(ceil(Const(size.xscale)) - Const(size.xscale)) >= .5 , (Const(size.xscale) - (Const(size.xscale) * abs(ceil(Const(size.xscale)) - Const(size.xscale))))*2 , (Const(size.xscale) * abs(ceil(Const(size.xscale)) - Const(size.xscale)))*2)  ,0
ignorehitpause = 1

[State 786847, 9]
type = BindToRoot
trigger1 = PlayerIdExist(Root,ID)
trigger1 = ishelper(9999993)
trigger1 = var(0) = 1 || var(0) = 3
time = 1
facing = 1
pos = 0,cond(abs(ceil(Const(size.xscale)) - Const(size.xscale)) >= .5 , (Const(size.xscale) - (Const(size.xscale) * abs(ceil(Const(size.xscale)) - Const(size.xscale))))*2 , (Const(size.xscale) * abs(ceil(Const(size.xscale)) - Const(size.xscale)))*2)
ignorehitpause = 1

[State 786847, 10]
type = BindToRoot
trigger1 = PlayerIdExist(Root,ID)
trigger1 = ishelper(9999994)
trigger1 = var(0) = 1 || var(0) = 3
time = 1
facing = 1
pos = 0,-cond(abs(ceil(Const(size.xscale)) - Const(size.xscale)) >= .5 , (Const(size.xscale) - (Const(size.xscale) * abs(ceil(Const(size.xscale)) - Const(size.xscale))))*2 , (Const(size.xscale) * abs(ceil(Const(size.xscale)) - Const(size.xscale)))*2)
ignorehitpause = 1

;Option 2------------------
[State 786847, 11]
type = BindToRoot
trigger1 = PlayerIdExist(Root,ID)
trigger1 = ishelper(9999991)
trigger1 = var(0) = 2
time = 1
facing = 1
pos = Const(size.xscale),0
ignorehitpause = 1

[State 786847, 12]
type = BindToRoot
trigger1 = PlayerIdExist(Root,ID)
trigger1 = ishelper(9999992)
trigger1 = var(0) = 2
time = 1
facing = 1
pos = -Const(size.xscale),0
ignorehitpause = 1

[State 786847, 13]
type = BindToRoot
trigger1 = PlayerIdExist(Root,ID)
trigger1 = ishelper(9999993)
trigger1 = var(0) = 2
time = 1
facing = 1
pos = 0,Const(size.yscale)
ignorehitpause = 1

[State 786847, 14]
type = BindToRoot
trigger1 = PlayerIdExist(Root,ID)
trigger1 = ishelper(9999994)
trigger1 = var(0) = 2
time = 1
facing = 1
pos = 0,-Const(size.yscale)
ignorehitpause = 1

Last Edit: December 18, 2018, 09:42:54 pm by ink
Re: Blur effect for sprites that are scaled in game.
New #2  December 18, 2018, 11:39:05 pm
  • avatar
  • ***
if youre using 1.1 you can make the sprites blurry
there's this thread about fixing a tv or something
something about the indexed.frag
just letting you know

-edit-
Spoiler, click to toggle visibilty
works best if the sprites not cropped
but when there's alot of large 8 bit sprites shown on screen the game might lag

i'm with you about sprites look best with no blur
zzz
Last Edit: December 20, 2018, 11:24:01 am by cldz