Cleanup: DRW: Make clipped shader use UBO clip planes
This commit is contained in:
parent
577d3498b4
commit
554af9c689
|
@ -874,11 +874,9 @@ static void drw_shgroup_init(DRWShadingGroup *shgroup, GPUShader *shader)
|
|||
drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_VIEWPROJECTION_INV, storage->persinv, 16, 1);
|
||||
drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_PROJECTION, storage->winmat, 16, 1);
|
||||
drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_PROJECTION_INV, storage->wininv, 16, 1);
|
||||
drw_shgroup_builtin_uniform(shgroup, GPU_UNIFORM_CLIPPLANES, storage->clipplanes, 4, 6);
|
||||
}
|
||||
|
||||
drw_shgroup_builtin_uniform(
|
||||
shgroup, GPU_UNIFORM_CLIPPLANES, DST.view_storage_cpy.clipplanes, 4, 6);
|
||||
|
||||
/* Not supported. */
|
||||
BLI_assert(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MODELVIEW_INV) == -1);
|
||||
BLI_assert(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_MODELVIEW) == -1);
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#define COMMON_VIEW_LIB
|
||||
|
||||
/* keep in sync with DRWManager.view_data */
|
||||
layout(std140) uniform viewBlock
|
||||
{
|
||||
|
@ -15,6 +17,12 @@ layout(std140) uniform viewBlock
|
|||
vec4 CameraTexCoFactors;
|
||||
};
|
||||
|
||||
#ifdef world_clip_planes_calc_clip_distance
|
||||
# undef world_clip_planes_calc_clip_distance
|
||||
# define world_clip_planes_calc_clip_distance(p) \
|
||||
_world_clip_planes_calc_clip_distance(p, clipPlanes)
|
||||
#endif
|
||||
|
||||
uniform mat4 ModelMatrix;
|
||||
uniform mat4 ModelMatrixInverse;
|
||||
|
||||
|
|
|
@ -1,15 +1,24 @@
|
|||
#ifdef USE_WORLD_CLIP_PLANES
|
||||
# if defined(GPU_VERTEX_SHADER) || defined(GPU_GEOMETRY_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;
|
||||
}
|
||||
|
||||
# define _world_clip_planes_calc_clip_distance(wpos, _clipplanes) \
|
||||
{ \
|
||||
vec4 pos = vec4(wpos, 1.0); \
|
||||
gl_ClipDistance[0] = dot(_clipplanes[0], pos); \
|
||||
gl_ClipDistance[1] = dot(_clipplanes[1], pos); \
|
||||
gl_ClipDistance[2] = dot(_clipplanes[2], pos); \
|
||||
gl_ClipDistance[3] = dot(_clipplanes[3], pos); \
|
||||
gl_ClipDistance[4] = dot(_clipplanes[4], pos); \
|
||||
gl_ClipDistance[5] = dot(_clipplanes[5], pos); \
|
||||
}
|
||||
|
||||
/* HACK Dirty hack to be able to override the definition in common_view_lib.glsl.
|
||||
* Not doing this would require changing the include order in every shaders. */
|
||||
# define world_clip_planes_calc_clip_distance(wpos) \
|
||||
_world_clip_planes_calc_clip_distance(wpos, WorldClipPlanes)
|
||||
|
||||
# endif
|
||||
|
||||
# define world_clip_planes_set_clip_distance(c) \
|
||||
|
|
Loading…
Reference in New Issue