diff options
author | Wieland Hagen <wieland.hagen@kdab.com> | 2016-12-28 13:25:38 +0700 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-01-30 18:56:16 +0000 |
commit | 18ad771187f3d9a7d14d1a98d71ce64ed8ff15d4 (patch) | |
tree | c5e82336db09f911066912f011771ff1ca35fb77 /src/extras/shaders/gl3/distancefieldtext.vert | |
parent | 6c94c0395d060b4f4e07da1b86348f3e0e7a9b65 (diff) |
QDistanceFieldMaterial: distance field text rendering shaders
One QDistanceFieldMaterial will have to be created for each distinct
texture atlas that is used to store the glyphs of fonts.
The smaller the glyphs are in pixel space (i.e. the more texels per
pixel), the smoother we render the threshold between inside-glyph
and outside-glyph. We measure the size of the glyph by taking
the per-fragment delta of the texture coordinates. This is to reduce
aiasing as much as possible without resorting to screen-space AA
techniques.
The same method is used in the QtQuick renderer, but here in this case
we allow a much smoother threshold for small glyphs.
Change-Id: I6632e7e1da31126c84f5bd2b4a4498377bdad79e
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/extras/shaders/gl3/distancefieldtext.vert')
-rw-r--r-- | src/extras/shaders/gl3/distancefieldtext.vert | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/extras/shaders/gl3/distancefieldtext.vert b/src/extras/shaders/gl3/distancefieldtext.vert new file mode 100644 index 000000000..9bd2a0a90 --- /dev/null +++ b/src/extras/shaders/gl3/distancefieldtext.vert @@ -0,0 +1,19 @@ +#version 150 core + +in vec3 vertexPosition; +in vec2 vertexTexCoord; + +out vec3 position; +out vec2 texCoord; + +uniform mat4 modelView; +uniform mat4 mvp; + +void main() +{ + texCoord = vertexTexCoord; + position = vec3(modelView * vec4(vertexPosition, 1.0)); + + gl_Position = mvp * vec4(vertexPosition, 1.0); +} + |