Blender V4.3
kernel/svm/math.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
11 ccl_private float *stack,
12 uint type,
13 uint inputs_stack_offsets,
14 uint result_stack_offset)
15{
16 uint a_stack_offset, b_stack_offset, c_stack_offset;
17 svm_unpack_node_uchar3(inputs_stack_offsets, &a_stack_offset, &b_stack_offset, &c_stack_offset);
18
19 float a = stack_load_float(stack, a_stack_offset);
20 float b = stack_load_float(stack, b_stack_offset);
21 float c = stack_load_float(stack, c_stack_offset);
22 float result = svm_math((NodeMathType)type, a, b, c);
23
24 stack_store_float(stack, result_stack_offset, result);
25}
26
29 ccl_private float *stack,
30 uint type,
31 uint inputs_stack_offsets,
32 uint outputs_stack_offsets,
33 int offset)
34{
35 uint value_stack_offset, vector_stack_offset;
36 uint a_stack_offset, b_stack_offset, param1_stack_offset;
38 inputs_stack_offsets, &a_stack_offset, &b_stack_offset, &param1_stack_offset);
39 svm_unpack_node_uchar2(outputs_stack_offsets, &value_stack_offset, &vector_stack_offset);
40
41 float3 a = stack_load_float3(stack, a_stack_offset);
42 float3 b = stack_load_float3(stack, b_stack_offset);
43 float3 c = make_float3(0.0f, 0.0f, 0.0f);
44 float param1 = stack_load_float(stack, param1_stack_offset);
45
46 float value;
48
49 /* 3 Vector Operators */
52 {
53 uint4 extra_node = read_node(kg, &offset);
54 c = stack_load_float3(stack, extra_node.x);
55 }
56
57 svm_vector_math(&value, &vector, (NodeVectorMathType)type, a, b, c, param1);
58
59 if (stack_valid(value_stack_offset))
60 stack_store_float(stack, value_stack_offset, value);
61 if (stack_valid(vector_stack_offset))
62 stack_store_float3(stack, vector_stack_offset, vector);
63 return offset;
64}
65
unsigned int uint
@ NODE_VECTOR_MATH_WRAP
@ NODE_VECTOR_MATH_FACEFORWARD
@ NODE_VECTOR_MATH_MULTIPLY_ADD
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a vector
local_group_size(16, 16) .push_constant(Type b
const KernelGlobalsCPU *ccl_restrict KernelGlobals
#define ccl_private
#define ccl_device_noinline
#define CCL_NAMESPACE_END
ccl_device_forceinline float3 make_float3(const float x, const float y, const float z)
ccl_device_noinline int svm_node_vector_math(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, uint type, uint inputs_stack_offsets, uint outputs_stack_offsets, int offset)
CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_math(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, uint type, uint inputs_stack_offsets, uint result_stack_offset)
ccl_device_inline void stack_store_float3(ccl_private float *stack, uint a, float3 f)
CCL_NAMESPACE_BEGIN ccl_device_inline float3 stack_load_float3(ccl_private float *stack, uint a)
ccl_device_inline uint4 read_node(KernelGlobals kg, ccl_private int *offset)
ccl_device_forceinline void svm_unpack_node_uchar3(uint i, ccl_private uint *x, ccl_private uint *y, ccl_private uint *z)
ccl_device_forceinline void svm_unpack_node_uchar2(uint i, ccl_private uint *x, ccl_private uint *y)
ccl_device_inline void stack_store_float(ccl_private float *stack, uint a, float f)
ccl_device_inline float stack_load_float(ccl_private float *stack, uint a)
ccl_device_inline bool stack_valid(uint a)
NodeMathType
NodeVectorMathType
ShaderData
CCL_NAMESPACE_BEGIN ccl_device void svm_vector_math(ccl_private float *value, ccl_private float3 *vector, NodeVectorMathType type, float3 a, float3 b, float3 c, float param1)
Definition math_util.h:9
ccl_device float svm_math(NodeMathType type, float a, float b, float c)
Definition math_util.h:105
uint x
Definition types_uint4.h:15