Cleanup: remove duplicated shaders that only added clipping checks

Originally I wanted to avoid adding draw manager specific ifdef's all
over generic shaders however this isn't needed in so many places.

Also there are shaders that are only used by the draw manager so
duplicating them only to have the original unused doesn't make sense.
This commit is contained in:
Campbell Barton 2019-01-25 08:01:07 +11:00
parent 6d8394d38b
commit e72fa714a8
7 changed files with 25 additions and 42 deletions

View File

@ -325,8 +325,6 @@ data_to_c_simple(modes/shaders/particle_strand_frag.glsl SRC)
data_to_c_simple(modes/shaders/particle_strand_vert.glsl SRC)
data_to_c_simple(modes/shaders/sculpt_mask_vert.glsl SRC)
data_to_c_simple(modes/shaders/volume_velocity_vert.glsl SRC)
data_to_c_simple(modes/shaders/drw_shader_3D_vert.glsl SRC)
data_to_c_simple(modes/shaders/drw_shader_3D_smooth_color_vert.glsl SRC)
data_to_c_simple(engines/gpencil/shaders/gpencil_fill_vert.glsl SRC)
data_to_c_simple(engines/gpencil/shaders/gpencil_fill_frag.glsl SRC)

View File

@ -38,14 +38,13 @@
extern char datatoc_common_world_clip_lib_glsl[];
extern char datatoc_drw_shader_3D_vert_glsl[];
extern char datatoc_drw_shader_3D_smooth_color_vert_glsl[];
extern char datatoc_gpu_shader_uniform_color_frag_glsl[];
extern char datatoc_gpu_shader_3D_smooth_color_frag_glsl[];
extern char datatoc_gpu_shader_3D_smooth_color_vert_glsl[];
extern char datatoc_gpu_shader_3D_vert_glsl[];
extern char datatoc_gpu_shader_depth_only_frag_glsl[];
extern char datatoc_gpu_shader_flat_color_frag_glsl[];
extern char datatoc_gpu_shader_instance_camera_vert_glsl[];
extern char datatoc_gpu_shader_uniform_color_frag_glsl[];
/* cache of built-in shaders (each is created on first use) */
static struct {
@ -68,7 +67,7 @@ static GPUShader *drw_shader_get_builtin_shader_clipped(eGPUBuiltinShader shader
break;
}
shader = DRW_shader_create_from_arrays({
.vert = (const char *[]){world_clip_lib, datatoc_drw_shader_3D_vert_glsl, NULL},
.vert = (const char *[]){world_clip_lib, datatoc_gpu_shader_3D_vert_glsl, NULL},
.frag = (const char *[]){datatoc_gpu_shader_uniform_color_frag_glsl, NULL},
.defs = (const char *[]){world_clip_def, NULL}});
break;
@ -77,7 +76,7 @@ static GPUShader *drw_shader_get_builtin_shader_clipped(eGPUBuiltinShader shader
break;
}
shader = DRW_shader_create_from_arrays({
.vert = (const char *[]){world_clip_lib, datatoc_drw_shader_3D_smooth_color_vert_glsl, NULL},
.vert = (const char *[]){world_clip_lib, datatoc_gpu_shader_3D_smooth_color_vert_glsl, NULL},
.frag = (const char *[]){datatoc_gpu_shader_3D_smooth_color_frag_glsl, NULL},
.defs = (const char *[]){world_clip_def, NULL}});
break;
@ -86,7 +85,7 @@ static GPUShader *drw_shader_get_builtin_shader_clipped(eGPUBuiltinShader shader
break;
}
shader = DRW_shader_create_from_arrays({
.vert = (const char *[]){world_clip_lib, datatoc_drw_shader_3D_vert_glsl, NULL},
.vert = (const char *[]){world_clip_lib, datatoc_gpu_shader_3D_vert_glsl, NULL},
.frag = (const char *[]){datatoc_gpu_shader_depth_only_frag_glsl, NULL},
.defs = (const char *[]){world_clip_def, NULL}});
break;

View File

@ -105,7 +105,7 @@ extern char datatoc_gpu_shader_flat_color_frag_glsl[];
extern char datatoc_gpu_shader_flat_id_frag_glsl[];
extern char datatoc_common_fullscreen_vert_glsl[];
extern char datatoc_gpu_shader_uniform_color_frag_glsl[];
extern char datatoc_drw_shader_3D_vert_glsl[];
extern char datatoc_gpu_shader_3D_vert_glsl[];
/* *********** LISTS *********** */
typedef struct OBJECT_PassList {
@ -419,7 +419,7 @@ static void OBJECT_engine_init(void *vedata)
if (!sh_data->outline_resolve) {
/* Outline */
sh_data->outline_prepass = DRW_shader_create_from_arrays({
.vert = (const char *[]){world_clip_lib_or_empty, datatoc_drw_shader_3D_vert_glsl, NULL},
.vert = (const char *[]){world_clip_lib_or_empty, datatoc_gpu_shader_3D_vert_glsl, NULL},
.frag = (const char *[]){datatoc_object_outline_prepass_frag_glsl, NULL},
.defs = (const char *[]){world_clip_def_or_empty, NULL}});
sh_data->outline_prepass_wire = DRW_shader_create_from_arrays({
@ -495,7 +495,7 @@ static void OBJECT_engine_init(void *vedata)
/* Loose Points */
sh_data->loose_points = DRW_shader_create_from_arrays({
.vert = (const char *[]){world_clip_lib_or_empty, datatoc_drw_shader_3D_vert_glsl, NULL},
.vert = (const char *[]){world_clip_lib_or_empty, datatoc_gpu_shader_3D_vert_glsl, NULL},
.frag = (const char *[]){datatoc_object_loose_points_frag_glsl, NULL},
.defs = (const char *[]){world_clip_def_or_empty, NULL}});
}

View File

@ -1,17 +0,0 @@
/* Keep 'gpu_shader_3D_smooth_color_vert.glsl' compatible. */
uniform mat4 ModelViewProjectionMatrix;
uniform mat4 ModelMatrix;
in vec3 pos;
in vec4 color;
out vec4 finalColor;
void main()
{
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
finalColor = color;
#ifdef USE_WORLD_CLIP_PLANES
world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
#endif
}

View File

@ -1,13 +0,0 @@
/* Keep 'gpu_shader_3D_vert.glsl' compatible. */
uniform mat4 ModelViewProjectionMatrix;
uniform mat4 ModelMatrix;
in vec3 pos;
void main()
{
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
#ifdef USE_WORLD_CLIP_PLANES
world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
#endif
}

View File

@ -1,6 +1,10 @@
uniform mat4 ModelViewProjectionMatrix;
#ifdef USE_WORLD_CLIP_PLANES
uniform mat4 ModelMatrix;
#endif
in vec3 pos;
in vec4 color;
@ -10,4 +14,8 @@ void main()
{
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
finalColor = color;
#ifdef USE_WORLD_CLIP_PLANES
world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
#endif
}

View File

@ -1,9 +1,17 @@
uniform mat4 ModelViewProjectionMatrix;
#ifdef USE_WORLD_CLIP_PLANES
uniform mat4 ModelMatrix;
#endif
in vec3 pos;
void main()
{
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
#ifdef USE_WORLD_CLIP_PLANES
world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
#endif
}