diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-04-13 16:29:45 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-04-13 21:34:12 +0300 |
commit | 02273441dc2cebab122d6f6d1b0642a500a67409 (patch) | |
tree | bdcdf4d9ff8a1438704fc426f0d1dc859dee2437 /source/blender/draw/modes/shaders | |
parent | 1c01811cce00b799ee94aad24083ddf3954a5829 (diff) |
Draw Manager: lattice editmode drawing
Diffstat (limited to 'source/blender/draw/modes/shaders')
-rw-r--r-- | source/blender/draw/modes/shaders/edit_lattice_overlay_frag.glsl | 26 | ||||
-rw-r--r-- | source/blender/draw/modes/shaders/edit_lattice_overlay_loosevert_vert.glsl | 39 |
2 files changed, 65 insertions, 0 deletions
diff --git a/source/blender/draw/modes/shaders/edit_lattice_overlay_frag.glsl b/source/blender/draw/modes/shaders/edit_lattice_overlay_frag.glsl new file mode 100644 index 00000000000..57e96143c75 --- /dev/null +++ b/source/blender/draw/modes/shaders/edit_lattice_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_lattice_overlay_loosevert_vert.glsl b/source/blender/draw/modes/shaders/edit_lattice_overlay_loosevert_vert.glsl new file mode 100644 index 00000000000..d3fc56d1ee9 --- /dev/null +++ b/source/blender/draw/modes/shaders/edit_lattice_overlay_loosevert_vert.glsl @@ -0,0 +1,39 @@ + +/* Draw Lattice 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; +} |