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:
authorCampbell Barton <ideasman42@gmail.com>2019-01-21 15:51:34 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-01-21 15:55:53 +0300
commit9bc47ed0f6d0db9e43af30c741a7e5ac347cbecd (patch)
treeca8dbd6ce37e3529a3c5fe8c0bc944c535128ec3 /source/blender/draw/modes
parent0c829e8240eebd7ce4ed9d61f8682c0d6bf534f4 (diff)
Fix clipping shaders with some AMD/Intel drivers
Caused: error: unsized array index must be constant Use hard coded number of clipping planes, copying the 4th to 5 & 6 when only 4 are used.
Diffstat (limited to 'source/blender/draw/modes')
-rw-r--r--source/blender/draw/modes/edit_mesh_mode.c33
-rw-r--r--source/blender/draw/modes/overlay_mode.c16
-rw-r--r--source/blender/draw/modes/shaders/common_world_clip_lib.glsl25
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_facedot_vert.glsl12
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_facefill_vert.glsl12
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_geom_edge.glsl8
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl12
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_points_vert.glsl12
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl20
-rw-r--r--source/blender/draw/modes/shaders/edit_normals_geom.glsl8
-rw-r--r--source/blender/draw/modes/shaders/edit_normals_vert.glsl12
-rw-r--r--source/blender/draw/modes/shaders/overlay_face_orientation_vert.glsl12
-rw-r--r--source/blender/draw/modes/shaders/overlay_face_wireframe_geom.glsl8
-rw-r--r--source/blender/draw/modes/shaders/overlay_face_wireframe_vert.glsl12
-rw-r--r--source/blender/draw/modes/shaders/paint_weight_vert.glsl12
15 files changed, 76 insertions, 138 deletions
diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c
index 1a3d7fb4cb4..59aa4ea5ff0 100644
--- a/source/blender/draw/modes/edit_mesh_mode.c
+++ b/source/blender/draw/modes/edit_mesh_mode.c
@@ -42,6 +42,7 @@
#include "BKE_object.h"
#include "BLI_dynstr.h"
+#include "BLI_string_utils.h"
extern struct GPUUniformBuffer *globals_ubo; /* draw_common.c */
@@ -49,6 +50,8 @@ extern struct GlobalsUboStorage ts; /* draw_common.c */
extern struct GPUTexture *globals_weight_ramp; /* draw_common.c */
+extern char datatoc_common_world_clip_lib_glsl[];
+
extern char datatoc_paint_weight_vert_glsl[];
extern char datatoc_paint_weight_frag_glsl[];
@@ -229,6 +232,7 @@ static char *EDIT_MESH_sh_lib(void)
BLI_dynstr_append(ds, datatoc_common_globals_lib_glsl);
BLI_dynstr_append(ds, datatoc_edit_mesh_overlay_common_lib_glsl);
+ BLI_dynstr_append(ds, datatoc_common_world_clip_lib_glsl);
str = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds);
@@ -295,15 +299,19 @@ static void EDIT_MESH_engine_init(void *vedata)
});
if (is_clip) {
- DRW_state_clip_planes_len_set((draw_ctx->rv3d->viewlock & RV3D_BOXCLIP) ? 4 : 6);
+ DRW_state_clip_planes_set_from_rv3d(draw_ctx->rv3d);
}
if (!sh_data->weight_face) {
+ char *lib = BLI_string_joinN(
+ datatoc_common_world_clip_lib_glsl,
+ datatoc_common_globals_lib_glsl);
sh_data->weight_face = DRW_shader_create_with_lib(
datatoc_paint_weight_vert_glsl, NULL,
datatoc_paint_weight_frag_glsl,
- datatoc_common_globals_lib_glsl,
+ lib,
is_clip ? DEF_WORLD_CLIP_STR : NULL);
+ MEM_freeN(lib);
}
if (!sh_data->overlay_vert) {
@@ -322,50 +330,61 @@ static void EDIT_MESH_engine_init(void *vedata)
MEM_freeN(lib);
}
if (!sh_data->overlay_facedot) {
+ char *lib = BLI_string_joinN(
+ datatoc_common_world_clip_lib_glsl,
+ datatoc_common_globals_lib_glsl);
const char *defs =
DEF_WORLD_CLIP_STR
"#define VERTEX_FACING\n" ;
sh_data->overlay_facedot = DRW_shader_create_with_lib(
datatoc_edit_mesh_overlay_facedot_vert_glsl, NULL,
datatoc_edit_mesh_overlay_facedot_frag_glsl,
- datatoc_common_globals_lib_glsl,
+ lib,
defs + (is_clip ? 0 : strlen(DEF_WORLD_CLIP_STR)));
+ MEM_freeN(lib);
}
if (!sh_data->overlay_mix) {
sh_data->overlay_mix = DRW_shader_create_fullscreen(datatoc_edit_mesh_overlay_mix_frag_glsl, NULL);
}
if (!sh_data->overlay_facefill) {
+ char *lib = BLI_string_joinN(
+ datatoc_common_world_clip_lib_glsl,
+ datatoc_common_globals_lib_glsl);
sh_data->overlay_facefill = DRW_shader_create_with_lib(
datatoc_edit_mesh_overlay_facefill_vert_glsl, NULL,
datatoc_edit_mesh_overlay_facefill_frag_glsl,
- datatoc_common_globals_lib_glsl,
+ lib,
is_clip ? DEF_WORLD_CLIP_STR : NULL);
+ MEM_freeN(lib);
}
if (!sh_data->normals_face) {
const char *defs =
DEF_WORLD_CLIP_STR
"#define FACE_NORMALS\n";
- sh_data->normals_face = DRW_shader_create(
+ sh_data->normals_face = DRW_shader_create_with_lib(
datatoc_edit_normals_vert_glsl,
datatoc_edit_normals_geom_glsl,
datatoc_gpu_shader_uniform_color_frag_glsl,
+ datatoc_common_world_clip_lib_glsl,
defs + (is_clip ? 0 : strlen(DEF_WORLD_CLIP_STR)));
}
if (!sh_data->normals_loop) {
const char *defs =
DEF_WORLD_CLIP_STR
"#define LOOP_NORMALS\n";
- sh_data->normals_loop = DRW_shader_create(
+ sh_data->normals_loop = DRW_shader_create_with_lib(
datatoc_edit_normals_vert_glsl,
datatoc_edit_normals_geom_glsl,
datatoc_gpu_shader_uniform_color_frag_glsl,
+ datatoc_common_world_clip_lib_glsl,
defs + (is_clip ? 0 : strlen(DEF_WORLD_CLIP_STR)));
}
if (!sh_data->normals) {
- sh_data->normals = DRW_shader_create(
+ sh_data->normals = DRW_shader_create_with_lib(
datatoc_edit_normals_vert_glsl,
datatoc_edit_normals_geom_glsl,
datatoc_gpu_shader_uniform_color_frag_glsl,
+ datatoc_common_world_clip_lib_glsl,
is_clip ? DEF_WORLD_CLIP_STR : NULL);
}
if (!sh_data->depth) {
diff --git a/source/blender/draw/modes/overlay_mode.c b/source/blender/draw/modes/overlay_mode.c
index 2fc4cf3a765..16e008d349d 100644
--- a/source/blender/draw/modes/overlay_mode.c
+++ b/source/blender/draw/modes/overlay_mode.c
@@ -82,6 +82,8 @@ static struct {
OVERLAY_ShaderData sh_data[2];
} e_data = {NULL};
+extern char datatoc_common_world_clip_lib_glsl[];
+
/* Shaders */
extern char datatoc_overlay_face_orientation_frag_glsl[];
extern char datatoc_overlay_face_orientation_vert_glsl[];
@@ -112,7 +114,7 @@ static void overlay_engine_init(void *vedata)
const bool is_clip = (draw_ctx->rv3d->rflag & RV3D_CLIPPING) != 0;
if (is_clip) {
- DRW_state_clip_planes_len_set((draw_ctx->rv3d->viewlock & RV3D_BOXCLIP) ? 4 : 6);
+ DRW_state_clip_planes_set_from_rv3d(draw_ctx->rv3d);
}
if (!stl->g_data) {
@@ -123,30 +125,34 @@ static void overlay_engine_init(void *vedata)
if (!sh_data->face_orientation_sh) {
/* Face orientation */
- sh_data->face_orientation_sh = DRW_shader_create(
+ sh_data->face_orientation_sh = DRW_shader_create_with_lib(
datatoc_overlay_face_orientation_vert_glsl, NULL,
datatoc_overlay_face_orientation_frag_glsl,
+ datatoc_common_world_clip_lib_glsl,
is_clip ? NULL : DEF_WORLD_CLIP_STR);
}
if (!sh_data->face_wireframe_sh) {
- sh_data->select_wireframe_sh = DRW_shader_create(
+ sh_data->select_wireframe_sh = DRW_shader_create_with_lib(
datatoc_overlay_face_wireframe_vert_glsl,
datatoc_overlay_face_wireframe_geom_glsl,
datatoc_gpu_shader_depth_only_frag_glsl,
+ datatoc_common_world_clip_lib_glsl,
DEF_WORLD_CLIP_STR "#define SELECT_EDGES\n" +
(is_clip ? 0 : strlen(DEF_WORLD_CLIP_STR)));
- sh_data->face_wireframe_sh = DRW_shader_create(
+ sh_data->face_wireframe_sh = DRW_shader_create_with_lib(
datatoc_overlay_face_wireframe_vert_glsl,
NULL,
datatoc_overlay_face_wireframe_frag_glsl,
+ datatoc_common_world_clip_lib_glsl,
is_clip ? DEF_WORLD_CLIP_STR : NULL);
- sh_data->face_wireframe_sculpt_sh = DRW_shader_create(
+ sh_data->face_wireframe_sculpt_sh = DRW_shader_create_with_lib(
datatoc_overlay_face_wireframe_vert_glsl,
datatoc_overlay_face_wireframe_geom_glsl,
datatoc_overlay_face_wireframe_frag_glsl,
+ datatoc_common_world_clip_lib_glsl,
DEF_WORLD_CLIP_STR "#define USE_SCULPT\n" +
(is_clip ? 0 : strlen(DEF_WORLD_CLIP_STR)));
}
diff --git a/source/blender/draw/modes/shaders/common_world_clip_lib.glsl b/source/blender/draw/modes/shaders/common_world_clip_lib.glsl
new file mode 100644
index 00000000000..b889780751e
--- /dev/null
+++ b/source/blender/draw/modes/shaders/common_world_clip_lib.glsl
@@ -0,0 +1,25 @@
+#ifdef USE_WORLD_CLIP_PLANES
+#ifdef GPU_VERTEX_SHADER
+uniform vec4 WorldClipPlanes[6];
+void world_clip_planes_calc_clip_distance(vec3 wpos)
+{
+ gl_ClipDistance[0] = dot(WorldClipPlanes[0].xyz, wpos) + WorldClipPlanes[0].w;
+ gl_ClipDistance[1] = dot(WorldClipPlanes[1].xyz, wpos) + WorldClipPlanes[1].w;
+ gl_ClipDistance[2] = dot(WorldClipPlanes[2].xyz, wpos) + WorldClipPlanes[2].w;
+ gl_ClipDistance[3] = dot(WorldClipPlanes[3].xyz, wpos) + WorldClipPlanes[3].w;
+ gl_ClipDistance[4] = dot(WorldClipPlanes[4].xyz, wpos) + WorldClipPlanes[4].w;
+ gl_ClipDistance[5] = dot(WorldClipPlanes[5].xyz, wpos) + WorldClipPlanes[5].w;
+}
+#endif
+
+#define world_clip_planes_set_clip_distance(c) \
+{ \
+ gl_ClipDistance[0] = (c)[0]; \
+ gl_ClipDistance[1] = (c)[1]; \
+ gl_ClipDistance[2] = (c)[2]; \
+ gl_ClipDistance[3] = (c)[3]; \
+ gl_ClipDistance[4] = (c)[4]; \
+ gl_ClipDistance[5] = (c)[5]; \
+}
+
+#endif
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_facedot_vert.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_facedot_vert.glsl
index 2a54ca70684..a66560cd8d9 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_facedot_vert.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_facedot_vert.glsl
@@ -2,11 +2,6 @@
uniform mat4 ModelViewProjectionMatrix;
uniform mat4 ModelMatrix;
-#ifdef USE_WORLD_CLIP_PLANES
-uniform vec4 WorldClipPlanes[6];
-uniform int WorldClipPlanesLen;
-#endif
-
in vec3 pos;
in vec4 norAndFlag;
@@ -36,11 +31,6 @@ void main()
#endif
#ifdef USE_WORLD_CLIP_PLANES
- {
- vec3 worldPosition = (ModelMatrix * vec4(pos, 1.0)).xyz;
- for (int i = 0; i < WorldClipPlanesLen; i++) {
- gl_ClipDistance[i] = dot(WorldClipPlanes[i].xyz, worldPosition) + WorldClipPlanes[i].w;
- }
- }
+ world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
#endif
}
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_facefill_vert.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_facefill_vert.glsl
index fa808b4fdb9..95630fc2e0f 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_facefill_vert.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_facefill_vert.glsl
@@ -3,11 +3,6 @@ uniform mat4 ModelViewProjectionMatrix;
uniform mat4 ModelMatrix;
uniform ivec4 dataMask = ivec4(0xFF);
-#ifdef USE_WORLD_CLIP_PLANES
-uniform vec4 WorldClipPlanes[6];
-uniform int WorldClipPlanesLen;
-#endif
-
in vec3 pos;
in ivec4 data;
@@ -33,11 +28,6 @@ void main()
faceColor = colorFace;
#ifdef USE_WORLD_CLIP_PLANES
- {
- vec3 worldPosition = (ModelMatrix * vec4(pos, 1.0)).xyz;
- for (int i = 0; i < WorldClipPlanesLen; i++) {
- gl_ClipDistance[i] = dot(WorldClipPlanes[i].xyz, worldPosition) + WorldClipPlanes[i].w;
- }
- }
+ world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
#endif
}
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_edge.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_edge.glsl
index e8987b59c45..76c53b3cf86 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_edge.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_edge.glsl
@@ -9,10 +9,6 @@ uniform mat4 ProjectionMatrix;
uniform mat4 ViewProjectionMatrixInverse;
uniform vec2 viewportSize;
-#ifdef USE_WORLD_CLIP_PLANES
-uniform int WorldClipPlanesLen;
-#endif
-
in vec4 pPos[];
in ivec4 vData[];
#ifdef VERTEX_FACING
@@ -63,9 +59,7 @@ void doVertex(int v, vec4 pos)
gl_Position = pos;
#ifdef USE_WORLD_CLIP_PLANES
- for (int i = 0; i < WorldClipPlanesLen; i++) {
- gl_ClipDistance[i] = gl_in[v].gl_ClipDistance[i];
- }
+ world_clip_planes_set_clip_distance(gl_in[v].gl_ClipDistance);
#endif
EmitVertex();
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl
index 3fcc3a7240f..1c88f1ff959 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom_tri.glsl
@@ -15,10 +15,6 @@ uniform mat4 ProjectionMatrix;
uniform vec2 viewportSize;
uniform bool isXray = false;
-#ifdef USE_WORLD_CLIP_PLANES
-uniform int WorldClipPlanesLen;
-#endif
-
in vec4 pPos[];
#ifdef USE_WORLD_CLIP_PLANES
/* Worldspace position. */
@@ -77,9 +73,7 @@ void doVertex(int v)
gl_Position = pPos[v];
#ifdef USE_WORLD_CLIP_PLANES
- for (int i = 0; i < WorldClipPlanesLen; i++) {
- gl_ClipDistance[i] = gl_in[v].gl_ClipDistance[i];
- }
+ world_clip_planes_set_clip_distance(gl_in[v].gl_ClipDistance);
#endif
EmitVertex();
@@ -98,9 +92,7 @@ void doVertexOfs(int v, vec2 fixvec)
gl_Position = pPos[v] + vec4(fixvec * pPos[v].w, z_ofs, 0.0);
#ifdef USE_WORLD_CLIP_PLANES
- for (int i = 0; i < WorldClipPlanesLen; i++) {
- gl_ClipDistance[i] = gl_in[v].gl_ClipDistance[i];
- }
+ world_clip_planes_set_clip_distance(gl_in[v].gl_ClipDistance);
#endif
EmitVertex();
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_points_vert.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_points_vert.glsl
index 53a56097234..687e5b0a0fc 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_points_vert.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_points_vert.glsl
@@ -6,11 +6,6 @@ uniform mat4 ModelViewProjectionMatrix;
uniform mat4 ModelMatrix;
uniform float ofs = 3e-5;
-#ifdef USE_WORLD_CLIP_PLANES
-uniform vec4 WorldClipPlanes[6];
-uniform int WorldClipPlanesLen;
-#endif
-
in vec3 pos;
in ivec4 data;
#ifdef VERTEX_FACING
@@ -56,11 +51,6 @@ void main()
}
#ifdef USE_WORLD_CLIP_PLANES
- {
- vec3 worldPosition = (ModelMatrix * vec4(pos, 1.0)).xyz;
- for (int i = 0; i < WorldClipPlanesLen; i++) {
- gl_ClipDistance[i] = dot(WorldClipPlanes[i].xyz, worldPosition) + WorldClipPlanes[i].w;
- }
- }
+ world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
#endif
}
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl
index d4d7c455b1b..13431168fb0 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl
@@ -9,12 +9,6 @@ uniform mat4 ModelViewProjectionMatrix;
uniform mat4 ModelMatrix;
uniform ivec4 dataMask = ivec4(0xFF);
-#ifdef USE_WORLD_CLIP_PLANES
-uniform vec4 WorldClipPlanes[6];
-uniform int WorldClipPlanesLen;
-#endif
-
-
in vec3 pos;
#ifdef VERTEX_FACING
in vec3 vnor;
@@ -43,12 +37,7 @@ void main()
# endif
# ifdef USE_WORLD_CLIP_PLANES
- {
- vec3 worldPosition = (ModelMatrix * vec4(pos, 1.0)).xyz;
- for (int i = 0; i < WorldClipPlanesLen; i++) {
- gl_ClipDistance[i] = dot(WorldClipPlanes[i].xyz, worldPosition) + WorldClipPlanes[i].w;
- }
- }
+ world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
# endif
}
@@ -115,12 +104,7 @@ void main()
# endif
# ifdef USE_WORLD_CLIP_PLANES
- {
- vec3 worldPosition = (ModelMatrix * vec4(pos, 1.0)).xyz;
- for (int i = 0; i < WorldClipPlanesLen; i++) {
- gl_ClipDistance[i] = dot(WorldClipPlanes[i].xyz, worldPosition) + WorldClipPlanes[i].w;
- }
- }
+ world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
# endif
}
diff --git a/source/blender/draw/modes/shaders/edit_normals_geom.glsl b/source/blender/draw/modes/shaders/edit_normals_geom.glsl
index 50214c75e6a..91a57a79eb0 100644
--- a/source/blender/draw/modes/shaders/edit_normals_geom.glsl
+++ b/source/blender/draw/modes/shaders/edit_normals_geom.glsl
@@ -2,10 +2,6 @@
layout(points) in;
layout(line_strip, max_vertices=2) out;
-#ifdef USE_WORLD_CLIP_PLANES
-uniform int WorldClipPlanesLen;
-#endif
-
flat in vec4 v1[1];
flat in vec4 v2[1];
@@ -14,9 +10,7 @@ void main()
for (int v = 0; v < 2; v++) {
gl_Position = (v == 0) ? v1[0] : v2[0];
#ifdef USE_WORLD_CLIP_PLANES
- for (int i = 0; i < WorldClipPlanesLen; i++) {
- gl_ClipDistance[i] = gl_in[0].gl_ClipDistance[i];
- }
+ world_clip_planes_set_clip_distance(gl_in[0].gl_ClipDistance);
#endif
EmitVertex();
}
diff --git a/source/blender/draw/modes/shaders/edit_normals_vert.glsl b/source/blender/draw/modes/shaders/edit_normals_vert.glsl
index 99741de63bb..8d73a2f5ad2 100644
--- a/source/blender/draw/modes/shaders/edit_normals_vert.glsl
+++ b/source/blender/draw/modes/shaders/edit_normals_vert.glsl
@@ -5,11 +5,6 @@ uniform mat4 ProjectionMatrix;
uniform mat4 ModelMatrix;
uniform float normalSize;
-#ifdef USE_WORLD_CLIP_PLANES
-uniform vec4 WorldClipPlanes[6];
-uniform int WorldClipPlanesLen;
-#endif
-
in vec3 pos;
#ifdef LOOP_NORMALS
@@ -34,11 +29,6 @@ void main()
vec3 n = normalize(NormalMatrix * nor); /* viewspace */
v2 = v1 + ProjectionMatrix * vec4(n * normalSize, 0.0);
#ifdef USE_WORLD_CLIP_PLANES
- {
- vec3 worldPosition = (ModelMatrix * vec4(pos, 1.0)).xyz;
- for (int i = 0; i < WorldClipPlanesLen; i++) {
- gl_ClipDistance[i] = dot(WorldClipPlanes[i].xyz, worldPosition) + WorldClipPlanes[i].w;
- }
- }
+ world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
#endif
}
diff --git a/source/blender/draw/modes/shaders/overlay_face_orientation_vert.glsl b/source/blender/draw/modes/shaders/overlay_face_orientation_vert.glsl
index 2d025bc65ee..f9f2679fe81 100644
--- a/source/blender/draw/modes/shaders/overlay_face_orientation_vert.glsl
+++ b/source/blender/draw/modes/shaders/overlay_face_orientation_vert.glsl
@@ -1,11 +1,6 @@
uniform mat4 ModelViewProjectionMatrix;
uniform mat4 ModelMatrix;
-#ifdef USE_WORLD_CLIP_PLANES
-uniform vec4 WorldClipPlanes[6];
-uniform int WorldClipPlanesLen;
-#endif
-
in vec3 pos;
void main()
@@ -13,11 +8,6 @@ void main()
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
#ifdef USE_WORLD_CLIP_PLANES
- {
- vec3 worldPosition = (ModelMatrix * vec4(pos, 1.0)).xyz;
- for (int i = 0; i < WorldClipPlanesLen; i++) {
- gl_ClipDistance[i] = dot(WorldClipPlanes[i].xyz, worldPosition) + WorldClipPlanes[i].w;
- }
- }
+ world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
#endif
}
diff --git a/source/blender/draw/modes/shaders/overlay_face_wireframe_geom.glsl b/source/blender/draw/modes/shaders/overlay_face_wireframe_geom.glsl
index 2f3acc2a050..d4d53b7d24d 100644
--- a/source/blender/draw/modes/shaders/overlay_face_wireframe_geom.glsl
+++ b/source/blender/draw/modes/shaders/overlay_face_wireframe_geom.glsl
@@ -8,10 +8,6 @@ layout(line_strip, max_vertices = 6) out;
layout(triangle_strip, max_vertices = 3) out;
#endif
-#ifdef USE_WORLD_CLIP_PLANES
-uniform int WorldClipPlanesLen;
-#endif
-
in float facing_g[];
in float edgeSharpness_g[];
@@ -25,9 +21,7 @@ void vert_from_gl_in(int v)
{
gl_Position = gl_in[v].gl_Position;
#ifdef USE_WORLD_CLIP_PLANES
- for (int i = 0; i < WorldClipPlanesLen; i++) {
- gl_ClipDistance[i] = gl_in[v].gl_ClipDistance[i];
- }
+ world_clip_planes_set_clip_distance(gl_in[v].gl_ClipDistance);
#endif
}
diff --git a/source/blender/draw/modes/shaders/overlay_face_wireframe_vert.glsl b/source/blender/draw/modes/shaders/overlay_face_wireframe_vert.glsl
index 3c3869db7b4..cb07c535200 100644
--- a/source/blender/draw/modes/shaders/overlay_face_wireframe_vert.glsl
+++ b/source/blender/draw/modes/shaders/overlay_face_wireframe_vert.glsl
@@ -5,11 +5,6 @@ uniform mat3 NormalMatrix;
uniform vec2 wireStepParam;
-#ifdef USE_WORLD_CLIP_PLANES
-uniform vec4 WorldClipPlanes[6];
-uniform int WorldClipPlanesLen;
-#endif
-
vec3 get_edge_sharpness(vec3 wd)
{
bvec3 do_edge = greaterThan(wd, vec3(0.0));
@@ -84,12 +79,7 @@ void main()
facing = normalize(NormalMatrix * nor).z;
#ifdef USE_WORLD_CLIP_PLANES
- {
- vec3 worldPosition = (ModelMatrix * vec4(pos, 1.0)).xyz;
- for (int i = 0; i < WorldClipPlanesLen; i++) {
- gl_ClipDistance[i] = dot(WorldClipPlanes[i].xyz, worldPosition) + WorldClipPlanes[i].w;
- }
- }
+ world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
#endif
}
diff --git a/source/blender/draw/modes/shaders/paint_weight_vert.glsl b/source/blender/draw/modes/shaders/paint_weight_vert.glsl
index ab0fb775e54..d111f3dc0a8 100644
--- a/source/blender/draw/modes/shaders/paint_weight_vert.glsl
+++ b/source/blender/draw/modes/shaders/paint_weight_vert.glsl
@@ -2,11 +2,6 @@
uniform mat4 ModelViewProjectionMatrix;
uniform mat4 ModelMatrix;
-#ifdef USE_WORLD_CLIP_PLANES
-uniform vec4 WorldClipPlanes[6];
-uniform int WorldClipPlanesLen;
-#endif
-
in float weight;
in vec3 pos;
@@ -20,11 +15,6 @@ void main()
weight_interp = max(vec2(weight, -weight), 0.0);
#ifdef USE_WORLD_CLIP_PLANES
- {
- vec3 worldPosition = (ModelMatrix * vec4(pos, 1.0)).xyz;
- for (int i = 0; i < WorldClipPlanesLen; i++) {
- gl_ClipDistance[i] = dot(WorldClipPlanes[i].xyz, worldPosition) + WorldClipPlanes[i].w;
- }
- }
+ world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
#endif
}