EEVEE: Fix Missing GGX multi-scattering on Glass BSDF
Oversight that should have been in rB6f3c279d9e70
This commit is contained in:
parent
6f3c279d9e
commit
7b9e47a35e
Notes:
blender-bot
2023-02-13 20:29:28 +01:00
Referenced by issue #82857, Crash on GP toggle select mode
|
@ -1,6 +1,11 @@
|
|||
#ifndef VOLUMETRICS
|
||||
void node_bsdf_glass(
|
||||
vec4 color, float roughness, float ior, vec3 N, float ssr_id, out Closure result)
|
||||
void node_bsdf_glass(vec4 color,
|
||||
float roughness,
|
||||
float ior,
|
||||
vec3 N,
|
||||
float use_multiscatter,
|
||||
float ssr_id,
|
||||
out Closure result)
|
||||
{
|
||||
N = normalize(N);
|
||||
vec3 out_spec, out_refr, ssr_spec;
|
||||
|
@ -8,7 +13,9 @@ void node_bsdf_glass(
|
|||
color.rgb; /* Simulate 2 transmission event */
|
||||
eevee_closure_glass(N,
|
||||
vec3(1.0),
|
||||
vec3(1.0),
|
||||
/* HACK: Pass the multiscatter flag as the sign to not add closure
|
||||
* variations or increase register usage. */
|
||||
(use_multiscatter != 0.0) ? vec3(1.0) : -vec3(1.0),
|
||||
int(ssr_id),
|
||||
roughness,
|
||||
1.0,
|
||||
|
@ -28,5 +35,5 @@ void node_bsdf_glass(
|
|||
}
|
||||
#else
|
||||
/* Stub glass because it is not compatible with volumetrics. */
|
||||
# define node_bsdf_glass(a, b, c, d, e, f) (f = CLOSURE_DEFAULT)
|
||||
# define node_bsdf_glass(a, b, c, d, e, f, result) (result = CLOSURE_DEFAULT)
|
||||
#endif
|
||||
|
|
|
@ -51,7 +51,15 @@ static int node_shader_gpu_bsdf_glass(GPUMaterial *mat,
|
|||
|
||||
GPU_material_flag_set(mat, GPU_MATFLAG_GLOSSY | GPU_MATFLAG_REFRACT);
|
||||
|
||||
return GPU_stack_link(mat, node, "node_bsdf_glass", in, out, GPU_constant(&node->ssr_id));
|
||||
float use_multi_scatter = (node->custom1 == SHD_GLOSSY_MULTI_GGX) ? 1.0f : 0.0f;
|
||||
|
||||
return GPU_stack_link(mat,
|
||||
node,
|
||||
"node_bsdf_glass",
|
||||
in,
|
||||
out,
|
||||
GPU_constant(&use_multi_scatter),
|
||||
GPU_constant(&node->ssr_id));
|
||||
}
|
||||
|
||||
/* node type definition */
|
||||
|
|
Loading…
Reference in New Issue