diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-04-15 09:46:17 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-04-19 17:38:44 +0300 |
commit | cdba73c8faf7ec28de66b380ed2952d42a2aac38 (patch) | |
tree | a8c07ccfcbf3fe513ba1c83cfc392a0d5a903841 /source/blender/draw/modes/shaders | |
parent | ce6b01f203caae98a648bb3024479dba2e033c2a (diff) |
Draw Manager: curve support
Draws the curve centerline and editmode verts/handles.
Handle theme colors, and normal display still need adding.
Diffstat (limited to 'source/blender/draw/modes/shaders')
-rw-r--r-- | source/blender/draw/modes/shaders/edit_curve_overlay_frag.glsl | 26 | ||||
-rw-r--r-- | source/blender/draw/modes/shaders/edit_curve_overlay_loosevert_vert.glsl | 39 |
2 files changed, 65 insertions, 0 deletions
diff --git a/source/blender/draw/modes/shaders/edit_curve_overlay_frag.glsl b/source/blender/draw/modes/shaders/edit_curve_overlay_frag.glsl new file mode 100644 index 00000000000..57e96143c75 --- /dev/null +++ b/source/blender/draw/modes/shaders/edit_curve_overlay_frag.glsl @@ -0,0 +1,26 @@ + +flat in int vertFlag; + +#define VERTEX_SELECTED (1 << 0) +#define VERTEX_ACTIVE (1 << 1) + +#if __VERSION__ == 120 + #define FragColor gl_FragColor +#else + out vec4 FragColor; +#endif + +void main() +{ + /* TODO: vertex size */ + + if ((vertFlag & VERTEX_SELECTED) != 0) { + FragColor = colorVertexSelect; + } + else if ((vertFlag & VERTEX_ACTIVE) != 0) { + FragColor = colorEditMeshActive; + } + else { + FragColor = colorVertex; + } +} diff --git a/source/blender/draw/modes/shaders/edit_curve_overlay_loosevert_vert.glsl b/source/blender/draw/modes/shaders/edit_curve_overlay_loosevert_vert.glsl new file mode 100644 index 00000000000..1af529e5482 --- /dev/null +++ b/source/blender/draw/modes/shaders/edit_curve_overlay_loosevert_vert.glsl @@ -0,0 +1,39 @@ + +/* Draw Curve Vertices */ + +uniform mat4 ModelViewProjectionMatrix; +uniform vec2 viewportSize; + +in vec3 pos; +in int data; + +/* these are the same for all vertices + * and does not need interpolation */ +flat out int vertFlag; +flat out int clipCase; + +/* See fragment shader */ +noperspective out vec4 eData1; +flat out vec4 eData2; + +/* project to screen space */ +vec2 proj(vec4 pos) +{ + return (0.5 * (pos.xy / pos.w) + 0.5) * viewportSize; +} + +void main() +{ + clipCase = 0; + + vec4 pPos = ModelViewProjectionMatrix * vec4(pos, 1.0); + + /* only verterx position 0 is used */ + eData1 = eData2 = vec4(1e10); + eData2.zw = proj(pPos); + + vertFlag = data; + + gl_PointSize = sizeEdgeFix; + gl_Position = pPos; +} |