Fix T52441: Principle BSDF clearcoat
Since the change to prevent shader recompilation at every update, we got a regression when clearcoat was used. Basically at the shader build time we would determine if the shader needed clear coat, and if it didin't, it would build a different GLSL program. However if later the user updated the clearcoat value so that it would then require the full clearcoat shader, the user wouldn't get it until manually forcing the shader to recompile, or reopening the file. We now handle the optimization in the GLSL code. That adds a minimum overhead due to branching. But the overall performance seems unchanged (tested on linux in AMD and NVidia). Reviewers: pascal, brecht, fclem Differential Revision: https://developer.blender.org/D2822
This commit is contained in:
parent
bffa57e6d8
commit
518e768579
Notes:
blender-bot
2023-02-14 07:17:43 +01:00
Referenced by issue #52698, Mapping Node Is not working in EEvEE Referenced by issue #52702, Manipulator bug Referenced by issue #52681, 2.8 Edit Mode Crash Referenced by issue #52665, Crash on move using arrow axis of transform gizmo. Referenced by issue #52657, Blender crashes the minute I interact with the manipulator and Maya interaction mode can not be enabled. Referenced by issue #52441, Principle BSDF clearcoat optimisation bug Referenced by issue #51467, Eevee: Shader recompilation issue
|
@ -2861,6 +2861,14 @@ void node_bsdf_principled_clearcoat(vec4 base_color, float subsurface, vec3 subs
|
|||
float clearcoat_roughness, float ior, float transmission, float transmission_roughness, vec3 N, vec3 CN, vec3 T, vec3 I, float ssr_id, out Closure result)
|
||||
{
|
||||
#ifdef EEVEE_ENGINE
|
||||
if (clearcoat == 0.0) {
|
||||
node_bsdf_principled_simple(
|
||||
base_color, subsurface, subsurface_radius, subsurface_color, metallic, specular,
|
||||
specular_tint, roughness, anisotropic, anisotropic_rotation, sheen, sheen_tint, clearcoat,
|
||||
clearcoat_roughness, ior, transmission, transmission_roughness, N, CN, T, I, ssr_id, result);
|
||||
return;
|
||||
}
|
||||
|
||||
vec3 diffuse, f0, ssr_spec;
|
||||
convert_metallic_to_specular_tinted(base_color.rgb, metallic, specular, specular_tint, diffuse, f0);
|
||||
|
||||
|
|
|
@ -98,13 +98,7 @@ static int node_shader_gpu_bsdf_principled(GPUMaterial *mat, bNode *node, bNodeE
|
|||
&in[19].link);
|
||||
}
|
||||
|
||||
/* Only use complex versions when needed. */
|
||||
if (!in[12].link && (in[12].vec[0] == 0.0f)) {
|
||||
return GPU_stack_link(mat, node, "node_bsdf_principled_simple", in, out, GPU_builtin(GPU_VIEW_POSITION), GPU_uniform(&node->ssr_id));
|
||||
}
|
||||
else {
|
||||
return GPU_stack_link(mat, node, "node_bsdf_principled_clearcoat", in, out, GPU_builtin(GPU_VIEW_POSITION), GPU_uniform(&node->ssr_id));
|
||||
}
|
||||
return GPU_stack_link(mat, node, "node_bsdf_principled_clearcoat", in, out, GPU_builtin(GPU_VIEW_POSITION), GPU_uniform(&node->ssr_id));
|
||||
}
|
||||
|
||||
static void node_shader_update_principled(bNodeTree *UNUSED(ntree), bNode *node)
|
||||
|
|
Loading…
Reference in New Issue