YesNoOk
avatar

Afterimages pissing you off? Well they're broken. (Read 80249 times)

Started by Vans, June 08, 2015, 03:41:26 pm
Share this topic:
Afterimages pissing you off? Well they're broken.
#1  June 08, 2015, 03:41:26 pm
  • ****
    • China
    • http://vans.trinitymugen.net/
This is a problem that has me on suicide watch right now. So let's say we want to make a SOLID afterimage, pretty simple right?

We go to the docs and read the documentation on afterimage:

Quote
palcolor = col (int)
palinvertall = invertall (bool)
palbright = add_r, add_g, add_b (int)
palcontrast = mul_r, mul_g, mul_b (int)
palpostbright = add2_r, add2_g, add2_b (int)

These parameters determine palette effects to be applied to all afterimages. First the color level is adjusted according to the palcolor value, then if invertall is non-zero the colors are inverted. Afterwards, the palbright components are added to the corresponding component of the player's palette, then each component is multiplied by the corresponding palcontrast component divided by 256, then the palpostbright components are added to the result. The value of palcolor ranges from 0 (greyscale) to 256 (normal color).

For instance, if the red component of the character's palette is denoted pal_r, then the red component of the afterimage palette is given by (pal_r + add_r) * mul_r / 256 + add2_r, assuming palcolor and palinvert are left at their default values. Valid values are 0-256 for palcolor, 0-255 for palbright and palpostbright components, and any non-negative integer for palcontrast components.

The defaults are:

palcolor = 256
palinvertall = 0
palbright = 30,30,30
palcontrast = 120,120,220
palpostbright = 0,0,0

paladd = add_r, add_g, add_b (int)
palmul = mul_r, mul_g, mul_b (float)

These parameters specify palette effects that are applied repeatedly to successive frames in the afterimage. In one application of these palette effects, first the paladd components are added to the afterimage palette, then the components are multiplied by the palmul multipliers.

These effects are applied zero times to the most recent afterimage frame, once to the second-newest afterimage frame, twice in succession to the third-newest afterimage frame, etc. Valid values are 0-255 for the paladd components, and any non-negative float value for the palmul multipliers.

The defaults are:

paladd = 10,10,25
palmul = .65,.65,.75

Okay cool. So going by this info a controller such as this:

Code:
[State 810, 1]
type = AfterImage
trigger1 = time = 1
time = 170000
length = 9
framegap = 3
palcolor = 256
palinvertall = 0
palbright = 0,0,0
palcontrast = 256,256,256
palpostbright = 0,0,0
paladd = 0,0,0
palmul = 1.0,1.0,1.0

Should produce SOLID-color afterimages. OK.



THEY'RE RED, MUGEN LIES TO ME.

Okay so if we try to use palpostbright = -30,0,0...



Close since we are trying to compensate for the extra red, but close inspection of the color values hints that the colors are still off.

Suspiciously, nulling out the palbright parameter will produce afterimages that resemble the proper colors, however, the result is too bright:



I should also mention that mugen completely ignores any negative values in the palbright parameter.

Still unsure if we can somehow reverse-engineer the equation to see what values MUGEN is actually feeding, because it's clearly feeding red where there shouldn't be any.

Discuss.

Last Edit: June 08, 2015, 04:02:33 pm by Vans
Re: Afterimages pissing you off? Well they're broken.
#2  June 08, 2015, 03:49:43 pm
  • ****
  • Target Acquired.
    • Ukraine
    • mugencoder.com
If it's too bright, try adjusting all the palbright values instead of just the red value. Such as -30,-30,-30. I don't think the PalFX takes actual character colors into consideration so there would be no extra red to adjust for.

While mugen lies a lot, I don't think it is here honestly.

-[Все слова это только слова.]-
Re: Afterimages pissing you off? Well they're broken.
#3  June 08, 2015, 03:50:25 pm
  • ****
    • China
    • http://vans.trinitymugen.net/
If it's too bright, try adjusting all the palbright values instead of just the red value. Such as -30,-30,-30. I don't think the PalFX takes actual character colors into consideration so there would be no extra red to adjust for.

