EEVEE-Next: Make Specular BSDF work
This removes the ambient occlusion socket as this have no use in EEVEE-Next. Add correct material flags for noiseless clear coat and fix transparency.
This commit is contained in:
@@ -225,8 +225,7 @@ Closure closure_eval(ClosureSubsurface diffuse, ClosureReflection reflection)
|
||||
/* Glue with the old system. */
|
||||
CLOSURE_VARS_DECLARE_2(Diffuse, Glossy);
|
||||
|
||||
/* WORKAROUND: This is to avoid regression in 3.2 and avoid messing with EEVEE-Next. */
|
||||
in_common.occlusion = (diffuse.sss_radius.g == -1.0) ? diffuse.sss_radius.r : 1.0;
|
||||
in_common.occlusion = 1.0;
|
||||
in_Diffuse_0.N = diffuse.N;
|
||||
in_Diffuse_0.albedo = diffuse.color;
|
||||
in_Glossy_1.N = reflection.N;
|
||||
@@ -261,8 +260,7 @@ Closure closure_eval(ClosureSubsurface diffuse,
|
||||
/* Glue with the old system. */
|
||||
CLOSURE_VARS_DECLARE_3(Diffuse, Glossy, Glossy);
|
||||
|
||||
/* WORKAROUND: This is to avoid regression in 3.2 and avoid messing with EEVEE-Next. */
|
||||
in_common.occlusion = (diffuse.sss_radius.g == -1.0) ? diffuse.sss_radius.r : 1.0;
|
||||
in_common.occlusion = 1.0;
|
||||
in_Diffuse_0.N = diffuse.N;
|
||||
in_Diffuse_0.albedo = diffuse.color;
|
||||
in_Glossy_1.N = reflection.N;
|
||||
|
||||
@@ -11,7 +11,6 @@ void node_eevee_specular(vec4 diffuse,
|
||||
float clearcoat,
|
||||
float clearcoat_roughness,
|
||||
vec3 CN,
|
||||
float occlusion,
|
||||
float weight,
|
||||
const float use_clearcoat,
|
||||
out Closure result)
|
||||
@@ -24,7 +23,6 @@ void node_eevee_specular(vec4 diffuse,
|
||||
clearcoat = saturate(clearcoat);
|
||||
clearcoat_roughness = saturate(clearcoat_roughness);
|
||||
CN = safe_normalize(CN);
|
||||
occlusion = saturate(occlusion);
|
||||
|
||||
vec3 V = coordinate_incoming(g_data.P);
|
||||
|
||||
@@ -39,29 +37,11 @@ void node_eevee_specular(vec4 diffuse,
|
||||
|
||||
float alpha = (1.0 - transp) * weight;
|
||||
|
||||
#ifdef GPU_SHADER_EEVEE_LEGACY_DEFINES
|
||||
/* EEVEE Legacy evaluates the subsurface as a diffuse closure.
|
||||
* So this has no performance penalty. However, using a separate closure for subsurface
|
||||
* (just like for EEVEE-Next) would induce a huge performance hit. */
|
||||
ClosureSubsurface diffuse_data;
|
||||
/* Disable subsurface. */
|
||||
diffuse_data.sss_radius.b = -1.0;
|
||||
#else
|
||||
ClosureDiffuse diffuse_data;
|
||||
#endif
|
||||
diffuse_data.weight = alpha;
|
||||
diffuse_data.color = diffuse.rgb;
|
||||
diffuse_data.N = N;
|
||||
|
||||
#ifdef GPU_SHADER_EEVEE_LEGACY_DEFINES
|
||||
/* WORKAROUND: Nasty workaround to the current interface with the closure evaluation.
|
||||
* Ideally the occlusion input should be move to the output node or removed all-together.
|
||||
* This is temporary to avoid a regression in 3.2 and should be removed after EEVEE-Next rewrite.
|
||||
*/
|
||||
diffuse_data.sss_radius.r = occlusion;
|
||||
diffuse_data.sss_radius.g = -1.0; /* Flag */
|
||||
#endif
|
||||
|
||||
ClosureReflection reflection_data;
|
||||
reflection_data.weight = alpha;
|
||||
if (true) {
|
||||
|
||||
@@ -33,7 +33,6 @@ static void node_declare(NodeDeclarationBuilder &b)
|
||||
.max(1.0f)
|
||||
.subtype(PROP_FACTOR);
|
||||
b.add_input<decl::Vector>("Clear Coat Normal").hide_value();
|
||||
b.add_input<decl::Float>("Ambient Occlusion").hide_value();
|
||||
b.add_input<decl::Float>("Weight").unavailable();
|
||||
b.add_output<decl::Shader>("BSDF");
|
||||
}
|
||||
@@ -46,8 +45,6 @@ static int node_shader_gpu_eevee_specular(GPUMaterial *mat,
|
||||
GPUNodeStack *in,
|
||||
GPUNodeStack *out)
|
||||
{
|
||||
static float one = 1.0f;
|
||||
|
||||
/* Normals */
|
||||
if (!in[5].link) {
|
||||
GPU_link(mat, "world_normals_get", &in[5].link);
|
||||
@@ -58,16 +55,21 @@ static int node_shader_gpu_eevee_specular(GPUMaterial *mat,
|
||||
GPU_link(mat, "world_normals_get", &in[8].link);
|
||||
}
|
||||
|
||||
/* Occlusion */
|
||||
if (!in[9].link) {
|
||||
GPU_link(mat, "set_value", GPU_constant(&one), &in[9].link);
|
||||
bool use_transparency = socket_not_zero(4);
|
||||
bool use_coat = socket_not_zero(6);
|
||||
|
||||
eGPUMaterialFlag flag = GPU_MATFLAG_DIFFUSE | GPU_MATFLAG_GLOSSY;
|
||||
if (use_coat) {
|
||||
flag |= GPU_MATFLAG_COAT;
|
||||
}
|
||||
if (use_transparency) {
|
||||
flag |= GPU_MATFLAG_TRANSPARENT;
|
||||
}
|
||||
|
||||
GPU_material_flag_set(mat, GPU_MATFLAG_DIFFUSE | GPU_MATFLAG_GLOSSY);
|
||||
GPU_material_flag_set(mat, flag);
|
||||
|
||||
float use_clear = socket_not_zero(6) ? 1.0f : 0.0f;
|
||||
|
||||
return GPU_stack_link(mat, node, "node_eevee_specular", in, out, GPU_constant(&use_clear));
|
||||
float use_coat_f = use_coat ? 1.0f : 0.0f;
|
||||
return GPU_stack_link(mat, node, "node_eevee_specular", in, out, GPU_constant(&use_coat_f));
|
||||
}
|
||||
|
||||
} // namespace blender::nodes::node_shader_eevee_specular_cc
|
||||
|
||||
Reference in New Issue
Block a user