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

AtlasEngine: Fix grayscale blending shader #12734

Merged
1 commit merged into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/renderer/atlas/dwrite.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ float4 DWrite_GrayscaleBlend(float4 gammaRatios, float grayscaleEnhancedContrast
float blendEnhancedContrast = contrastBoost + DWrite_ApplyLightOnDarkContrastAdjustment(grayscaleEnhancedContrast, foregroundStraight);
float intensity = DWrite_CalcColorIntensity(foregroundStraight);
float contrasted = DWrite_EnhanceContrast(glyphAlpha, blendEnhancedContrast);
return foregroundColor * DWrite_ApplyAlphaCorrection(contrasted, intensity, gammaRatios);
float alphaCorrected = DWrite_ApplyAlphaCorrection(contrasted, intensity, gammaRatios);
return alphaCorrected * foregroundColor;
}

// Call this function to get the same gamma corrected alpha blending effect
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/atlas/shader_ps.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ float4 main(float4 pos: SV_Position): SV_Target
// See DWrite_GrayscaleBlend
float intensity = DWrite_CalcColorIntensity(foregroundStraight);
float contrasted = DWrite_EnhanceContrast(glyph.a, blendEnhancedContrast);
color = fg * DWrite_ApplyAlphaCorrection(contrasted, intensity, gammaRatios);
float4 alphaCorrected = DWrite_ApplyAlphaCorrection(contrasted, intensity, gammaRatios);
color = alphaBlendPremultiplied(color, alphaCorrected * fg);
Comment on lines +150 to +151
Copy link
Member Author

Choose a reason for hiding this comment

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

Here's a direct link showing the old code using alphaBlendPremultiplied here: 5964060#diff-ca02942b22b9baa16bcef607b524e1e4590793109f302c097b6705f0d1383310L135

}
}
}
Expand Down