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
34 lines
1.0 KiB
GLSL
34 lines
1.0 KiB
GLSL
/* SPDX-FileCopyrightText: 2019-2022 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#include "gpu_shader_common_math_utils.glsl"
|
|
|
|
void mapping_mat4(
|
|
vec3 vec, vec4 m0, vec4 m1, vec4 m2, vec4 m3, vec3 minvec, vec3 maxvec, out vec3 outvec)
|
|
{
|
|
mat4 mat = mat4(m0, m1, m2, m3);
|
|
outvec = (mat * vec4(vec, 1.0)).xyz;
|
|
outvec = clamp(outvec, minvec, maxvec);
|
|
}
|
|
|
|
void mapping_point(vec3 vector, vec3 location, vec3 rotation, vec3 scale, out vec3 result)
|
|
{
|
|
result = (euler_to_mat3(rotation) * (vector * scale)) + location;
|
|
}
|
|
|
|
void mapping_texture(vec3 vector, vec3 location, vec3 rotation, vec3 scale, out vec3 result)
|
|
{
|
|
result = safe_divide(transpose(euler_to_mat3(rotation)) * (vector - location), scale);
|
|
}
|
|
|
|
void mapping_vector(vec3 vector, vec3 location, vec3 rotation, vec3 scale, out vec3 result)
|
|
{
|
|
result = euler_to_mat3(rotation) * (vector * scale);
|
|
}
|
|
|
|
void mapping_normal(vec3 vector, vec3 location, vec3 rotation, vec3 scale, out vec3 result)
|
|
{
|
|
result = normalize(euler_to_mat3(rotation) * safe_divide(vector, scale));
|
|
}
|