Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Erwin <significant.bit@gmail.com>2016-09-17 14:33:02 +0300
committerMike Erwin <significant.bit@gmail.com>2016-09-17 14:33:48 +0300
commit1b1275f0db85101345def817fee486beebaa6b9a (patch)
tree1c6338f84ca852f587e213cea609a3f026984886 /source/blender/gpu/shaders/gpu_shader_text_frag.glsl
parentc3034afa586e3c5009f852e42c6a46000daa2551 (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_frag.glsl')
-rw-r--r--source/blender/gpu/shaders/gpu_shader_text_frag.glsl14
1 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_text_frag.glsl b/source/blender/gpu/shaders/gpu_shader_text_frag.glsl
new file mode 100644
index 00000000000..4869a6360fa
--- /dev/null
+++ b/source/blender/gpu/shaders/gpu_shader_text_frag.glsl
@@ -0,0 +1,14 @@
+
+flat varying vec4 color;
+varying vec2 texcoord;
+
+uniform sampler2D glyph;
+
+void main()
+{
+ // input color replaces texture color
+ gl_FragColor.rgb = color.rgb;
+
+ // modulate input alpha & texture alpha
+ gl_FragColor.a = color.a * texture2D(glyph, texcoord).a;
+}