diff options
Diffstat (limited to 'source/blender/draw/modes/shaders/armature_axes_vert.glsl')
-rw-r--r-- | source/blender/draw/modes/shaders/armature_axes_vert.glsl | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/draw/modes/shaders/armature_axes_vert.glsl b/source/blender/draw/modes/shaders/armature_axes_vert.glsl new file mode 100644 index 00000000000..3a70c5d8515 --- /dev/null +++ b/source/blender/draw/modes/shaders/armature_axes_vert.glsl @@ -0,0 +1,30 @@ + +uniform mat4 ViewProjectionMatrix; +uniform vec3 screenVecs[3]; + +/* ---- Instanciated Attribs ---- */ +in float axis; /* position on the axis. [0.0-1.0] is X axis, [1.0-2.0] is Y, etc... */ +in vec2 screenPos; +in vec3 colorAxis; + +/* ---- Per instance Attribs ---- */ +in mat4 InstanceModelMatrix; +in vec3 color; + +flat out vec4 finalColor; + +void main() +{ + vec3 chosen_axis = InstanceModelMatrix[int(axis)].xyz; + vec3 y_axis = InstanceModelMatrix[1].xyz; + vec3 bone_loc = InstanceModelMatrix[3].xyz; + vec3 wpos = bone_loc + y_axis + chosen_axis * fract(axis); + vec3 spos = screenVecs[0].xyz * screenPos.x + screenVecs[1].xyz * screenPos.y; + /* Scale uniformly by axis length */ + spos *= length(chosen_axis); + + gl_Position = ViewProjectionMatrix * vec4(wpos + spos, 1.0); + + finalColor.rgb = mix(color, colorAxis, 0.9); + finalColor.a = 1.0; +} |