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
32 lines
805 B
GLSL
32 lines
805 B
GLSL
/* SPDX-FileCopyrightText: 2019-2022 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#include "gpu_shader_material_transform_utils.glsl"
|
|
|
|
void tangent_orco_x(vec3 orco_in, out vec3 orco_out)
|
|
{
|
|
orco_out = orco_in.xzy * vec3(0.0, -0.5, 0.5) + vec3(0.0, 0.25, -0.25);
|
|
}
|
|
|
|
void tangent_orco_y(vec3 orco_in, out vec3 orco_out)
|
|
{
|
|
orco_out = orco_in.zyx * vec3(-0.5, 0.0, 0.5) + vec3(0.25, 0.0, -0.25);
|
|
}
|
|
|
|
void tangent_orco_z(vec3 orco_in, out vec3 orco_out)
|
|
{
|
|
orco_out = orco_in.yxz * vec3(-0.5, 0.5, 0.0) + vec3(0.25, -0.25, 0.0);
|
|
}
|
|
|
|
void node_tangentmap(vec4 attr_tangent, out vec3 tangent)
|
|
{
|
|
tangent = normalize(attr_tangent.xyz);
|
|
}
|
|
|
|
void node_tangent(vec3 orco, out vec3 T)
|
|
{
|
|
direction_transform_object_to_world(orco, T);
|
|
T = cross(g_data.N, normalize(cross(T, g_data.N)));
|
|
}
|