Added zoom independent sharp edges to the SDF text example. (#1727)
This commit is contained in:
parent
1c45a882f7
commit
7f1068ef96
@ -12,14 +12,14 @@ uniform vec4 colDiffuse;
|
||||
out vec4 finalColor;
|
||||
|
||||
// NOTE: Add here your custom variables
|
||||
const float smoothing = 1.0/16.0;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Texel color fetching from texture sampler
|
||||
// NOTE: Calculate alpha using signed distance field (SDF)
|
||||
float distance = texture(texture0, fragTexCoord).a;
|
||||
float alpha = smoothstep(0.5 - smoothing, 0.5 + smoothing, distance);
|
||||
float distanceFromOutline = texture(texture0, fragTexCoord).a - 0.5;
|
||||
float distanceChangePerFragment = length(vec2(dFdx(distanceFromOutline), dFdy(distanceFromOutline)));
|
||||
float alpha = smoothstep(-distanceChangePerFragment, distanceChangePerFragment, distanceFromOutline);
|
||||
|
||||
// Calculate final fragment color
|
||||
finalColor = vec4(fragColor.rgb, fragColor.a*alpha);
|
||||
|
Loading…
Reference in New Issue
Block a user