YesNoOk
avatar

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