0
0
Fork 0

me-main #1

Merged
Nate Rupsis merged 123 commits from me-main into main 2023-02-13 18:39:11 +01:00
4 changed files with 16 additions and 19 deletions
Showing only changes of commit efabe81c91 - Show all commits

View File

@ -647,21 +647,6 @@ char *GPU_material_split_sub_function(GPUMaterial *material,
SNPRINTF(func_link->name, "ntree_fn%d", material->generated_function_len++);
BLI_addtail(&material->graph.material_functions, func_link);
/* Set value to break the link with the main graph. */
switch (return_type) {
case GPU_FLOAT:
GPU_link(material, "set_value_one", link);
break;
case GPU_VEC3:
GPU_link(material, "set_rgb_one", link);
break;
case GPU_VEC4:
GPU_link(material, "set_rgba_one", link);
break;
default:
BLI_assert(0);
break;
}
return func_link->name;
}

View File

@ -263,9 +263,7 @@ vec3 dF_impl(vec3 v)
g_derivative_flag = -1; \
result.y = (fn); \
g_derivative_flag = 0; \
result -= vec2((fn)); \
}
#endif
/* TODO(fclem): Remove. */

View File

@ -12,8 +12,13 @@ void differentiate_texco(vec4 v, out vec3 df)
df = v.xyz + dF_impl(v.xyz);
}
void node_bump(
float strength, float dist, float height, vec3 N, vec2 dHd, float invert, out vec3 result)
void node_bump(float strength,
float dist,
float height,
vec3 N,
vec2 height_xy,
float invert,
out vec3 result)
{
N = normalize(N);
dist *= FrontFacing ? invert : -invert;
@ -29,6 +34,7 @@ void node_bump(
/* Compute surface gradient and determinant. */
float det = dot(dPdx, Rx);
vec2 dHd = height_xy - vec2(height);
vec3 surfgrad = dHd.x * Rx + dHd.y * Ry;
strength = max(strength, 0.0);

View File

@ -59,6 +59,14 @@ static int gpu_shader_bump(GPUMaterial *mat,
const char *height_function = GPU_material_split_sub_function(mat, GPU_FLOAT, &in[2].link);
/* TODO (Miguel Pozo):
* Currently, this doesn't compute the actual differentials, just the height at dX and dY
* offsets. The actual differentials are computed inside the GLSL node_bump function by
* substracting the height input. This avoids redundant computations when the height input is
* also needed by regular nodes as part in the main function (See #103903 for context).
* A better option would be to add a "value" input socket (in this case the height) to the
* differentiate node, but currently this kind of intermediate nodes are pruned in the codegen
* process (see #104265), so we need to fix that first. */
GPUNodeLink *dheight = GPU_differentiate_float_function(height_function);
float invert = (node->custom1) ? -1.0 : 1.0;