From dbd7f36da8ec3ac1c2898aee346beecb86aac8a2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 6 Feb 2019 09:15:16 +1100 Subject: GPU: refactor clipped drawing from DRW into GPU Needed to fix T61196, supporting clipped back-buffer in the 3D view which is done outside the draw module. It was also inconvenient having DRW_shader_* versions of GPU_shader_* API calls. - Clipping distances are now supported as a shader configuration for builtin shaders. - Add shader config argument when accessing builtin shaders. - Move GPU_shader_create_from_arrays() from DRW to GPU. --- .../gpu/shaders/gpu_shader_cfg_world_clip_lib.glsl | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 source/blender/gpu/shaders/gpu_shader_cfg_world_clip_lib.glsl (limited to 'source/blender/gpu/shaders') 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 new file mode 100644 index 00000000000..6964b2a0c39 --- /dev/null +++ b/source/blender/gpu/shaders/gpu_shader_cfg_world_clip_lib.glsl @@ -0,0 +1,25 @@ +#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; +} +#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 -- cgit v1.2.3