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

Started by Vans, June 08, 2015, 03:41:26 pm

Vans

Afterimages pissing you off? Well they're broken.
#1  June 08, 2015, 03:41:26 pm
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)
palcontrast = mul_r, mul_g, mul_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

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:

palmul = .65,.65,.75

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

Code:
`[State 810, 1]type = AfterImagetrigger1 = time = 1time = 170000length = 9framegap = 3palcolor = 256palinvertall = 0palbright = 0,0,0palcontrast = 256,256,256palpostbright = 0,0,0paladd = 0,0,0palmul = 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.
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.

-[Все слова это только слова.]-

Vans

Re: Afterimages pissing you off? Well they're broken.
#3  June 08, 2015, 03:50:25 pm
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.

Алексей

Re: Afterimages pissing you off? Well they're broken.
#4  June 08, 2015, 03:57:00 pm
• Target Acquired.
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.

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 Алексей

felineki

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.

Ricepigeon

Re: Afterimages pissing you off? Well they're broken.
#6  June 08, 2015, 04:00:54 pm
• Thanks and God bless
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?

Vans

Re: Afterimages pissing you off? Well they're broken.
#7  June 08, 2015, 04:02:03 pm
^

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.

Ricepigeon

Re: Afterimages pissing you off? Well they're broken.
#8  June 08, 2015, 04:08:20 pm
• Thanks and God bless
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

Flowrellik

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.

Jesuszilla

Re: Afterimages pissing you off? Well they're broken.
#10  June 08, 2015, 05:48:36 pm
• Loyal to the Game
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

Vans

Re: Afterimages pissing you off? Well they're broken.
#11  June 08, 2015, 06:32:09 pm
It's dumb but yeah, the value in palcontrast should really be 256 according to their own formula:

Quote

Jesuszilla

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

I may have found a solution. add_r -32,0,0, mul_r = 257

Vans

Re: Afterimages pissing you off? Well they're broken.
#13  June 08, 2015, 06:50:02 pm
Palbright does not admit negative values.

Jesuszilla

Re: Afterimages pissing you off? Well they're broken.
#14  June 08, 2015, 06:58:48 pm
• Loyal to the Game

Have -32 as the paladd component.

Vans

Re: Afterimages pissing you off? Well they're broken.
#15  June 08, 2015, 07:00:37 pm
Code:
`[State 810, 1]type = AfterImagetrigger1 = animelem = 2time = 170length = 9framegap = 3palcolor = 256palcontrast = 257,256,256palpostbright = -32,0,0palbright = 0,0,0paladd = 0,0,00palmul = 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

Jesuszilla

Re: Afterimages pissing you off? Well they're broken.
#16  June 08, 2015, 07:03:36 pm
• Loyal to the Game
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

Vans

Re: Afterimages pissing you off? Well they're broken.
#17  June 08, 2015, 07:13:12 pm
Paladd cannot be used as it applies the effect to successive afterimages:

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

Jesuszilla

Re: Afterimages pissing you off? Well they're broken.
#18  June 08, 2015, 07:17:40 pm
• Loyal to the Game
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
palmul=1,1,1
alpha=64,256
trigger1=time=1

RAM :

¯\_(ツ)_/¯

Vans

Re: Afterimages pissing you off? Well they're broken.
#20  June 08, 2015, 08:06:12 pm
LOL

rednavi -RETIRED

Re: Afterimages pissing you off? Well they're broken.
#21  June 08, 2015, 08:07:43 pm
...What the fuck

Bea

Re: Afterimages pissing you off? Well they're broken.
#22  June 08, 2015, 08:14:41 pm
• MUGEN Grandma
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.

K.O.D

Re: Afterimages pissing you off? Well they're broken.
#23  June 08, 2015, 08:18:35 pm
• what a shame
looool

Jesuszilla

Re: Afterimages pissing you off? Well they're broken.
#24  June 08, 2015, 08:22:31 pm
• Loyal to the Game
Fucking incredible.

Алексей

Re: Afterimages pissing you off? Well they're broken.
#25  June 08, 2015, 08:56:13 pm
• Target Acquired.
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.

-[Все слова это только слова.]-

XGargoyle

Re: Afterimages pissing you off? Well they're broken.
#26  June 08, 2015, 09:19:48 pm
• Hedgehog Whisperer
 XGargoyle: Battle posing since 1979http://xgargoyle.mgbr.nethttp://www.pandorabots.com/pandora/talk?botid=e71c0d43fe35093a  <-- Please click that linkhttp://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
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.

Chronan

Re: Afterimages pissing you off? Well they're broken.
#28  June 08, 2015, 10:13:43 pm
• The Barbarian
• Most ****able 2013
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.

Jesuszilla

Re: Afterimages pissing you off? Well they're broken.
#29  June 08, 2015, 10:34:48 pm
• Loyal to the Game
Each color component is only 8 bits, so it would be from 0-255, not 0-65535.

Vans

Re: Afterimages pissing you off? Well they're broken.
#30  June 08, 2015, 10:38:03 pm
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

Bastard Mami

Re: Afterimages pissing you off? Well they're broken.
#31  June 08, 2015, 11:33:10 pm
• [E]

Jesuszilla

Re: Afterimages pissing you off? Well they're broken.
#32  June 08, 2015, 11:38:35 pm
• Loyal to the Game
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

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
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 = Helpertrigger1 = time = 1trigger1 = numhelper(12000) = 0helpertype = normalname = "ai"ID = 12000stateno = 12000pos = 0,0postype = p1facing = 1keyctrl = 0ownpal = 1supermovetime = 0pausemovetime = 0`

Code:
`[Statedef 12000][State 0, RemapPal]type = RemapPaltrigger1 = 1source = 1,palnodest = 30,palno[State 0, AssertSpecial]type = AssertSpecialtrigger1 = 1flag = invisible[State 0, Turn]type = Turntrigger1 = facing != root, facing [State 0, ChangeAnim]type = ChangeAnimtrigger1 = anim != root, animvalue = root, anim[State 0, PosSet]type = PosSettrigger1 = 1x = root, pos xy = root, pos y[State 810, 1]type = AfterImagetrigger1 = time = 1time = 170000length = 99 framegap = 3palcolor = 256palinvertall = 0palbright = 0,0,0palcontrast = 256,256,256palpostbright = 0,0,0paladd = 0,0,0palmul = 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.

oscarlin814

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 = AfterImagetrigger1 = time = 0time = 170000length = 11framegap = 1palcolor = 256palinvertall = 0palbright = 0,0,0palcontrast = 256,256,256palpostbright = -30,0,0paladd = 0,0,0palmul = 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.