Blender V5.3
mix.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
9#include "kernel/svm/util.h"
10
12
13/* Node */
14
17{
18 const float fac = stack_load(stack, node.fac);
19 const float3 c1 = stack_load(stack, node.c1);
20 const float3 c2 = stack_load(stack, node.c2);
21 const float3 result = svm_mix_clamped_factor(node.mix_type, fac, c1, c2);
22
23 stack_store_float3(stack, node.result_offset, result);
24}
25
28{
29 float t = stack_load(stack, node.fac);
30 if (node.use_clamp > 0) {
31 t = saturatef(t);
32 }
33 const float3 a = stack_load(stack, node.a);
34 const float3 b = stack_load(stack, node.b);
35 float3 result = svm_mix(node.blend_type, t, a, b);
36 if (node.use_clamp_result) {
37 result = saturate(result);
38 }
39 stack_store_float3(stack, node.result_offset, result);
40}
41
44{
45 float t = stack_load(stack, node.fac);
46 if (node.use_clamp > 0) {
47 t = saturatef(t);
48 }
49 const float a = stack_load(stack, node.a);
50 const float b = stack_load(stack, node.b);
51 const float result = endvalue_preserving_mix(a, b, t);
52
53 stack_store_float(stack, node.result_offset, result);
54}
55
58{
59 float t = stack_load(stack, node.fac);
60 if (node.use_clamp > 0) {
61 t = saturatef(t);
62 }
63 const float3 a = stack_load(stack, node.a);
64 const float3 b = stack_load(stack, node.b);
65 const float3 result = endvalue_preserving_mix(a, b, t);
66 stack_store_float3(stack, node.result_offset, result);
67}
68
70 ccl_private float *ccl_restrict stack,
72{
73 float3 t = stack_load(stack, node.fac);
74 if (node.use_clamp > 0) {
75 t = saturate(t);
76 }
77 const float3 a = stack_load(stack, node.a);
78 const float3 b = stack_load(stack, node.b);
79 const float3 result = endvalue_preserving_mix(a, b, t);
80 stack_store_float3(stack, node.result_offset, result);
81}
82
ccl_device_noinline_cpu float3 svm_mix(NodeMix type, const float t, const float3 c1, const float3 c2)
Definition color_util.h:309
ccl_device_noinline_cpu float3 svm_mix_clamped_factor(NodeMix type, const float t, const float3 c1, const float3 c2)
Definition color_util.h:360
ccl_device_inline void stack_store_float(ccl_private float *stack, const uint a, const float f)
ccl_device_inline void stack_store_float3(ccl_private float *stack, const uint a, const float3 f)
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 saturatef(x)
float endvalue_preserving_mix(float a, float b, float t)
ccl_device_noinline void svm_node_mix_float(ccl_private float *ccl_restrict stack, const ccl_global SVMNodeMixFloat &ccl_restrict node)
Definition mix.h:42
ccl_device_noinline void svm_node_mix_vector(ccl_private float *ccl_restrict stack, const ccl_global SVMNodeMixVector &ccl_restrict node)
Definition mix.h:56
CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_mix(ccl_private float *ccl_restrict stack, const ccl_global SVMNodeMix &ccl_restrict node)
Definition mix.h:15
ccl_device_noinline void svm_node_mix_color(ccl_private float *ccl_restrict stack, const ccl_global SVMNodeMixColor &ccl_restrict node)
Definition mix.h:26
ccl_device_noinline void svm_node_mix_vector_non_uniform(ccl_private float *ccl_restrict stack, const ccl_global SVMNodeMixVectorNonUniform &ccl_restrict node)
Definition mix.h:69
#define saturate(a)
Definition smaa.cc:319