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

Remove automatic value change when specifying luminosity opacity on AcrylicBrush #2017

Merged
merged 6 commits into from
Mar 18, 2020

Conversation

marcelwgn
Copy link
Collaborator

Description

Remove unwanted clamping/rounding of colors when luminosity opacity is set on acrylic brush.

Motivation and Context

Fixes #1639

How Has This Been Tested?

Added new test page for visual verification.

Screenshots (if appropriate):

image

@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label Feb 23, 2020
@marcelwgn marcelwgn changed the title Acrylic luminosity fix Remove automatic value change when specifying luminosity opacity on AcrylicBrush Feb 23, 2020
@kikisaints
Copy link

@SpencerHurd - please review the screenshots to ensure the visuals chingucoding is showing is what's desired for this Acrylic fix.

@ranjeshj ranjeshj added team-Rendering Issue for the Rendering team area-Materials Reveal, Acrylic, lighting, etc. labels Feb 24, 2020
@ranjeshj
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@DmitriyKomin
Copy link
Contributor

double GetTintOpacityModifier(winrt::Color tintColor)

Following Spencer's description of the proposed change in the GitHub discussion for issue#1639, I would expect a change to this function, or GetEffectiveTintColor() above [to avoid applying any tintOpacityModifier to get the effective tint color in case TintLuminosityOpacity is set]


Refers to: dev/Materials/Acrylic/AcrylicBrush.cpp:344 in 647dac8. [](commit_id = 647dac8, deletion_comment = True)

Copy link
Contributor

@DmitriyKomin DmitriyKomin left a comment

Choose a reason for hiding this comment

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

GetEffectiveTintColor: there should be a change either here or in GetTintOpacityModifier to skip any modifications of TintColor when TintLuminosityOpacity is specified by the app.

@marcelwgn
Copy link
Collaborator Author

For the calculation of the Luminosity color, the values specified for TintColor and TintOpacity are used as provided by user.

From what I understood, only the luminosity color was not calculated correctly, thus this was the only change I made.

}

// To create the Luminosity blend input color without luminosity opacity,
// we're taking the TintColor input, converting to HSV, and clamping the V between these values
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer you put the remainder of this function in an else block, I think it makes it easier to read at a glance than having to recognize the early return

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am personally more a fan of the "return early" pattern, but sure, I will change it.

Copy link
Contributor

Choose a reason for hiding this comment

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

You are still returning early but this puts the logic that is now in the else block at the correct indentation level. before this change its easier to look at the code that is now in the else block and assume it will be run regardless of whether or not the above if statement was executed or not. Now it is obvious from the indentation level that it will only be run if we do not meet the if statement.


In reply to: 386686086 [](ancestors = 386686086)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh haha, I see. So your preferred way would be have a variable and we either set it to the "normal" luminosity brush or run the calculations and return our saved variable at the end of the function? If you want I can still change that to only have one return at the end.

@DmitriyKomin
Copy link
Contributor

In GetEffectiveTintColor() we obtain the effective TintColor, and its Alpha is affected by luminosity via the tintOpacityModifier:
336: double tintOpacityModifier = GetTintOpacityModifier(tintColor);
339: tintColor.A = static_cast<uint8_t>(round(tintColor.A * tintOpacity * tintOpacityModifier));

That is the tint color we actually use in the recipe (sometimes directly, sometimes to determine if we're in the special case of 'opaque acrylic'):
295: bool shouldUseOpaqueBrush = GetEffectiveTintColor().A == 255;
308: auto newColor = GetEffectiveTintColor();
930: winrt::Color tintColor = GetEffectiveTintColor();
1010: bool shouldUseOpaqueBrush = GetEffectiveTintColor().A == 255;

To complete the change, we can eg update line 339 to exclude the tintOpacityModifier term in the case that luminosityOpacity is provided.


In reply to: 591684517 [](ancestors = 591684517)

@marcelwgn
Copy link
Collaborator Author

@DmitriyKomin I am not sure what's the right change is here, this is something @SpencerHurd (and possibly @chigy) need to decide.

Sorry if I am CC'ing the wrong people here, I am not sure who exactly is the expert for that specifically 😅

@chigy
Copy link
Member

chigy commented Mar 4, 2020

@DmitriyKomin I am not sure what's the right change is here, this is something @SpencerHurd (and possibly @chigy) need to decide.

Sorry if I am CC'ing the wrong people here, I am not sure who exactly is the expert for that specifically 😅

@kikisaints , did we not receive actual recipe from design team when this was discussed originally?

@kikisaints
Copy link

@DmitriyKomin I am not sure what's the right change is here, this is something @SpencerHurd (and possibly @chigy) need to decide.
Sorry if I am CC'ing the wrong people here, I am not sure who exactly is the expert for that specifically 😅

@kikisaints , did we not receive actual recipe from design team when this was discussed originally?

We received a design detailing the luminosity integration. Internally as the PM team we decided on a "fallback" behavior that was:

  1. If the luminosity was not set, we would default and auto-correct to values that would make Acrylic look like the "old" one
  2. If the luminosity value was specified then we would apply it

It looks like DI didn't implement this quite the way we had decided, resulting in some additional luminosity adjustments even when the property was set. I think this was to combat Shadows, but since the DI doesn't remember why it was adjusted and design is unhappy with it I'm inclined to remove it so 1 above operates as we originally intended.

Copy link
Contributor

@StephenLPeters StephenLPeters left a comment

Choose a reason for hiding this comment

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

:shipit:

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@codendone codendone removed the needs-triage Issue needs to be triaged by the area owners label Mar 6, 2020
@StephenLPeters
Copy link
Contributor

@DmitriyKomin could you please take another look and approve if this is ready to go in?

@DmitriyKomin
Copy link
Contributor

@SpencerHurd : can you review the PR overall and also look at my comment above requesting a change? I believe that is needed to achieve the behavior you outlined...

@SpencerHurd
Copy link

Hi everyone,

Dimitiry was kind enough to walk me through the code changes. It looks to me like two of the three alterations are being correctly suppressed when Luminosity Opacity is provided. So the desired LuminosityTintColor is being used, and the desired LuminosityTintOpacity is being used.

However it looks like the TintOpacity is still being altered, which is undesirable.

Thank you very much!

@marcelwgn
Copy link
Collaborator Author

Thanks for your feedback @SpencerHurd and @DmitriyKomin !
I have changed the code not interfere in the tint opacity calculation if users have specified the tint luminosity opacity. If there is anything else missing, feel free to tell me!

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@DmitriyKomin
Copy link
Contributor

Thanks

Thanks for your feedback @SpencerHurd and @DmitriyKomin !
I have changed the code not interfere in the tint opacity calculation if users have specified the tint luminosity opacity. If there is anything else missing, feel free to tell me!

Thanks! Looks good, I approved the PR.

@StephenLPeters StephenLPeters merged commit 4409667 into microsoft:master Mar 18, 2020
@marcelwgn marcelwgn deleted the acrylic-luminosity-fix branch May 15, 2020 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Materials Reveal, Acrylic, lighting, etc. team-Rendering Issue for the Rendering team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Acrylic brushes change the values I provide
9 participants