-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use file inserts and string replacements in overlay shaders
PiperOrigin-RevId: 638251955
- Loading branch information
Showing
2 changed files
with
51 additions
and
72 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
libraries/effect/src/main/assets/shaders/insert_overlay_fragment_shader_methods.glsl
This file contains 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,21 @@ | ||
// Manually implementing the CLAMP_TO_BORDER texture wrapping option | ||
// (https://open.gl/textures) since it's not implemented until OpenGL ES 3.2. | ||
vec4 getClampToBorderOverlayColor(sampler2D texSampler, vec2 texSamplingCoord, | ||
float alphaScale) { | ||
if (texSamplingCoord.x > 1.0 || texSamplingCoord.x < 0.0 || | ||
texSamplingCoord.y > 1.0 || texSamplingCoord.y < 0.0) { | ||
return vec4(0.0, 0.0, 0.0, 0.0); | ||
} else { | ||
vec4 overlayColor = vec4(texture2D(texSampler, texSamplingCoord)); | ||
overlayColor.a = alphaScale * overlayColor.a; | ||
return overlayColor; | ||
} | ||
} | ||
|
||
vec4 getMixColor(vec4 videoColor, vec4 overlayColor) { | ||
vec4 outputColor; | ||
outputColor.rgb = overlayColor.rgb * overlayColor.a + | ||
videoColor.rgb * (1.0 - overlayColor.a); | ||
outputColor.a = overlayColor.a + videoColor.a * (1.0 - overlayColor.a); | ||
return outputColor; | ||
} |
This file contains 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