diff options
author | Mike Erwin <significant.bit@gmail.com> | 2016-09-17 14:33:02 +0300 |
---|---|---|
committer | Mike Erwin <significant.bit@gmail.com> | 2016-09-17 14:33:48 +0300 |
commit | 1b1275f0db85101345def817fee486beebaa6b9a (patch) | |
tree | 1c6338f84ca852f587e213cea609a3f026984886 /source/blender/gpu/shaders/gpu_shader_text_vert.glsl | |
parent | c3034afa586e3c5009f852e42c6a46000daa2551 (diff) |
add GPU_SHADER_TEXT for font rendering
With USE_GLSL enabled, GPU_basic_shader(TEXTURE|COLOR) always rendered black. New shader uses a solid color + alpha channel of texture (which in our case is a font glyph). See fragment shader for details.
I prefer this approah -- multiple shaders that each do one thing well (and are easy to read/write/understand), instead of one shader that can do many things given the right options.
Diffstat (limited to 'source/blender/gpu/shaders/gpu_shader_text_vert.glsl')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_text_vert.glsl | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_text_vert.glsl b/source/blender/gpu/shaders/gpu_shader_text_vert.glsl new file mode 100644 index 00000000000..8449c4229b3 --- /dev/null +++ b/source/blender/gpu/shaders/gpu_shader_text_vert.glsl @@ -0,0 +1,16 @@ + +// TODO(merwin): +// - use modern GLSL +// - uniform color, not per vertex +// - generic attrib inputs (2D pos, tex coord) + +flat varying vec4 color; +varying vec2 texcoord; + +void main() +{ + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + + color = gl_Color; + texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).st; +} |