Afterimages pissing you off? Well they're broken.

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

Previous topic - Next topic

Vans

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:

[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.


Алексей

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

Quote from: Алексей on June 08, 2015, 03:49:43 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.

Please make sure to read the problem before posting, thanks.

Алексей

#3
Quote from: Vans on June 08, 2015, 03:50:25 PM
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.

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

felineki

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


    [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

^

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

#7
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.

Flowrellik

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

#9
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.

Vans

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


Jesuszilla

It is dumb.

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

Vans


Jesuszilla

Oh shit I had the wrong add.

Have -32 as the paladd component.

Vans

#14
[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.

Jesuszilla

#15
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

Vans

Paladd cannot be used as it applies the effect to successive afterimages:

[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



Jesuszilla

#17
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).

Demented Fortune Cookie

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 :


¯\_(ツ)_/¯