[Bf-blender-cvs] [25ff7a4f2a7] blender2.8: DRW: Hair: Add additionnal subdivision smoothing support.
Clément Foucault
noreply at git.blender.org
Sun Jun 3 16:35:41 CEST 2018
Commit: 25ff7a4f2a753067aa2a0fdd2730a2ad1264821a
Author: Clément Foucault
Date: Sun Jun 3 16:44:55 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB25ff7a4f2a753067aa2a0fdd2730a2ad1264821a
DRW: Hair: Add additionnal subdivision smoothing support.
Only use catmull-rom interpolation for now. It's smoother and does not
exhibit artifacts.
===================================================================
M source/blender/draw/modes/shaders/common_hair_refine_vert.glsl
===================================================================
diff --git a/source/blender/draw/modes/shaders/common_hair_refine_vert.glsl b/source/blender/draw/modes/shaders/common_hair_refine_vert.glsl
index 96a3103f666..9f412c57db3 100644
--- a/source/blender/draw/modes/shaders/common_hair_refine_vert.glsl
+++ b/source/blender/draw/modes/shaders/common_hair_refine_vert.glsl
@@ -3,13 +3,53 @@
out vec4 outData;
+vec4 get_weights_cardinal(float t)
+{
+ float t2 = t * t;
+ float t3 = t2 * t;
+#if defined(CARDINAL)
+ float fc = 0.71;
+#else /* defined(CATMULL_ROM) */
+ float fc = 0.5;
+#endif
+
+ vec4 weights;
+ /* GLSL Optimized version of key_curve_position_weights() */
+ float fct = t * fc;
+ float fct2 = t2 * fc;
+ float fct3 = t3 * fc;
+ weights.x = ( fct2 * 2.0 - fct3) - fct;
+ weights.y = ( t3 * 2.0 - fct3) + (-t2 * 3.0 + fct2) + 1.0;
+ weights.z = (-t3 * 2.0 + fct3) + ( t2 * 3.0 - (2.0 * fct2)) + fct;
+ weights.w = fct3 - fct2;
+ return weights;
+}
+
+/* TODO(fclem): This one is buggy, find why. (it's not the optimization!!) */
+vec4 get_weights_bspline(float t)
+{
+ float t2 = t * t;
+ float t3 = t2 * t;
+
+ vec4 weights;
+ /* GLSL Optimized version of key_curve_position_weights() */
+ weights.xz = vec2(-0.16666666, -0.5) * t3 + (0.5 * t2 + 0.5 * vec2(-t, t) + 0.16666666);
+ weights.y = ( 0.5 * t3 - t2 + 0.66666666);
+ weights.w = ( 0.16666666 * t3);
+ return weights;
+}
+
+vec4 interp_data(vec4 v0, vec4 v1, vec4 v2, vec4 v3, vec4 w)
+{
+ return v0 * w.x + v1 * w.y + v2 * w.z + v3 * w.w;
+}
+
void main(void)
{
float interp_time;
vec4 data0, data1, data2, data3;
hair_get_interp_attribs(data0, data1, data2, data3, interp_time);
- /* TODO some interpolation. */
-
- outData = mix(data1, data2, interp_time);
+ vec4 weights = get_weights_cardinal(interp_time);
+ outData = interp_data(data0, data1, data2, data3, weights);
}
More information about the Bf-blender-cvs
mailing list