This changes the include directive to use the standard C preprocessor `#include` directive. The regex to applied to all glsl sources is: `pragma BLENDER_REQUIRE\((\w+\.glsl)\)` `include "$1"` This allow C++ linter to parse the code and allow easier codebase traversal. However there is a small catch. While it does work like a standard include directive when the code is treated as C++, it doesn't when compiled by our shader backends. In this case, we still use our dependency concatenation approach instead of file injection. This means that included files will always be prepended when compiled to GLSL and a file cannot be appended more than once. This is why all GLSL lib file should have the `#pragma once` directive and always be included at the start of the file. These requirements are actually already enforced by our code-style in practice. On the implementation, the source needed to be mutated to comment the `#pragma once` and `#include`. This is needed to avoid GLSL compiler error out as this is an extension that not all vendor supports. Rel #127983 Pull Request: https://projects.blender.org/blender/blender/pulls/128076
60 lines
1.8 KiB
GLSL
60 lines
1.8 KiB
GLSL
/* SPDX-FileCopyrightText: 2022-2023 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
#include "common_view_lib.glsl"
|
|
|
|
#if defined(GPU_VERTEX_SHADER) || defined(GPU_GEOMETRY_SHADER)
|
|
|
|
void view_clipping_distances(vec3 wpos)
|
|
{
|
|
# ifdef USE_WORLD_CLIP_PLANES
|
|
vec4 pos_4d = vec4(wpos, 1.0);
|
|
# ifdef OVERLAY_NEXT
|
|
gl_ClipDistance[0] = dot(globalsBlock.clip_planes[0], pos_4d);
|
|
gl_ClipDistance[1] = dot(globalsBlock.clip_planes[1], pos_4d);
|
|
gl_ClipDistance[2] = dot(globalsBlock.clip_planes[2], pos_4d);
|
|
gl_ClipDistance[3] = dot(globalsBlock.clip_planes[3], pos_4d);
|
|
gl_ClipDistance[4] = dot(globalsBlock.clip_planes[4], pos_4d);
|
|
gl_ClipDistance[5] = dot(globalsBlock.clip_planes[5], pos_4d);
|
|
# else
|
|
gl_ClipDistance[0] = dot(drw_clipping_[0], pos_4d);
|
|
gl_ClipDistance[1] = dot(drw_clipping_[1], pos_4d);
|
|
gl_ClipDistance[2] = dot(drw_clipping_[2], pos_4d);
|
|
gl_ClipDistance[3] = dot(drw_clipping_[3], pos_4d);
|
|
gl_ClipDistance[4] = dot(drw_clipping_[4], pos_4d);
|
|
gl_ClipDistance[5] = dot(drw_clipping_[5], pos_4d);
|
|
# endif
|
|
# endif
|
|
}
|
|
|
|
void view_clipping_distances_bypass()
|
|
{
|
|
# ifdef USE_WORLD_CLIP_PLANES
|
|
gl_ClipDistance[0] = 1.0;
|
|
gl_ClipDistance[1] = 1.0;
|
|
gl_ClipDistance[2] = 1.0;
|
|
gl_ClipDistance[3] = 1.0;
|
|
gl_ClipDistance[4] = 1.0;
|
|
gl_ClipDistance[5] = 1.0;
|
|
# endif
|
|
}
|
|
|
|
/* Kept as define for compiler compatibility. */
|
|
# ifdef USE_WORLD_CLIP_PLANES
|
|
# define view_clipping_distances_set(c) \
|
|
gl_ClipDistance[0] = (c).gl_ClipDistance[0]; \
|
|
gl_ClipDistance[1] = (c).gl_ClipDistance[1]; \
|
|
gl_ClipDistance[2] = (c).gl_ClipDistance[2]; \
|
|
gl_ClipDistance[3] = (c).gl_ClipDistance[3]; \
|
|
gl_ClipDistance[4] = (c).gl_ClipDistance[4]; \
|
|
gl_ClipDistance[5] = (c).gl_ClipDistance[5];
|
|
|
|
# else
|
|
# define view_clipping_distances_set(c)
|
|
# endif
|
|
|
|
#endif
|