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:
authorGermano <germano.costa@ig.com.br>2017-11-16 20:12:32 +0300
committerGermano <germano.costa@ig.com.br>2017-11-16 20:12:32 +0300
commit88c88c4610260ef3d00420c3e9fc3c1cd56aad14 (patch)
treeb9e49f253fd37c773c2098b583019e2240655885 /source/blender/gpu
parent562da211c21bc57e35d7b2dba2f36c2472de90a2 (diff)
Fix T51210: Draw Manager: Support for Metaball Drawing
Differential Revision: D2914
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/CMakeLists.txt1
-rw-r--r--source/blender/gpu/GPU_shader.h2
-rw-r--r--source/blender/gpu/intern/gpu_shader.c6
-rw-r--r--source/blender/gpu/shaders/gpu_shader_instance_mball_helpers_vert.glsl36
4 files changed, 44 insertions, 1 deletions
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index ec623554567..18a1ef36bdc 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -173,6 +173,7 @@ data_to_c_simple(shaders/gpu_shader_instance_edges_variying_color_geom.glsl SRC)
data_to_c_simple(shaders/gpu_shader_instance_edges_variying_color_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_instance_bone_envelope_solid_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_instance_bone_envelope_wire_vert.glsl SRC)
+data_to_c_simple(shaders/gpu_shader_instance_mball_helpers_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_3D_groundline_geom.glsl SRC)
data_to_c_simple(shaders/gpu_shader_3D_groundpoint_vert.glsl SRC)
diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h
index f3de3240c26..f2119a117e5 100644
--- a/source/blender/gpu/GPU_shader.h
+++ b/source/blender/gpu/GPU_shader.h
@@ -173,6 +173,8 @@ typedef enum GPUBuiltinShader {
GPU_SHADER_3D_INSTANCE_BONE_ENVELOPE_SOLID,
GPU_SHADER_3D_INSTANCE_BONE_ENVELOPE_WIRE,
+ GPU_SHADER_3D_INSTANCE_MBALL_HELPERS,
+
GPU_NUM_BUILTIN_SHADERS /* (not an actual shader) */
} GPUBuiltinShader;
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c
index cc1e1e8bb14..598722d372b 100644
--- a/source/blender/gpu/intern/gpu_shader.c
+++ b/source/blender/gpu/intern/gpu_shader.c
@@ -98,6 +98,7 @@ extern char datatoc_gpu_shader_instance_edges_variying_color_geom_glsl[];
extern char datatoc_gpu_shader_instance_edges_variying_color_vert_glsl[];
extern char datatoc_gpu_shader_instance_bone_envelope_solid_vert_glsl[];
extern char datatoc_gpu_shader_instance_bone_envelope_wire_vert_glsl[];
+extern char datatoc_gpu_shader_instance_mball_helpers_vert_glsl[];
extern char datatoc_gpu_shader_3D_groundpoint_vert_glsl[];
extern char datatoc_gpu_shader_3D_groundline_geom_glsl[];
@@ -805,7 +806,7 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
datatoc_gpu_shader_point_uniform_color_outline_aa_frag_glsl },
[GPU_SHADER_INSTANCE_UNIFORM_COLOR] = { datatoc_gpu_shader_instance_vert_glsl, datatoc_gpu_shader_uniform_color_frag_glsl },
- [GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE] =
+ [GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE] =
{ datatoc_gpu_shader_instance_variying_size_variying_color_vert_glsl,
datatoc_gpu_shader_flat_color_frag_glsl },
[GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SCALE] =
@@ -819,6 +820,9 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
datatoc_gpu_shader_simple_lighting_frag_glsl },
[GPU_SHADER_3D_INSTANCE_BONE_ENVELOPE_WIRE] = { datatoc_gpu_shader_instance_bone_envelope_wire_vert_glsl,
datatoc_gpu_shader_flat_color_frag_glsl },
+
+ [GPU_SHADER_3D_INSTANCE_MBALL_HELPERS] = { datatoc_gpu_shader_instance_mball_helpers_vert_glsl,
+ datatoc_gpu_shader_flat_color_frag_glsl },
};
if (builtin_shaders[shader] == NULL) {
diff --git a/source/blender/gpu/shaders/gpu_shader_instance_mball_helpers_vert.glsl b/source/blender/gpu/shaders/gpu_shader_instance_mball_helpers_vert.glsl
new file mode 100644
index 00000000000..819199c26c7
--- /dev/null
+++ b/source/blender/gpu/shaders/gpu_shader_instance_mball_helpers_vert.glsl
@@ -0,0 +1,36 @@
+
+/* This shader takes a 2D shape, puts it in 3D Object space such that is stays aligned with view,
+ * and scales the shape according to per-instance attributes
+ * Note that if the stiffness is zero, it assumes the scale is directly multiplied by the radius */
+
+
+ #define M_PI_2 1.570796f // pi/2
+
+uniform mat4 ViewProjectionMatrix;
+uniform vec3 screen_vecs[2];
+
+/* ---- Instanciated Attribs ---- */
+in vec2 pos;
+
+/* ---- Per instance Attribs ---- */
+in mat3x4 ScaleTranslationMatrix;
+in float radius;
+in vec3 color;
+
+flat out vec4 finalColor;
+
+void main()
+{
+ mat3 Scamat = mat3(ScaleTranslationMatrix);
+ vec4 world_pos = vec4(
+ ScaleTranslationMatrix[0][3],
+ ScaleTranslationMatrix[1][3],
+ ScaleTranslationMatrix[2][3],
+ 1.0);
+
+ vec3 screen_pos = screen_vecs[0].xyz * pos.x + screen_vecs[1].xyz * pos.y;
+ world_pos.xyz += Scamat * (screen_pos * radius);
+
+ gl_Position = ViewProjectionMatrix * world_pos;
+ finalColor = vec4(color, 1.0);
+}