Blender V5.3
checker.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
8#include "kernel/svm/util.h"
9
11
12/* Checker */
13
15{
16 /* avoid precision issues on unit coordinates */
17 p.x = (p.x + 0.000001f) * 0.999999f;
18 p.y = (p.y + 0.000001f) * 0.999999f;
19 p.z = (p.z + 0.000001f) * 0.999999f;
20
21 const int xi = abs(float_to_int(floorf(p.x)));
22 const int yi = abs(float_to_int(floorf(p.y)));
23 const int zi = abs(float_to_int(floorf(p.z)));
24
25 return ((xi % 2 == yi % 2) == (zi % 2)) ? 1.0f : 0.0f;
26}
27
30{
31 const float3 co = stack_load_float3(stack, node.co);
32 const float3 color1 = stack_load(stack, node.color1);
33 const float3 color2 = stack_load(stack, node.color2);
34 const float scale = stack_load(stack, node.scale);
35
36 const float f = svm_checker(co * scale);
37
38 if (stack_valid(node.color_offset)) {
39 stack_store_float3(stack, node.color_offset, (f == 1.0f) ? color1 : color2);
40 }
41 if (stack_valid(node.fac_offset)) {
42 stack_store_float(stack, node.fac_offset, f);
43 }
44}
45
ccl_device_noinline void svm_node_tex_checker(ccl_private float *ccl_restrict stack, const ccl_global SVMNodeTexChecker &ccl_restrict node)
Definition checker.h:28
CCL_NAMESPACE_BEGIN ccl_device float svm_checker(float3 p)
Definition checker.h:14
ccl_device_inline void stack_store_float(ccl_private float *stack, const uint a, const float f)
ccl_device_inline float3 stack_load_float3(const ccl_private float *stack, const uint a)
ccl_device_inline void stack_store_float3(ccl_private float *stack, const uint a, const float3 f)
ccl_device_inline bool stack_valid(const uint a)
ccl_device_inline T stack_load(const ccl_private float *stack, const uint a)
#define ccl_restrict
#define ccl_private
#define ccl_global
#define ccl_device_noinline
#define CCL_NAMESPACE_END
#define abs
float3x3 scale(float3x3 mat, float2 scale)
ccl_device_inline int float_to_int(const float f)
Definition math_base.h:454
#define floorf
#define ccl_device
float z
Definition sky_math.h:136
float y
Definition sky_math.h:136
float x
Definition sky_math.h:136