Cleanup: Conver macros into functions
Avoids macro redefinition warnings in unity builds.
This commit is contained in:
@@ -401,3 +401,16 @@ void get_XYZ_to_RGB_for_gpu(XYZ_to_RGB *data)
|
||||
data->b[1] = xyz_to_rgb[5];
|
||||
data->b[2] = xyz_to_rgb[8];
|
||||
}
|
||||
|
||||
bool node_socket_not_zero(const GPUNodeStack &socket)
|
||||
{
|
||||
return socket.link || socket.vec[0] > 1e-5f;
|
||||
}
|
||||
bool node_socket_not_white(const GPUNodeStack &socket)
|
||||
{
|
||||
return socket.link || socket.vec[0] < 1.0f || socket.vec[1] < 1.0f || socket.vec[2] < 1.0f;
|
||||
}
|
||||
bool node_socket_not_black(const GPUNodeStack &socket)
|
||||
{
|
||||
return socket.link || socket.vec[0] > 1e-5f || socket.vec[1] > 1e-5f || socket.vec[2] > 1e-5f;
|
||||
}
|
||||
|
||||
@@ -72,3 +72,7 @@ void ntreeShaderEndExecTree_internal(bNodeTreeExec *exec);
|
||||
|
||||
void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, bNode *output_node);
|
||||
void get_XYZ_to_RGB_for_gpu(XYZ_to_RGB *data);
|
||||
|
||||
bool node_socket_not_zero(const GPUNodeStack &socket);
|
||||
bool node_socket_not_white(const GPUNodeStack &socket);
|
||||
bool node_socket_not_black(const GPUNodeStack &socket);
|
||||
|
||||
@@ -16,17 +16,13 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
b.add_output<decl::Shader>("Volume").translation_context(BLT_I18NCONTEXT_ID_ID);
|
||||
}
|
||||
|
||||
#define socket_not_zero(sock) (in[sock].link || (in[sock].vec[0] > 1e-5f))
|
||||
#define socket_not_white(sock) \
|
||||
(in[sock].link || (in[sock].vec[0] < 1.0f || in[sock].vec[1] < 1.0f || in[sock].vec[2] < 1.0f))
|
||||
|
||||
static int node_shader_gpu_volume_absorption(GPUMaterial *mat,
|
||||
bNode *node,
|
||||
bNodeExecData * /*execdata*/,
|
||||
GPUNodeStack *in,
|
||||
GPUNodeStack *out)
|
||||
{
|
||||
if (socket_not_zero(SOCK_DENSITY_ID) && socket_not_white(SOCK_COLOR_ID)) {
|
||||
if (node_socket_not_zero(in[SOCK_DENSITY_ID]) && node_socket_not_white(in[SOCK_COLOR_ID])) {
|
||||
GPU_material_flag_set(mat, GPU_MATFLAG_VOLUME_ABSORPTION);
|
||||
}
|
||||
return GPU_stack_link(mat, node, "node_volume_absorption", in, out);
|
||||
|
||||
@@ -56,13 +56,6 @@ static void attribute_post_process(GPUMaterial *mat,
|
||||
}
|
||||
}
|
||||
|
||||
#define socket_not_zero(sock) (in[sock].link || (in[sock].vec[0] > 1e-5f))
|
||||
#define socket_not_black(sock) \
|
||||
(in[sock].link || \
|
||||
(in[sock].vec[0] > 1e-5f || in[sock].vec[1] > 1e-5f || in[sock].vec[2] > 1e-5f))
|
||||
#define socket_not_white(sock) \
|
||||
(in[sock].link || (in[sock].vec[0] < 1.0f || in[sock].vec[1] < 1.0f || in[sock].vec[2] < 1.0f))
|
||||
|
||||
static int node_shader_gpu_volume_principled(GPUMaterial *mat,
|
||||
bNode *node,
|
||||
bNodeExecData * /*execdata*/,
|
||||
@@ -70,14 +63,16 @@ static int node_shader_gpu_volume_principled(GPUMaterial *mat,
|
||||
GPUNodeStack *out)
|
||||
{
|
||||
/* Test if blackbody intensity is enabled. */
|
||||
bool use_blackbody = socket_not_zero(SOCK_BLACKBODY_INTENSITY_ID);
|
||||
bool use_blackbody = node_socket_not_zero(in[SOCK_BLACKBODY_INTENSITY_ID]);
|
||||
|
||||
if (socket_not_zero(SOCK_DENSITY_ID) && socket_not_black(SOCK_COLOR_ID)) {
|
||||
if (node_socket_not_zero(in[SOCK_DENSITY_ID]) && node_socket_not_black(in[SOCK_COLOR_ID])) {
|
||||
/* Consider there is absorption phenomenon when there is scattering since
|
||||
* `extinction = scattering + absorption`. */
|
||||
GPU_material_flag_set(mat, GPU_MATFLAG_VOLUME_SCATTER | GPU_MATFLAG_VOLUME_ABSORPTION);
|
||||
}
|
||||
if (socket_not_zero(SOCK_DENSITY_ID) && socket_not_white(SOCK_ABSORPTION_COLOR_ID)) {
|
||||
if (node_socket_not_zero(in[SOCK_DENSITY_ID]) &&
|
||||
node_socket_not_white(in[SOCK_ABSORPTION_COLOR_ID]))
|
||||
{
|
||||
GPU_material_flag_set(mat, GPU_MATFLAG_VOLUME_ABSORPTION);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user