While mugen lies a lot, I don't think it is here honestly.

What.

MUGEN does not admit negative values for palbright, and this is the afterimage controller.

Please make sure to read the problem before posting, thanks.
Re: Afterimages pissing you off? Well they're broken.
#4  June 08, 2015, 03:57:00 pm
  • ****
  • Target Acquired.
    • Ukraine
    • mugencoder.com
What.

What don't you understand? I'm happy to explain. :)

255,255,255 is pure white, right? Adjusting only the first value will make that color pure red. This explains why your first attempt came out red. If you want the full colors without any other color manipulation then you have to adjust all three values, not just the single one.

Quote
MUGEN does not admit negative values for palbright, and this is the afterimage controller.

Please make sure to read the problem before posting, thanks.
True, but it does for paladd... Try modifying that instead of palbright. You saw yourself that palbright should be left at 0.

-[Все слова это только слова.]-
Last Edit: June 08, 2015, 04:03:07 pm by Алексей
Re: Afterimages pissing you off? Well they're broken.
#5  June 08, 2015, 03:59:50 pm
  • ****
  • A frame here, a pixel there.
I noticed this when working on Akuma because he's supposed to have afterimages that just get gradually darker while otherwise retaining the original colors. Something's definitely off with how Mugen handles the red channel of the afterimage pal parameters.
Re: Afterimages pissing you off? Well they're broken.
#6  June 08, 2015, 04:00:54 pm
  • *****
  • Thanks and God bless
    • USA
    • ricepigeon.neocities.org
Code:
    [State 810, 1]
    type = AfterImage
    trigger1 = time = 1
    time = 170000
    length = 9
    framegap = 3
    palcolor = 256
    palinvertall = 0
    palbright = 0,0,0
    palcontrast = 256,256,256
    palpostbright = 0,0,0
    palbright = -100,0,0
    paladd = 0,0,0
    palmul = 1.0,1.0,1.0

Is it just me or is there an extra palbright parameter that shouldn't be there which might be causing this?
Re: Afterimages pissing you off? Well they're broken.
#7  June 08, 2015, 04:02:03 pm
  • ****
    • China
    • http://vans.trinitymugen.net/
^

Sorry about that, that was one attempt at actually compensating for the extra red. I updated my first post with the proper value in palbright.

Also, palbright ignores negative values anyway.
Re: Afterimages pissing you off? Well they're broken.
#8  June 08, 2015, 04:08:20 pm
  • *****
  • Thanks and God bless
    • USA
    • ricepigeon.neocities.org
This sort of reminds me of something involving an explod I tried once upon a time on Kohaku's Utsuho in order to replicate the effects of her cape that she has in source, where you have two explods of the same sprite; once being additive transparency and the other being subtractive. Logically, both should have cancelled each other out and produce nothing, but the one with subtractive transparency still showed itself (albeit faintly) regardless of what sprpriority you set the two explods to.

I suspect that something similar might be happening here in regards to the red channel.
Last Edit: June 08, 2015, 04:16:23 pm by Ricepigeon
Re: Afterimages pissing you off? Well they're broken.
#9  June 08, 2015, 05:41:53 pm
  • ****
  • Raging Fist
Well, I actually thought about using an afterimage code as a projectile overlay where the projectile will look like it, but it seems like the logical thing to do would be an explod....which Im trying to figure out.
Re: Afterimages pissing you off? Well they're broken.
#10  June 08, 2015, 05:48:36 pm
  • ******
  • Loyal to the Game
    • USA
    • http://jesuszilla.trinitymugen.net/
Shouldn't that be 255 rather than 256 in the parameters you're feeding to palcontrast?

I'd try that first.

The best way to "reverse engineer" it would be to open up an image editor and compare the RGB values between the normal frame and the afterimages.

Forgive me if I've repeated any information, I'm on my phone right now.

EDIT: Sometimes it adds 32 or 33 to the red. An add and multiply of some sort is occurring.
Last Edit: June 08, 2015, 06:09:26 pm by Jesuszilla
Re: Afterimages pissing you off? Well they're broken.
#11  June 08, 2015, 06:32:09 pm
  • ****
    • China
    • http://vans.trinitymugen.net/
