This unify the C++ and GLSL codebase style. The GLSL types are still in the backend compatibility layers to support python shaders. However, the C++ shader compilation layer doesn't have them to enforce correct type usage. Note that this is going to break pretty much all PRs in flight that targets shader code. Rel #137261 Pull Request: https://projects.blender.org/blender/blender/pulls/137369
34 lines
759 B
GLSL
34 lines
759 B
GLSL
/* SPDX-FileCopyrightText: 2019-2022 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
void node_wireframe(float size, out float fac)
|
|
{
|
|
float3 barys = g_data.barycentric_coords.xyy;
|
|
barys.z = 1.0f - barys.x - barys.y;
|
|
|
|
size *= 0.5f;
|
|
float3 s = step(-size, -barys * g_data.barycentric_dists);
|
|
|
|
fac = max(s.x, max(s.y, s.z));
|
|
}
|
|
|
|
void node_wireframe_screenspace(float size, out float fac)
|
|
{
|
|
float3 barys = g_data.barycentric_coords.xyy;
|
|
barys.z = 1.0f - barys.x - barys.y;
|
|
|
|
#ifdef GPU_FRAGMENT_SHADER
|
|
size *= (1.0f / 3.0f);
|
|
float3 dx = dFdx(barys);
|
|
float3 dy = dFdy(barys);
|
|
float3 deltas = sqrt(dx * dx + dy * dy);
|
|
|
|
float3 s = step(-deltas * size, -barys);
|
|
|
|
fac = max(s.x, max(s.y, s.z));
|
|
#else
|
|
fac = 1.0f;
|
|
#endif
|
|
}
|