Commit: 198e3a35c884fe18a3abc2cbbe82c1c2398eb556
Author: Mike Erwin
Date:   Thu Oct 6 16:31:49 2016 -0400
Branches: blender2.8
https://developer.blender.org/rB198e3a35c884fe18a3abc2cbbe82c1c2398eb556

OpenGL: another built-in shader for 2D points

GPU_SHADER_2D_POINT_VARYING_SIZE_VARYING_COLOR

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

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_2D_point_varying_size_varying_color_vert.glsl

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

diff --git a/source/blender/gpu/CMakeLists.txt 
b/source/blender/gpu/CMakeLists.txt
index 50d587c..9d747ba 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -140,6 +140,7 @@ 
data_to_c_simple(shaders/gpu_shader_point_varying_color_frag.glsl SRC)
 
data_to_c_simple(shaders/gpu_shader_3D_point_fixed_size_varying_color_vert.glsl 
SRC)
 data_to_c_simple(shaders/gpu_shader_3D_point_varying_size_no_color_vert.glsl 
SRC)
 
data_to_c_simple(shaders/gpu_shader_3D_point_varying_size_varying_color_vert.glsl
 SRC)
+data_to_c_simple(shaders/gpu_shader_2D_point_varying_size_varying_color_vert.glsl
 SRC)
 
 data_to_c_simple(shaders/gpu_shader_text_vert.glsl SRC)
 data_to_c_simple(shaders/gpu_shader_text_frag.glsl SRC)
diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h
index 042aa7f..9fc1f29 100644
--- a/source/blender/gpu/GPU_shader.h
+++ b/source/blender/gpu/GPU_shader.h
@@ -106,6 +106,7 @@ typedef enum GPUBuiltinShader {
        GPU_SHADER_2D_TEXTURE_RECT,
        /* points */
        GPU_SHADER_2D_POINT_FIXED_SIZE_UNIFORM_COLOR,
+       GPU_SHADER_2D_POINT_VARYING_SIZE_VARYING_COLOR,
        GPU_SHADER_3D_POINT_FIXED_SIZE_UNIFORM_COLOR,
        GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR,
        GPU_SHADER_3D_POINT_VARYING_SIZE_UNIFORM_COLOR,
diff --git a/source/blender/gpu/intern/gpu_shader.c 
b/source/blender/gpu/intern/gpu_shader.c
index 01ced90..1b9747b 100644
--- a/source/blender/gpu/intern/gpu_shader.c
+++ b/source/blender/gpu/intern/gpu_shader.c
@@ -66,6 +66,7 @@ extern char 
datatoc_gpu_shader_point_varying_color_frag_glsl[];
 extern char datatoc_gpu_shader_3D_point_fixed_size_varying_color_vert_glsl[];
 extern char datatoc_gpu_shader_3D_point_varying_size_no_color_vert_glsl[];
 extern char datatoc_gpu_shader_3D_point_varying_size_varying_color_vert_glsl[];
+extern char datatoc_gpu_shader_2D_point_varying_size_varying_color_vert_glsl[];
 
 extern char datatoc_gpu_shader_text_vert_glsl[];
 extern char datatoc_gpu_shader_text_frag_glsl[];
@@ -111,6 +112,7 @@ static struct GPUShadersGlobal {
                GPUShader *depth_only_3D;
                /* points */
                GPUShader *point_fixed_size_uniform_color_2D;
+               GPUShader *point_varying_size_varying_color_2D;
                GPUShader *point_fixed_size_uniform_color_3D;
                GPUShader *point_fixed_size_varying_color_3D;
                GPUShader *point_varying_size_uniform_color_3D;
@@ -729,6 +731,14 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader 
shader)
                                        NULL, NULL, NULL, 0, 0, 0);
                        retval = GG.shaders.point_fixed_size_uniform_color_2D;
                        break;
+               case GPU_SHADER_2D_POINT_VARYING_SIZE_VARYING_COLOR:
+                       if (!GG.shaders.point_varying_size_varying_color_2D)
+                               GG.shaders.point_varying_size_varying_color_2D 
= GPU_shader_create(
+                                       
datatoc_gpu_shader_2D_point_varying_size_varying_color_vert_glsl,
+                                       
datatoc_gpu_shader_point_varying_color_frag_glsl,
+                                       NULL, NULL, NULL, 0, 0, 0);
+                       retval = GG.shaders.point_varying_size_varying_color_2D;
+                       break;
                case GPU_SHADER_3D_POINT_FIXED_SIZE_UNIFORM_COLOR:
                        if (!GG.shaders.point_fixed_size_uniform_color_3D)
                                GG.shaders.point_fixed_size_uniform_color_3D = 
GPU_shader_create(
@@ -850,8 +860,6 @@ GPUShader *GPU_shader_get_builtin_fx_shader(int effect, 
bool persp)
 
 void GPU_shader_free_builtin_shaders(void)
 {
-       int i;
-
        if (GG.shaders.vsm_store) {
                GPU_shader_free(GG.shaders.vsm_store);
                GG.shaders.vsm_store = NULL;
@@ -922,6 +930,11 @@ void GPU_shader_free_builtin_shaders(void)
                GG.shaders.point_fixed_size_uniform_color_2D = NULL;
        }
 
+       if (GG.shaders.point_varying_size_varying_color_2D) {
+               GPU_shader_free(GG.shaders.point_varying_size_varying_color_2D);
+               GG.shaders.point_varying_size_varying_color_2D = NULL;
+       }
+
        if (GG.shaders.point_fixed_size_uniform_color_3D) {
                GPU_shader_free(GG.shaders.point_fixed_size_uniform_color_3D);
                GG.shaders.point_fixed_size_uniform_color_3D = NULL;
@@ -942,7 +955,7 @@ void GPU_shader_free_builtin_shaders(void)
                GG.shaders.point_varying_size_varying_color_3D = NULL;
        }
 
-       for (i = 0; i < 2 * MAX_FX_SHADERS; ++i) {
+       for (int i = 0; i < 2 * MAX_FX_SHADERS; ++i) {
                if (GG.shaders.fx_shaders[i]) {
                        GPU_shader_free(GG.shaders.fx_shaders[i]);
                        GG.shaders.fx_shaders[i] = NULL;
diff --git 
a/source/blender/gpu/shaders/gpu_shader_2D_point_varying_size_varying_color_vert.glsl
 
b/source/blender/gpu/shaders/gpu_shader_2D_point_varying_size_varying_color_vert.glsl
new file mode 100644
index 0000000..4cdd43a
--- /dev/null
+++ 
b/source/blender/gpu/shaders/gpu_shader_2D_point_varying_size_varying_color_vert.glsl
@@ -0,0 +1,19 @@
+
+#if __VERSION__ == 120
+  attribute vec2 pos;
+  attribute float size;
+  attribute vec4 color;
+  varying vec4 finalColor;
+#else
+  in vec2 pos;
+  in float size;
+  in vec4 color;
+  out vec4 finalColor;
+#endif
+
+void main()
+{
+       gl_Position = gl_ModelViewProjectionMatrix * vec4(pos, 0.0, 1.0);
+       gl_PointSize = size;
+       finalColor = color;
+}

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to