Blender  V3.3
kernel/svm/math.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #pragma once
5 
7 
10  ccl_private float *stack,
11  uint type,
12  uint inputs_stack_offsets,
13  uint result_stack_offset)
14 {
15  uint a_stack_offset, b_stack_offset, c_stack_offset;
16  svm_unpack_node_uchar3(inputs_stack_offsets, &a_stack_offset, &b_stack_offset, &c_stack_offset);
17 
18  float a = stack_load_float(stack, a_stack_offset);
19  float b = stack_load_float(stack, b_stack_offset);
20  float c = stack_load_float(stack, c_stack_offset);
21  float result = svm_math((NodeMathType)type, a, b, c);
22 
23  stack_store_float(stack, result_stack_offset, result);
24 }
25 
28  ccl_private float *stack,
29  uint type,
30  uint inputs_stack_offsets,
31  uint outputs_stack_offsets,
32  int offset)
33 {
34  uint value_stack_offset, vector_stack_offset;
35  uint a_stack_offset, b_stack_offset, param1_stack_offset;
37  inputs_stack_offsets, &a_stack_offset, &b_stack_offset, &param1_stack_offset);
38  svm_unpack_node_uchar2(outputs_stack_offsets, &value_stack_offset, &vector_stack_offset);
39 
40  float3 a = stack_load_float3(stack, a_stack_offset);
41  float3 b = stack_load_float3(stack, b_stack_offset);
42  float3 c = make_float3(0.0f, 0.0f, 0.0f);
43  float param1 = stack_load_float(stack, param1_stack_offset);
44 
45  float value;
46  float3 vector;
47 
48  /* 3 Vector Operators */
51  uint4 extra_node = read_node(kg, &offset);
52  c = stack_load_float3(stack, extra_node.x);
53  }
54 
55  svm_vector_math(&value, &vector, (NodeVectorMathType)type, a, b, c, param1);
56 
57  if (stack_valid(value_stack_offset))
58  stack_store_float(stack, value_stack_offset, value);
59  if (stack_valid(vector_stack_offset))
60  stack_store_float3(stack, vector_stack_offset, vector);
61  return offset;
62 }
63 
unsigned int uint
Definition: BLI_sys_types.h:67
@ NODE_VECTOR_MATH_WRAP
@ NODE_VECTOR_MATH_FACEFORWARD
@ NODE_VECTOR_MATH_MULTIPLY_ADD
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
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 Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise 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
#define ccl_private
Definition: cuda/compat.h:48
#define ccl_device_noinline
Definition: cuda/compat.h:40
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
const KernelGlobalsCPU *ccl_restrict KernelGlobals
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
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
Definition: kernel/types.h:925
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:8
ccl_device float svm_math(NodeMathType type, float a, float b, float c)
Definition: math_util.h:104
#define make_float3(x, y, z)
Definition: metal/compat.h:204
static unsigned c
Definition: RandGen.cpp:83
static unsigned a[3]
Definition: RandGen.cpp:78
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
uint x
Definition: types_uint4.h:15