diff options
author | Jeroen Bakker <jbakker> | 2021-05-26 18:02:32 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2021-05-26 18:03:37 +0300 |
commit | 8f9599d17e80254928d2d72081a4c7e0dee64038 (patch) | |
tree | d34ff981e4e0e72ce894042c82587a4266728b16 /source/blender/draw/intern/shaders/common_hair_refine_vert.glsl | |
parent | 87055dc71b0d50cd25660969b55cda7d44af6a12 (diff) |
DrawManager: Use Compute Shader to Update Hair.
This patch will use compute shaders to create the VBO for hair.
The previous implementation uses tranform feedback.
Timings master (transform feedback with GPU_USAGE_STATIC between 0.000069s and 0.000362s
Timings transform feedback with GPU_USAGE_DEVICE_ONLY. between 0.000057s and 0.000122s
Timings compute shader between 0.000032 and 0.000092s
Future improvements:
* Generate hair Index buffer using compute shaders: currently done single threaded on CPU, easy to add as compute shader.
Reviewed By: fclem
Differential Revision: https://developer.blender.org/D11057
Diffstat (limited to 'source/blender/draw/intern/shaders/common_hair_refine_vert.glsl')
-rw-r--r-- | source/blender/draw/intern/shaders/common_hair_refine_vert.glsl | 45 |
1 files changed, 2 insertions, 43 deletions
diff --git a/source/blender/draw/intern/shaders/common_hair_refine_vert.glsl b/source/blender/draw/intern/shaders/common_hair_refine_vert.glsl index 3f5e3f8226f..371d43827b9 100644 --- a/source/blender/draw/intern/shaders/common_hair_refine_vert.glsl +++ b/source/blender/draw/intern/shaders/common_hair_refine_vert.glsl @@ -3,47 +3,6 @@ out vec4 finalColor; -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; -} - #ifdef TF_WORKAROUND uniform int targetWidth; uniform int targetHeight; @@ -56,8 +15,8 @@ void main(void) vec4 data0, data1, data2, data3; hair_get_interp_attrs(data0, data1, data2, data3, interp_time); - vec4 weights = get_weights_cardinal(interp_time); - finalColor = interp_data(data0, data1, data2, data3, weights); + vec4 weights = hair_get_weights_cardinal(interp_time); + finalColor = hair_interp_data(data0, data1, data2, data3, weights); #ifdef TF_WORKAROUND int id = gl_VertexID - idOffset; |