-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix alpha blending in WebGL backends #650
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
bc22c4f
Revert "egui_web: make text thicker and less pixelated (#640)"
AsmPrgmC3 09efdc7
Fix WebgGL2 colors
AsmPrgmC3 b08d733
Fix WebgGL1 colors
AsmPrgmC3 64e41be
Add comments
AsmPrgmC3 4f948da
Remove color test warning for WebGL backend
AsmPrgmC3 9ed8651
Add changelog item for fixed alpha blending
AsmPrgmC3 c0dec5d
Revert debug change
AsmPrgmC3 a8c597a
cargo fmt
AsmPrgmC3 309d3c7
Correct comment
AsmPrgmC3 03ae062
Revert changes to WebGL1 backend, add color test warning again
AsmPrgmC3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
precision mediump float; | ||
uniform sampler2D u_sampler; | ||
varying vec4 v_rgba; | ||
varying vec2 v_tc; | ||
|
||
void main() { | ||
// The texture is set up with `SRGB8_ALPHA8`, so no need to decode here! | ||
vec4 texture_rgba = texture2D(u_sampler, v_tc); | ||
|
||
// Multiply vertex color with texture color (in linear space). | ||
// Linear color is written and blended in Framebuffer and converted to sRGB later | ||
gl_FragColor = v_rgba * texture_rgba; | ||
} |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
precision mediump float; | ||
uniform sampler2D u_sampler; | ||
varying vec2 v_tc; | ||
|
||
// 0-255 sRGB from 0-1 linear | ||
vec3 srgb_from_linear(vec3 rgb) { | ||
bvec3 cutoff = lessThan(rgb, vec3(0.0031308)); | ||
vec3 lower = rgb * vec3(3294.6); | ||
vec3 higher = vec3(269.025) * pow(rgb, vec3(1.0 / 2.4)) - vec3(14.025); | ||
return mix(higher, lower, vec3(cutoff)); | ||
} | ||
|
||
// 0-255 sRGBA from 0-1 linear | ||
vec4 srgba_from_linear(vec4 rgba) { | ||
return vec4(srgb_from_linear(rgba.rgb), 255.0 * rgba.a); | ||
} | ||
|
||
void main() { | ||
gl_FragColor = texture2D(u_sampler, v_tc); | ||
|
||
gl_FragColor = srgba_from_linear(gl_FragColor) / 255.; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
precision mediump float; | ||
attribute vec2 a_pos; | ||
varying vec2 v_tc; | ||
|
||
void main() { | ||
gl_Position = vec4(a_pos * 2. - 1., 0.0, 1.0); | ||
v_tc = a_pos; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.