diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/gpu/shaders/material/gpu_shader_material_glass.glsl | 15 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c | 10 |
2 files changed, 20 insertions, 5 deletions
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_glass.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_glass.glsl index 6d782ff18de..c328b4800bc 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_glass.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_glass.glsl @@ -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 diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c index cab25c7ddd0..e0fcce6f617 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c @@ -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 */ |