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-11-27 15:49:00 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-11-27 15:49:22 +0300
commit32ab0647a53c16420993ca49563580cd48ac99af (patch)
tree622ad30a0f02894d6b7d132a61e726219fc7924d /source/blender/draw/modes/shaders/particle_strand_vert.glsl
parent4c1a01d1a07138aa9b80ab34cc3bde1df5ec141e (diff)
DRW: Implement Hair Weight drawing
Fixes T57931 Particle weight edit mode is not supported. There is a bug that prevent refresh of the toolsettings on which is based the weight / non-weight display selection (see T58086).
Diffstat (limited to 'source/blender/draw/modes/shaders/particle_strand_vert.glsl')
-rw-r--r--source/blender/draw/modes/shaders/particle_strand_vert.glsl42
1 files changed, 42 insertions, 0 deletions
diff --git a/source/blender/draw/modes/shaders/particle_strand_vert.glsl b/source/blender/draw/modes/shaders/particle_strand_vert.glsl
index 077d6a64f9b..9db62a581cb 100644
--- a/source/blender/draw/modes/shaders/particle_strand_vert.glsl
+++ b/source/blender/draw/modes/shaders/particle_strand_vert.glsl
@@ -9,11 +9,53 @@ out vec4 finalColor;
out vec2 radii;
#endif
+vec3 weight_to_rgb(float weight)
+{
+ vec3 r_rgb;
+ float blend = ((weight / 2.0) + 0.5);
+
+ if (weight <= 0.25) { /* blue->cyan */
+ r_rgb[0] = 0.0;
+ r_rgb[1] = blend * weight * 4.0;
+ r_rgb[2] = blend;
+ }
+ else if (weight <= 0.50) { /* cyan->green */
+ r_rgb[0] = 0.0;
+ r_rgb[1] = blend;
+ r_rgb[2] = blend * (1.0 - ((weight - 0.25) * 4.0));
+ }
+ else if (weight <= 0.75) { /* green->yellow */
+ r_rgb[0] = blend * ((weight - 0.50) * 4.0);
+ r_rgb[1] = blend;
+ r_rgb[2] = 0.0;
+ }
+ else if (weight <= 1.0) { /* yellow->red */
+ r_rgb[0] = blend;
+ r_rgb[1] = blend * (1.0 - ((weight - 0.75) * 4.0));
+ r_rgb[2] = 0.0;
+ }
+ else {
+ /* exceptional value, unclamped or nan,
+ * avoid uninitialized memory use */
+ r_rgb[0] = 1.0;
+ r_rgb[1] = 0.0;
+ r_rgb[2] = 1.0;
+ }
+
+ return r_rgb;
+}
+
+#define DECOMPRESS_RANGE 1.0039
+
void main()
{
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
+#ifdef USE_WEIGHT
+ finalColor = vec4(weight_to_rgb(color * DECOMPRESS_RANGE), 1.0);
+#else
finalColor = mix(colorWire, colorEdgeSelect, color);
+#endif
#ifdef USE_POINTS
gl_PointSize = sizeVertex;