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
37 lines
1001 B
GLSL
37 lines
1001 B
GLSL
/* SPDX-FileCopyrightText: 2019-2022 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#include "gpu_shader_material_tangent.glsl"
|
|
|
|
void node_geometry(vec3 orco_attr,
|
|
out vec3 position,
|
|
out vec3 normal,
|
|
out vec3 tangent,
|
|
out vec3 true_normal,
|
|
out vec3 incoming,
|
|
out vec3 parametric,
|
|
out float backfacing,
|
|
out float pointiness,
|
|
out float random_per_island)
|
|
{
|
|
/* handle perspective/orthographic */
|
|
incoming = coordinate_incoming(g_data.P);
|
|
position = g_data.P;
|
|
normal = g_data.N;
|
|
true_normal = g_data.Ng;
|
|
|
|
if (g_data.is_strand) {
|
|
tangent = g_data.curve_T;
|
|
}
|
|
else {
|
|
tangent_orco_z(orco_attr, orco_attr);
|
|
node_tangent(orco_attr, tangent);
|
|
}
|
|
|
|
parametric = vec3(g_data.barycentric_coords, 0.0);
|
|
backfacing = (FrontFacing) ? 0.0 : 1.0;
|
|
pointiness = 0.5;
|
|
random_per_island = 0.0;
|
|
}
|