Skip to content

Maniacs Patch general tint bug/not implemented #2755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Br4ssman opened this issue Mar 25, 2022 · 3 comments
Closed

Maniacs Patch general tint bug/not implemented #2755

Br4ssman opened this issue Mar 25, 2022 · 3 comments

Comments

@Br4ssman
Copy link

Br4ssman commented Mar 25, 2022

Just put an pic with alpha channel, and modify its tint, via pic or tint screen.

This is an example of a pic imported normally:
imagen1

And I set its pic properties and:
imagen2

Video showing how tint screen transform the normal picture to the bugged pone:
https://user-images.githubusercontent.com/18174790/160157150-41f5ddb8-0c38-4fd6-9db6-266868f364cb.mp4

Thanks.

@Ghabry
Copy link
Member

Ghabry commented Mar 29, 2022

The problem is that the alpha value was ignored (premultiplied alpha)

static inline void color_tone(uint32_t &src_pixel, Tone tone, int rs, int gs, int bs, int as) {
	uint8_t a = (src_pixel >> as) & 0xFF;
	uint8_t r = ((uint32_t)hard_light.table[tone.red][(src_pixel >> rs) & 0xFF]) * a / 255;
	uint8_t g = ((uint32_t)hard_light.table[tone.green][(src_pixel >> gs) & 0xFF]) * a / 255;
	uint8_t b = ((uint32_t)hard_light.table[tone.blue][(src_pixel >> bs) & 0xFF]) * a / 255;
	src_pixel = ((uint32_t)r << rs) | ((uint32_t)g << gs) | ((uint32_t)b << bs) | ((uint32_t)a << as);
}

Unfortunately that multiply will make the blit even slower. Will do some benchmarking to figure out how bad it is and if special-casing a = 255 will help.

screenshot_1

screenshot_0

@Ghabry Ghabry added this to the 0.7.1 milestone Mar 29, 2022
Ghabry added a commit to Ghabry/easyrpg-player that referenced this issue May 9, 2022
Also refactor ToneBlit function structure.

Replaced ImageOpacity::Partial with Alpha_1Bit and Alpha_8Bit.
This allows further optimisations in Tone Blit to decide if premultiply is needed or not.

Benchmarks have shown that on x86 the difference is not measurable between multiply or not.
Maybe helps on other platforms with slower multiply.

Fix EasyRPG#2755
@Ghabry
Copy link
Member

Ghabry commented May 16, 2022

@Br4ssman please retest in master, this should look beautiful now 😊

@Br4ssman
Copy link
Author

Nice, thank you team:

imagen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants