# Afterimages pissing you off? Well they're broken. (Read 86210 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