Skip to content
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

Fix FlxCamera.fill() blending #3217

Merged
merged 4 commits into from
Jul 15, 2024
Merged

Conversation

richTrash21
Copy link
Contributor

@richTrash21 richTrash21 commented Jul 13, 2024

Fixes #3203 by overriding the blend mode of target graphics in FlxCamera.fill() to null (BlendMode.NORMAL). Does not affect blitting targets since blend modes just doesn't work there.
Additionally makes drawFX more readable

@richTrash21
Copy link
Contributor Author

richTrash21 commented Jul 13, 2024

Alternatively this can be turned into a feature by passing blend to FlxCamera.fill() with default value being null (BlendMode.NORMAL)
Like this:

final someColor = new FlxColor(0x99ff00ff);
final someBlendMode = BlendMode.ADD;
FlxG.camera.fill(someColor.rgb, true, someColor.alphaFloat, FlxG.camera.canvas.graphics, someBlendMode);

Note: just piggybanking an idea, will probably use it for personal stuff, tho let me know if it's good or meh.

@Geokureli
Copy link
Member

Reverted both parts like this, i don't want unrelated functional changes amended to PRs and this may technically be a "breaking change"

if (_fxFlashColor.alpha == 0)
	_fxFlashColor.alpha = 0xff;

also cleaned up the style changes a little more, not a fan of having vars crated outside of code blocks, only to be used inside of code blocks

@Geokureli Geokureli added this to the 5.9.0 milestone Jul 15, 2024
@Geokureli Geokureli merged commit ac488bf into HaxeFlixel:dev Jul 15, 2024
11 checks passed
@Geokureli
Copy link
Member

Thanks!

@richTrash21
Copy link
Contributor Author

Reverted both parts like this, i don't want unrelated functional changes amended to PRs and this may technically be a "breaking change"

if (_fxFlashColor.alpha == 0)
	_fxFlashColor.alpha = 0xff;

The reason why I added these parts was because of how drawFX() used alpha component of the effect color before this pr's changes, where if color had no alpha it would just set it to 255, so technically it wasn't a "breaking change".

// Draw the "fade" special effect onto the buffer
if (_fxFadeAlpha > 0.0)
{
	alphaComponent = _fxFadeColor.alpha;

	if (FlxG.renderBlit)
	{
		fill((Std.int(((alphaComponent <= 0) ? 0xff : alphaComponent) * _fxFadeAlpha) << 24) + (_fxFadeColor & 0x00ffffff));
	}
	else
	{
		fill((_fxFadeColor & 0x00ffffff), true, ((alphaComponent <= 0) ? 0xff : alphaComponent) * _fxFadeAlpha / 255, canvas.graphics);
	}
}

Note: Just giving a reasoning to why such changes were made, not to imply that they were necessary, I was just following the functionality of drawFX().

@Geokureli
Copy link
Member

The reason why I added these parts was because of how drawFX() used alpha component of the effect color before this pr's changes, where if color had no alpha it would just set it to 255, so technically it wasn't a "breaking change".

I understand but its a separate issue and it will change how an existing tool is designed to function, rather than an unintended bug, and therefore a breaking change to anyone who has made games with the previous functionality in mind.

Also changes like this need to consider broader conventions, what do other flixel tools do in the case of 0 alpha channel, how can we make tools that use colors with 0 alpha more cohesive and behave expectedly. I really don't want willy nilly changes to behavior like this without considering the broader scope

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

Successfully merging this pull request may close these issues.

FlxCamera.fill() uses blend mode of the last drawn item on camera
2 participants