Fix #104637: EEVEE Displacement regression after #104595

Keep using the 3 evaluations dF_branch method for the Displacement output.
The optimized 2 evaluations method used by node_bump is now on its own macro (dF_branch_incomplete).
displacement_bump modifies the normal that nodetree_exec uses, so even with a refactor it wouldn’t be possible to re-use the computation anyway.
This commit is contained in:
2023-02-12 23:06:21 +01:00
parent f0669ff8ba
commit 77963ff778
2 changed files with 17 additions and 1 deletions

View File

@@ -149,7 +149,7 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, const eGPUType
case GPU_NODE_LINK_DIFFERENTIATE_FLOAT_FN:
input->source = GPU_SOURCE_FUNCTION_CALL;
/* NOTE(@fclem): End of function call is the return variable set during codegen. */
SNPRINTF(input->function_call, "dF_branch(%s(), ", link->function_name);
SNPRINTF(input->function_call, "dF_branch_incomplete(%s(), ", link->function_name);
break;
default:
break;

View File

@@ -228,6 +228,11 @@ void dF_branch(float fn, out vec2 result)
result = vec2(0.0);
}
void dF_branch_incomplete(float fn, out vec2 result)
{
result = vec2(0.0);
}
#elif 0 /* TODO(@fclem): User Option? */
/* Fast derivatives */
vec3 dF_impl(vec3 v)
@@ -257,6 +262,17 @@ vec3 dF_impl(vec3 v)
}
# define dF_branch(fn, result) \
if (true) { \
g_derivative_flag = 1; \
result.x = (fn); \
g_derivative_flag = -1; \
result.y = (fn); \
g_derivative_flag = 0; \
result -= vec2((fn)); \
}
/* Used when the non-offset value is already computed elsewhere */
# define dF_branch_incomplete(fn, result) \
if (true) { \
g_derivative_flag = 1; \
result.x = (fn); \