diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-05-26 22:32:48 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-05-27 13:58:14 +0300 |
commit | 554af9c6895f772ce5fdeb4aa4172c43b997b669 (patch) | |
tree | 0dd620156f061174a7822c0818a33f01af91fccb /source/blender/gpu | |
parent | 577d3498b4d4d3b747e184550378bc7d77e72b60 (diff) |
Cleanup: DRW: Make clipped shader use UBO clip planes
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_cfg_world_clip_lib.glsl | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_cfg_world_clip_lib.glsl b/source/blender/gpu/shaders/gpu_shader_cfg_world_clip_lib.glsl index e34b86ac1ce..46cf2fe09a2 100644 --- a/source/blender/gpu/shaders/gpu_shader_cfg_world_clip_lib.glsl +++ b/source/blender/gpu/shaders/gpu_shader_cfg_world_clip_lib.glsl @@ -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) \ |