[Bf-blender-cvs] [6144721778] clay-engine: Groundline/GroundPoint shader for lights

Clément Foucault noreply at git.blender.org
Thu Feb 2 14:18:43 CET 2017


Commit: 614472177899419fee19f08ba02ec8811391d25f
Author: Clément Foucault
Date:   Thu Feb 2 00:41:14 2017 +0100
Branches: clay-engine
https://developer.blender.org/rB614472177899419fee19f08ba02ec8811391d25f

Groundline/GroundPoint shader for lights

===================================================================

M	source/blender/gpu/CMakeLists.txt
M	source/blender/gpu/GPU_shader.h
M	source/blender/gpu/intern/gpu_shader.c
A	source/blender/gpu/shaders/gpu_shader_3D_groundline_geom.glsl
A	source/blender/gpu/shaders/gpu_shader_3D_groundline_vert.glsl
A	source/blender/gpu/shaders/gpu_shader_3D_groundpoint_vert.glsl

===================================================================

diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index 7aeb67a224..08aab95d55 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -153,6 +153,10 @@ data_to_c_simple(shaders/gpu_shader_3D_flat_color_vert.glsl SRC)
 data_to_c_simple(shaders/gpu_shader_3D_smooth_color_vert.glsl SRC)
 data_to_c_simple(shaders/gpu_shader_3D_smooth_color_frag.glsl SRC)
 
+data_to_c_simple(shaders/gpu_shader_3D_groundpoint_vert.glsl SRC)
+data_to_c_simple(shaders/gpu_shader_3D_groundline_vert.glsl SRC)
+data_to_c_simple(shaders/gpu_shader_3D_groundline_geom.glsl SRC)
+
 data_to_c_simple(shaders/gpu_shader_point_uniform_color_frag.glsl SRC)
 data_to_c_simple(shaders/gpu_shader_point_uniform_color_smooth_frag.glsl SRC)
 data_to_c_simple(shaders/gpu_shader_point_uniform_color_outline_smooth_frag.glsl SRC)
diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h
index 8cc9433c6a..ad39f585d3 100644
--- a/source/blender/gpu/GPU_shader.h
+++ b/source/blender/gpu/GPU_shader.h
@@ -131,6 +131,9 @@ typedef enum GPUBuiltinShader {
 	GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_SMOOTH,
 	GPU_SHADER_3D_POINT_VARYING_SIZE_UNIFORM_COLOR,
 	GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR,
+	/* lamp drawing */
+	GPU_SHADER_3D_GROUNDPOINT,
+	GPU_SHADER_3D_GROUNDLINE,
 
 	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 6370e4f7f8..fb32477f40 100644
--- a/source/blender/gpu/intern/gpu_shader.c
+++ b/source/blender/gpu/intern/gpu_shader.c
@@ -70,6 +70,10 @@ extern char datatoc_gpu_shader_3D_flat_color_vert_glsl[];
 extern char datatoc_gpu_shader_3D_smooth_color_vert_glsl[];
 extern char datatoc_gpu_shader_3D_smooth_color_frag_glsl[];
 
+extern char datatoc_gpu_shader_3D_groundpoint_vert_glsl[];
+extern char datatoc_gpu_shader_3D_groundline_vert_glsl[];
+extern char datatoc_gpu_shader_3D_groundline_geom_glsl[];
+
 extern char datatoc_gpu_shader_point_uniform_color_frag_glsl[];
 extern char datatoc_gpu_shader_point_uniform_color_smooth_frag_glsl[];
 extern char datatoc_gpu_shader_point_uniform_color_outline_smooth_frag_glsl[];
@@ -678,6 +682,11 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
 		                                 datatoc_gpu_shader_3D_smooth_color_frag_glsl },
 		[GPU_SHADER_3D_DEPTH_ONLY] = { datatoc_gpu_shader_3D_vert_glsl, datatoc_gpu_shader_depth_only_frag_glsl },
 
+		[GPU_SHADER_3D_GROUNDPOINT] = { datatoc_gpu_shader_3D_groundpoint_vert_glsl, datatoc_gpu_shader_point_uniform_color_frag_glsl },
+		[GPU_SHADER_3D_GROUNDLINE] = { datatoc_gpu_shader_3D_groundline_vert_glsl, 
+		                               datatoc_gpu_shader_uniform_color_frag_glsl,
+		                               datatoc_gpu_shader_3D_groundline_geom_glsl },
+
 		[GPU_SHADER_2D_POINT_FIXED_SIZE_UNIFORM_COLOR] =
 			{ datatoc_gpu_shader_2D_vert_glsl, datatoc_gpu_shader_point_uniform_color_frag_glsl },
 		[GPU_SHADER_2D_POINT_VARYING_SIZE_VARYING_COLOR] =
diff --git a/source/blender/gpu/shaders/gpu_shader_3D_groundline_geom.glsl b/source/blender/gpu/shaders/gpu_shader_3D_groundline_geom.glsl
new file mode 100644
index 0000000000..f16fa21b34
--- /dev/null
+++ b/source/blender/gpu/shaders/gpu_shader_3D_groundline_geom.glsl
@@ -0,0 +1,16 @@
+
+/* Make to be used with dynamic batching so no Model Matrix needed */
+uniform mat4 ViewProjectionMatrix;
+
+layout(points) in;
+layout(line_strip, max_vertices = 2) out;
+
+void main()
+{
+	vec3 vert = gl_in[0].gl_Position.xyz;
+	gl_Position = ViewProjectionMatrix * vec4(vert.xyz, 1.0);
+	EmitVertex();
+	gl_Position = ViewProjectionMatrix * vec4(vert.xy, 0.0, 1.0);
+	EmitVertex();
+	EndPrimitive();
+}
diff --git a/source/blender/gpu/shaders/gpu_shader_3D_groundline_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_groundline_vert.glsl
new file mode 100644
index 0000000000..60793bf56b
--- /dev/null
+++ b/source/blender/gpu/shaders/gpu_shader_3D_groundline_vert.glsl
@@ -0,0 +1,8 @@
+
+/* Does Nothing */
+in vec3 pos;
+
+void main()
+{
+	gl_Position = vec4(pos, 1.0);
+}
diff --git a/source/blender/gpu/shaders/gpu_shader_3D_groundpoint_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_groundpoint_vert.glsl
new file mode 100644
index 0000000000..be6b6014a1
--- /dev/null
+++ b/source/blender/gpu/shaders/gpu_shader_3D_groundpoint_vert.glsl
@@ -0,0 +1,11 @@
+
+/* Make to be used with dynamic batching so no Model Matrix needed */
+uniform mat4 ViewProjectionMatrix;
+
+in vec3 pos;
+
+void main()
+{
+	gl_Position = ViewProjectionMatrix * vec4(pos.xy, 0.0, 1.0);
+	gl_PointSize = 2.0;
+}




More information about the Bf-blender-cvs mailing list