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

Text UV clamping #2338

Merged
merged 1 commit into from Jan 24, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -6,6 +6,7 @@

varying vec3 vUv;
flat varying vec4 vColor;
flat varying vec4 vStRect;

#ifdef WR_VERTEX_SHADER
// Draw a text run to a cache target. These are always
@@ -41,12 +42,18 @@ void main(void) {

vUv = vec3(mix(st0, st1, aPosition.xy), res.layer);
vColor = prim.task.color;

// We clamp the texture coordinates to the half-pixel offset from the borders
// in order to avoid sampling outside of the texture area.
vec2 half_texel = vec2(0.5) / texture_size;
vStRect = vec4(min(st0, st1) + half_texel, max(st0, st1) - half_texel);
}
#endif

#ifdef WR_FRAGMENT_SHADER
void main(void) {
float a = texture(sColor0, vUv).a;
vec2 uv = clamp(vUv.xy, vStRect.xy, vStRect.zw);
float a = texture(sColor0, vec3(uv, vUv.z)).a;
oFragColor = vColor * a;
}
#endif
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.