Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@jonahwilliams
Copy link
Contributor

@jonahwilliams jonahwilliams commented Sep 12, 2022

Gives all gradients/color source contents an alpha. Additionall corrects some implementation in errors when lerping gradients

Opacity:

Screen Shot 2022-09-12 at 10 23 54 AM

Fixes Stops:

Screen Shot 2022-09-12 at 10 46 50 AM

Fixes flutter/flutter#111313


for (auto i = 1u; i < texture_size - 1; i++) {
auto scaled_i = i / texture_size;
auto scaled_i = i / (texture_size * 1.0);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woops

// or very small stops.
AppendColor(next_color, &color_stop_channels);

// We've slightly overshot the previous stop.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't the case I though it was. If we've passed the previous stop, then we essentially just treat the current stop as the previous stop and run the same code as above.

Copy link
Member

@bdero bdero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Should we land this for the other color sources too? (Could be done in followup(s))

@chinmaygarde chinmaygarde changed the title Support alpha in Gradients, fix uneven stops. [Impeller] Support alpha in Gradients, fix uneven stops. Sep 12, 2022
gradient_info.tile_mode,
gradient_info.tile_mode);
frag_color = vec4(frag_color.xyz * frag_color.a, frag_color.a);
frag_color = vec4(frag_color.xyz * frag_color.a, frag_color.a) * gradient_info.alpha;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left this comment on the other PR, but this still makes me wonder if IPSampleWithTileMode shouldn't really just be IPSampleWithTileModeAndAlpha so we don't forget to do this somewhere - e.g. if and when we implement two point conical gradients.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Binding non-premultiplied images is the uncommon case -- all layer textures and UI images are premultiplied.

Copy link
Member

@bdero bdero Sep 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One idea for making this a bit more semantic is to add an IPPremultiply utility to the shader library and wrap the sampling function in it when we need to premultiply something. This way new contributors who don't know why we're doing the funky alpha multiplies can get a bit more context when first encountering it.
We happen to already have IPUnpremultiply because the advanced blends need to happen with unpremultiplied colors.

All shader functions get flattened by ImpellerC, so utilities like this are free.

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 12, 2022
@auto-submit auto-submit bot merged commit ce06251 into flutter:main Sep 12, 2022
@jonahwilliams jonahwilliams deleted the getBytes branch September 12, 2022 19:40
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 12, 2022
cfontas pushed a commit to cfontas/engine that referenced this pull request Sep 14, 2022
Oleh-Sv pushed a commit to Oleh-Sv/engine that referenced this pull request Sep 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App e: impeller

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

[Impeller] Gradient drawing is not taking paint alpha into account

4 participants