Merge pull request #7256 from samcake/orange

Fix the text rendering Bug
This commit is contained in:
Brad Hefta-Gaub 2016-03-07 09:11:55 -08:00
commit 3fe89c0cdf
2 changed files with 11 additions and 13 deletions

View file

@ -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,

View file

@ -3,6 +3,8 @@
#include <QFile>
#include <QImage>
#include <ColorUtils.h>
#include <StreamHelpers.h>
#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);