Blender
V5.3
source
blender
gpu
shaders
material
gpu_shader_material_tex_checker.bsl.hh
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2019 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
5
#pragma once
6
7
#include "
gpu_shader_compat.hh
"
8
9
[[
node
]]
10
void
node_tex_checker
(
11
float3
co,
float4
color1,
float4
color2,
float
scale
,
float4
&color,
float
&fac)
12
{
13
float3
p = co *
scale
;
14
15
/* Prevent precision issues on unit coordinates. */
16
p = (p + 0.000001f) * 0.999999f;
17
18
int
xi = int(
abs
(
floor
(p.
x
)));
19
int
yi = int(
abs
(
floor
(p.
y
)));
20
int
zi = int(
abs
(
floor
(p.
z
)));
21
22
bool
check = ((
mod
(xi, 2) ==
mod
(yi, 2)) == bool(
mod
(zi, 2)));
23
24
color = check ? color1 : color2;
25
fac = check ? 1.0f : 0.0f;
26
}
gpu_shader_compat.hh
node
#define node
Definition
gpu_shader_cxx_attribute.hh:142
abs
#define abs
Definition
gpu_shader_cxx_builtin.hh:104
mod
VecBase< float, D > constexpr mod(VecOp< float, D >, VecOp< float, D >) RET
floor
#define floor
Definition
gpu_shader_cxx_builtin.hh:108
node_tex_checker
void node_tex_checker(float3 co, float4 color1, float4 color2, float scale, float4 &color, float &fac)
Definition
gpu_shader_material_tex_checker.bsl.hh:10
scale
float3x3 scale(float3x3 mat, float2 scale)
Definition
gpu_shader_math_matrix.bsl.hh:100
float3
Definition
sky_math.h:135
float3::z
float z
Definition
sky_math.h:136
float3::y
float y
Definition
sky_math.h:136
float3::x
float x
Definition
sky_math.h:136
float4
Definition
sky_math.h:224
Generated on
for Blender by
doxygen
1.18.0