shader discard alpha < 0.5
quick fix for depth with treshold alpha later: depth peeling
This commit is contained in:
parent
99bb561291
commit
a0af51fdb4
2 changed files with 9 additions and 2 deletions
|
@ -24,7 +24,7 @@ float screenPxRange() {
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 bgColor = vec4(fontColor.rgb,0);
|
vec4 bgColor = vec4(fontColor.rgb,0.0);
|
||||||
vec4 fgColor = fontColor;
|
vec4 fgColor = fontColor;
|
||||||
|
|
||||||
vec3 msdf_rgb = texture(msdf, texCoordVarying).rgb;
|
vec3 msdf_rgb = texture(msdf, texCoordVarying).rgb;
|
||||||
|
@ -32,6 +32,11 @@ void main()
|
||||||
float screenPxDistance = screenPxRange()*(sd - 0.5);
|
float screenPxDistance = screenPxRange()*(sd - 0.5);
|
||||||
float opacity = clamp(screenPxDistance + 0.5, 0.0, 1.0);
|
float opacity = clamp(screenPxDistance + 0.5, 0.0, 1.0);
|
||||||
|
|
||||||
|
if (opacity < 0.5)
|
||||||
|
discard;
|
||||||
outputColor = mix(bgColor, fgColor, opacity);
|
outputColor = mix(bgColor, fgColor, opacity);
|
||||||
|
|
||||||
//outputColor = vec4(opacity, 1.0-opacity, 0.0, 1.0);
|
//outputColor = vec4(opacity, 1.0-opacity, 0.0, 1.0);
|
||||||
|
//outputColor = vec4(1.0-msdf_rgb.rgb, 1.0);
|
||||||
|
//outputColor = vec4(1.0,0.0,1.0,1.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,12 +25,14 @@ float screenPxRange() {
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 bgColor = vec4(fontColor.rgb,0);
|
vec4 bgColor = vec4(1.0-fontColor.rgb,0);
|
||||||
vec4 fgColor = fontColor;
|
vec4 fgColor = fontColor;
|
||||||
|
|
||||||
vec3 msdf_rgb = texture(msdf, texCoordVarying).rgb;
|
vec3 msdf_rgb = texture(msdf, texCoordVarying).rgb;
|
||||||
float sd = median(msdf_rgb.r, msdf_rgb.g, msdf_rgb.b);
|
float sd = median(msdf_rgb.r, msdf_rgb.g, msdf_rgb.b);
|
||||||
float screenPxDistance = screenPxRange()*(sd - 0.5);
|
float screenPxDistance = screenPxRange()*(sd - 0.5);
|
||||||
float opacity = clamp(screenPxDistance + 0.5, 0.0, 1.0);
|
float opacity = clamp(screenPxDistance + 0.5, 0.0, 1.0);
|
||||||
|
if (opacity < 0.5)
|
||||||
|
discard;
|
||||||
outputColor = mix(bgColor, fgColor, opacity);
|
outputColor = mix(bgColor, fgColor, opacity);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue