GPU: refactor clipped drawing from DRW into GPU
[blender.git] / source / blender / gpu / shaders / gpu_shader_cfg_world_clip_lib.glsl
1 #ifdef USE_WORLD_CLIP_PLANES
2 #if defined(GPU_VERTEX_SHADER) || defined(GPU_GEOMETRY_SHADER)
3 uniform vec4 WorldClipPlanes[6];
4 void world_clip_planes_calc_clip_distance(vec3 wpos)
5 {
6         gl_ClipDistance[0] = dot(WorldClipPlanes[0].xyz, wpos) + WorldClipPlanes[0].w;
7         gl_ClipDistance[1] = dot(WorldClipPlanes[1].xyz, wpos) + WorldClipPlanes[1].w;
8         gl_ClipDistance[2] = dot(WorldClipPlanes[2].xyz, wpos) + WorldClipPlanes[2].w;
9         gl_ClipDistance[3] = dot(WorldClipPlanes[3].xyz, wpos) + WorldClipPlanes[3].w;
10         gl_ClipDistance[4] = dot(WorldClipPlanes[4].xyz, wpos) + WorldClipPlanes[4].w;
11         gl_ClipDistance[5] = dot(WorldClipPlanes[5].xyz, wpos) + WorldClipPlanes[5].w;
12 }
13 #endif
14
15 #define world_clip_planes_set_clip_distance(c) \
16 { \
17         gl_ClipDistance[0] = (c)[0]; \
18         gl_ClipDistance[1] = (c)[1]; \
19         gl_ClipDistance[2] = (c)[2]; \
20         gl_ClipDistance[3] = (c)[3]; \
21         gl_ClipDistance[4] = (c)[4]; \
22         gl_ClipDistance[5] = (c)[5]; \
23 }
24
25 #endif