diff options
author | Mike Erwin <significant.bit@gmail.com> | 2017-02-28 10:18:52 +0300 |
---|---|---|
committer | Mike Erwin <significant.bit@gmail.com> | 2017-02-28 10:18:52 +0300 |
commit | 8a76049e84c79c6267c3c51fe32145f0ebf7805c (patch) | |
tree | 4adbfad5728d98aeb64bebec5a8cb3a69086844f /source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_outline_aa_vert.glsl | |
parent | e7d57628c955c1843c70c8fc5023f5d8954847bd (diff) |
rename built-in point shaders, SMOOTH --> AA
Updated shader names and code that uses them.
All of these shaders produce round points that are anti-aliased and blended against the background.
These were initially named SMOOTH because they replace glEnable(GL_POINT_SMOOTH). But SMOOTH in shader-land refers to vertex attribute interpolation (like glShadeModel(GL_SMOOTH)).
Using SMOOTH to mean two things is confusing, so we now use AA to mean "the point is anti-aliased".
Diffstat (limited to 'source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_outline_aa_vert.glsl')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_outline_aa_vert.glsl | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_outline_aa_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_outline_aa_vert.glsl new file mode 100644 index 00000000000..a37ae16f837 --- /dev/null +++ b/source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_outline_aa_vert.glsl @@ -0,0 +1,29 @@ + +uniform mat4 ModelViewProjectionMatrix; +uniform float size; +uniform float outlineWidth; + +#if __VERSION__ == 120 + attribute vec2 pos; + varying vec4 radii; +#else + in vec2 pos; + out vec4 radii; +#endif + +void main() { + gl_Position = ModelViewProjectionMatrix * vec4(pos, 0.0, 1.0); + gl_PointSize = size; + + // calculate concentric radii in pixels + float radius = 0.5 * size; + + // start at the outside and progress toward the center + radii[0] = radius; + radii[1] = radius - 1.0; + radii[2] = radius - outlineWidth; + radii[3] = radius - outlineWidth - 1.0; + + // convert to PointCoord units + radii /= size; +} |