It's dumb but yeah, the value in palcontrast should really be 256 according to their own formula:

Quote
(pal_r + add_r) * mul_r / 256 + add2_r

Re: Afterimages pissing you off? Well they're broken.
#12  June 08, 2015, 06:42:12 pm
  • ******
  • Loyal to the Game
    • USA
    • http://jesuszilla.trinitymugen.net/
It is dumb.

I may have found a solution. add_r -32,0,0, mul_r = 257
Re: Afterimages pissing you off? Well they're broken.
#13  June 08, 2015, 06:50:02 pm
  • ****
    • China
    • http://vans.trinitymugen.net/
Palbright does not admit negative values.
Re: Afterimages pissing you off? Well they're broken.
#14  June 08, 2015, 06:58:48 pm
  • ******
  • Loyal to the Game
    • USA
    • http://jesuszilla.trinitymugen.net/
Oh shit I had the wrong add.

Have -32 as the paladd component.
Re: Afterimages pissing you off? Well they're broken.
#15  June 08, 2015, 07:00:37 pm
  • ****
    • China
    • http://vans.trinitymugen.net/
Code:
[State 810, 1]
type = AfterImage
trigger1 = animelem = 2
time = 170
length = 9
framegap = 3
palcolor = 256
palcontrast = 257,256,256
palpostbright = -32,0,0
palbright = 0,0,0
paladd = 0,0,00
palmul = 1.0,1.0,1.0



Red seems to be off by 8 in certain colors, but so far this is the closest to neutral.

Edit: Updated with a better image.
Last Edit: June 08, 2015, 07:16:53 pm by Vans
Re: Afterimages pissing you off? Well they're broken.
#16  June 08, 2015, 07:03:36 pm
  • ******
  • Loyal to the Game
    • USA
    • http://jesuszilla.trinitymugen.net/
Updated my post again for a parameter that actually accepts negative arguments.

I saw that one color was off by 4. One thing for certain is that now it's always off by a power of 2, so we're getting somewhere.

EDIT: one was off by 24
Last Edit: June 08, 2015, 07:20:58 pm by Jesuszilla
Re: Afterimages pissing you off? Well they're broken.
#17  June 08, 2015, 07:13:12 pm
  • ****
    • China
    • http://vans.trinitymugen.net/
Paladd cannot be used as it applies the effect to successive afterimages:

Code:
[State 810, 1]
type = AfterImage
trigger1 = time = 1
time = 170000
length = 9
framegap = 1
palcolor = 256
palinvertall = 0
palbright = 0,0,0
palcontrast = 257,256,256
palpostbright = 0,0,0
paladd = -32,0,0
palmul = 1.0,1.0,1.0
persistent = 170

Re: Afterimages pissing you off? Well they're broken.
#18  June 08, 2015, 07:17:40 pm
  • ******
  • Loyal to the Game
    • USA
    • http://jesuszilla.trinitymugen.net/
Ah.

Also it turns out that the reason some of those colors are off by a certain amount is because the red just happens to max out at 255. Without a way to get the color value, I don't think it's possible to fully account for this.

I'll do my own investigation when I get home to see if it's something to do with the graphics card (you use Nvidia, I use AMD) or a shader problem (I know 1.1 allows some shader customization).
Last Edit: June 08, 2015, 07:25:23 pm by Jesuszilla
Re: Afterimages pissing you off? Well they're broken.
#19  June 08, 2015, 07:55:49 pm
  • **
CNS :
Quote
[state ]
type=afterimage
time=-1
length=9
timegap=1
framegap=3
palcolor=256
palinvertall=0
palbright=123,456,789
palcontrast=321,654,987
palpostbright=987,876,765
paladd=0,0,0
palmul=1,1,1
trans=addalpha
alpha=64,256
trigger1=time=1

RAM :


¯\_(ツ)_/¯
Re: Afterimages pissing you off? Well they're broken.
#20  June 08, 2015, 08:06:12 pm
  • ****
    • China
    • http://vans.trinitymugen.net/
