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:
authorClément Foucault <foucault.clem@gmail.com>2018-05-05 21:51:16 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-05-05 22:04:21 +0300
commit817cf2a317388b8bfc29ddf27a49b0628eb8e1ab (patch)
treeba91e9fbe5ed957d05634de1f0df514d2b4d91ad /source/blender/draw/modes/shaders/armature_shape_solid_vert.glsl
parentb2188d631a81972f38548a333757eb21ddd784b0 (diff)
Armature: Rename bone shaders and add 2 colors smooth blending.
This will enable us to do more nice stuff in future commits. This commit is a temporary commit, it will compile but will crash if trying to display any armature. Next commit does work.
Diffstat (limited to 'source/blender/draw/modes/shaders/armature_shape_solid_vert.glsl')
-rw-r--r--source/blender/draw/modes/shaders/armature_shape_solid_vert.glsl37
1 files changed, 37 insertions, 0 deletions
diff --git a/source/blender/draw/modes/shaders/armature_shape_solid_vert.glsl b/source/blender/draw/modes/shaders/armature_shape_solid_vert.glsl
new file mode 100644
index 00000000000..701fc9c38ab
--- /dev/null
+++ b/source/blender/draw/modes/shaders/armature_shape_solid_vert.glsl
@@ -0,0 +1,37 @@
+
+uniform mat3 NormalMatrix;
+uniform mat4 ViewMatrixInverse;
+uniform mat4 ViewProjectionMatrix;
+
+uniform mat4 ViewMatrix;
+uniform mat4 ProjectionMatrix;
+uniform vec2 viewportSize;
+
+/* ---- Instanciated Attribs ---- */
+in vec3 pos;
+in vec3 nor;
+
+/* ---- Per instance Attribs ---- */
+in mat4 InstanceModelMatrix;
+in vec3 boneColor;
+in vec3 stateColor;
+
+flat out vec4 finalColor;
+
+void main()
+{
+ mat3 NormalMatrix = transpose(inverse(mat3(ViewMatrix * InstanceModelMatrix)));
+ vec3 normal = normalize(NormalMatrix * nor);
+
+ /* Do lighting at an angle to avoid flat shading on front facing bone. */
+ const vec3 light = vec3(0.1, 0.1, 0.8);
+ float n = dot(normal, light);
+
+ /* Smooth lighting factor. */
+ const float s = 0.2; /* [0.0-0.5] range */
+ float fac = clamp((n * (1.0 - s)) + s, 0.0, 1.0);
+ finalColor.rgb = mix(stateColor, boneColor, fac);
+ finalColor.a = 1.0;
+
+ gl_Position = ViewProjectionMatrix * (InstanceModelMatrix * vec4(pos, 1.0));
+}