diff --git a/libraries/render-utils/src/sdf_text3D.slf b/libraries/render-utils/src/sdf_text3D.slf index faa4d02bfa..1e11cd984d 100644 --- a/libraries/render-utils/src/sdf_text3D.slf +++ b/libraries/render-utils/src/sdf_text3D.slf @@ -19,17 +19,14 @@ uniform vec4 Color; // the interpolated normal in vec3 _normal; in vec2 _texCoord0; -/* -layout(location = 0) out vec4 _fragColor0; -layout(location = 1) out vec4 _fragColor1; -layout(location = 2) out vec4 _fragColor2; -*/ const float gamma = 2.2; const float smoothing = 256.0; const float interiorCutoff = 0.8; const float outlineExpansion = 0.2; + + void main() { // retrieve signed distance float sdf = texture(Font, _texCoord0).g; @@ -49,19 +46,15 @@ void main() { // gamma correction for linear attenuation a = pow(a, 1.0 / gamma); + // discard if unvisible if (a < 0.01) { discard; } - // final color - /* _fragColor0 = vec4(Color.rgb, Color.a * a); - _fragColor1 = vec4(normalize(_normal.xyz), 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 0.5); - _fragColor2 = vec4(Color.rgb, 10 / 128.0); - */ packDeferredFragmentLightmap( normalize(_normal), - Color.a * a, - Color.rgb, + 1.0, + vec3(1.0), DEFAULT_ROUGHNESS, DEFAULT_METALLIC, DEFAULT_SPECULAR, diff --git a/libraries/render-utils/src/text/Font.cpp b/libraries/render-utils/src/text/Font.cpp index 2e86d09fe0..762a7fb723 100644 --- a/libraries/render-utils/src/text/Font.cpp +++ b/libraries/render-utils/src/text/Font.cpp @@ -3,6 +3,8 @@ #include #include +#include + #include #include "sdf_text3D_vert.h" @@ -354,7 +356,10 @@ void Font::drawString(gpu::Batch& batch, float x, float y, const QString& str, c batch.setPipeline(layered ? _layeredPipeline : _pipeline); batch.setResourceTexture(_fontLoc, _texture); batch._glUniform1i(_outlineLoc, (effectType == OUTLINE_EFFECT)); - batch._glUniform4fv(_colorLoc, 1, (const float*)color); + + // need the gamma corrected color here + glm::vec4 lrgba = glm::vec4(ColorUtils::toLinearVec3(glm::vec3(*color)), color->a); + batch._glUniform4fv(_colorLoc, 1, (const float*)&lrgba); batch.setInputFormat(_format); batch.setInputBuffer(0, _verticesBuffer, 0, _format->getChannels().at(0)._stride);