LOL
Re: Afterimages pissing you off? Well they're broken.
#21  June 08, 2015, 08:07:43 pm
  • avatar
  • ******
    • USA
...What the fuck

Bea

Re: Afterimages pissing you off? Well they're broken.
#22  June 08, 2015, 08:14:41 pm
  • *****
  • MUGEN Grandma
    • Brazil
    • www.smeenet.org
Elecbyte standard of quality.
Why are people surprised with such egregious bug? That is the norm for Elecbyte.
Princess Adora: "My friend saw She-Ra take her dress off in the shower. She said she has an 8 pack. She said She-Ra is shredded."

SF2NES is dead. Long live SF2NES.
Re: Afterimages pissing you off? Well they're broken.
#23  June 08, 2015, 08:18:35 pm
  • ******
  • what a shame
    • Iran
looool
Re: Afterimages pissing you off? Well they're broken.
#24  June 08, 2015, 08:22:31 pm
  • ******
  • Loyal to the Game
    • USA
    • http://jesuszilla.trinitymugen.net/
Fucking incredible.
Re: Afterimages pissing you off? Well they're broken.
#25  June 08, 2015, 08:56:13 pm
  • ****
  • Target Acquired.
    • Ukraine
    • mugencoder.com
LOL
My apologies, Vans.

Elecbyte standard of quality.
Why are people surprised with such egregious bug? That is the norm for Elecbyte.
Well I guess it's because we expect the shit we're working with to work. I'm in denial about it at times, because I just keep hoping that it's me that's doing wrong and that needs to fix his shit to get things to work properly.

-[Все слова это только слова.]-
Re: Afterimages pissing you off? Well they're broken.
#26  June 08, 2015, 09:19:48 pm
  • ******
  • Hedgehog Whisperer
  • Red Bull addict
    • Spain
    • xgargoyle.mgbr.net
XGargoyle: Battle posing since 1979
http://xgargoyle.mgbr.net
http://www.pandorabots.com/pandora/talk?botid=e71c0d43fe35093a  <-- Please click that link
http://paypal.me/XGargoyle  <-- Donations welcome!
Last Edit: June 08, 2015, 09:25:20 pm by XGargoyle

Bea

Re: Afterimages pissing you off? Well they're broken.
#27  June 08, 2015, 10:00:16 pm
  • *****
  • MUGEN Grandma
    • Brazil
    • www.smeenet.org
Elecbyte standard of quality.
Why are people surprised with such egregious bug? That is the norm for Elecbyte.
Well I guess it's because we expect the shit we're working with to work. I'm in denial about it at times, because I just keep hoping that it's me that's doing wrong and that needs to fix his shit to get things to work properly.

15 years around this stuff.
By now I know better than trusting Elecbyte code quality.
Princess Adora: "My friend saw She-Ra take her dress off in the shower. She said she has an 8 pack. She said She-Ra is shredded."

SF2NES is dead. Long live SF2NES.
Re: Afterimages pissing you off? Well they're broken.
#28  June 08, 2015, 10:13:43 pm
  • ****
  • The Barbarian
  • Most ****able 2013
    • USA
    • Skype - chronostrifeff7h@hotmail.com
Haha thanks for posting this. I've been playing around with Afterimages and couldn't help but notice the coloration was incorrect, 0,0,0 was giving me a reddish Krillin which was driving me up a wall. So I figured I was doing something wrong.

I'm not sure what it does, but I could have swore palbright seemed to take and apply negatives for me despite the documentation saying it doesn't. Not sure if it is rolling it back to some red of 65xxx or 32xxx (not that I'm even sure how the engine defines these ints), maybe its a 1.1 thing or maybe I really was messing with paladd. I might be losing my mind though, its been a couple weeks.

I'm tempted to play with this some more, now and this thread just helped me feel significantly less stupid about getting back into MUGEN code.
Re: Afterimages pissing you off? Well they're broken.
#29  June 08, 2015, 10:34:48 pm
  • ******
  • Loyal to the Game
    • USA
    • http://jesuszilla.trinitymugen.net/
Each color component is only 8 bits, so it would be from 0-255, not 0-65535.
Re: Afterimages pissing you off? Well they're broken.
#30  June 08, 2015, 10:38:03 pm
  • ****
    • China
    • http://vans.trinitymugen.net/
I have not confirmed using artmoney, but further tests would hint at the add_r parameter being completely fixed at 30.

If we assume the equation Elecbyte gives us is correct then,

(256 + 30) * 256 / 256 + add2_r = 256 → add2_r = -30.

Which means that setting palpostbright = -30,0,0 is the closest thing we can get to a fix (for getting solid colors)



This also means that colors looking off after doing that has to be related to something else entirely.
Last Edit: June 08, 2015, 10:47:31 pm by Vans
Re: Afterimages pissing you off? Well they're broken.
#31  June 08, 2015, 11:33:10 pm
  • ******
  • [E]
    • Mexico
Re: Afterimages pissing you off? Well they're broken.
#32  June 08, 2015, 11:38:35 pm
  • ******
  • Loyal to the Game
    • USA
    • http://jesuszilla.trinitymugen.net/
This also means that colors looking off after doing that has to be related to something else entirely.

I'm pretty sure it's related to the maxing out at 255. That could happen with several different values. So when you undo the conversion, you won't necessarily get the original value back.

In other words, it's not a one-to-one mapping.
Last Edit: June 08, 2015, 11:42:04 pm by Jesuszilla
Re: Afterimages pissing you off? Well they're broken.
#33  June 10, 2015, 05:07:56 am
  • **
So I looked a little bit more into this issue.

It turns out MUGEN, when parsing an AfterImage controller, and after initializing the default parameters for PalBright, actually stores add_r at the wrong address, so it ends up using add_g's address for add_r and add_g :laugh:

Nothing a bit of hex editing can't fix, fortunately.

KDT

Re: Afterimages pissing you off? Well they're broken.
#34  June 10, 2015, 06:05:18 am
  • *
    • UK
This seems to work

Make a helper with a palette with all the red values adjusted -30, i.e 159,44,255 to 129,44,255 and draw the after imge from that
Code:
[State 0, Helper]
type = Helper
trigger1 = time = 1
trigger1 = numhelper(12000) = 0
helpertype = normal
name = "ai"
ID = 12000
stateno = 12000
pos = 0,0
postype = p1
facing = 1
keyctrl = 0
ownpal = 1
supermovetime = 0
pausemovetime = 0

Code:
[Statedef 12000]

[State 0, RemapPal]
type = RemapPal
trigger1 = 1
source = 1,palno
dest = 30,palno

[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = invisible

[State 0, Turn]
type = Turn
trigger1 = facing != root, facing

[State 0, ChangeAnim]
type = ChangeAnim
trigger1 = anim != root, anim
value = root, anim

[State 0, PosSet]
type = PosSet
trigger1 = 1
x = root, pos x
y = root, pos y

[State 810, 1]
type = AfterImage
trigger1 = time = 1
time = 170000
length = 99
framegap = 3
palcolor = 256
palinvertall = 0
palbright = 0,0,0
palcontrast = 256,256,256
palpostbright = 0,0,0
paladd = 0,0,0
palmul = 1,1,1
Re: Afterimages pissing you off? Well they're broken.
#35  June 10, 2015, 06:33:23 am
  • **
It is a nice idea, but red values between 0 and 29 will be clamped to 30.
Re: Afterimages pissing you off? Well they're broken.
#36  March 17, 2022, 07:24:07 pm
  • *
Replying SIX YEARS later, it's even more broken. The solution in this simply no longer works now. This code:

Code:
[State blah blah blah, blah]
type = AfterImage
trigger1 = time = 0
time = 170000
length = 11
framegap = 1
palcolor = 256
palinvertall = 0
palbright = 0,0,0
palcontrast = 256,256,256
palpostbright = -30,0,0
paladd = 0,0,0
palmul = 1.0,1.0,1.0

Is now no longer a solution as the afterimages still appear red, for some reason. Editing postbright further does nothing.

Yeah, pain.