EEVEE: Add support for GGX Multi-scatter
Based on http://jcgt.org/published/0008/01/03/ This is a simple trick that does *not* have a huge performance impact but does work pretty well. It just modifies the Fresnel term to account for the multibounce energy loss (coloration). However this makes the shader variations count double. To avoid this we use a uniform and pass the multiscatter use flag inside the sign of f90. This is a bit hacky but avoids many code duplication. This uses the simplification proposed by McAuley in A Journey Through Implementing Multiscattering BRDFs and Area Lights This does not handle area light differently than the IBL case but that's already an issue in current implementation. This is related to T68460. Reviewed By: brecht Differential Revision: https://developer.blender.org/D8912
This commit is contained in:
@@ -53,7 +53,10 @@ static int node_shader_gpu_bsdf_anisotropic(GPUMaterial *mat,
|
||||
|
||||
GPU_material_flag_set(mat, GPU_MATFLAG_GLOSSY);
|
||||
|
||||
return GPU_stack_link(mat, node, "node_bsdf_anisotropic", in, out);
|
||||
float use_multi_scatter = (node->custom1 == SHD_GLOSSY_MULTI_GGX) ? 1.0f : 0.0f;
|
||||
|
||||
return GPU_stack_link(
|
||||
mat, node, "node_bsdf_anisotropic", in, out, GPU_constant(&use_multi_scatter));
|
||||
}
|
||||
|
||||
/* node type definition */
|
||||
|
||||
@@ -54,7 +54,15 @@ static int node_shader_gpu_bsdf_glossy(GPUMaterial *mat,
|
||||
|
||||
GPU_material_flag_set(mat, GPU_MATFLAG_GLOSSY);
|
||||
|
||||
return GPU_stack_link(mat, node, "node_bsdf_glossy", 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_glossy",
|
||||
in,
|
||||
out,
|
||||
GPU_constant(&use_multi_scatter),
|
||||
GPU_constant(&node->ssr_id));
|
||||
}
|
||||
|
||||
/* node type definition */
|
||||
|
||||
@@ -172,6 +172,8 @@ static int node_shader_gpu_bsdf_principled(GPUMaterial *mat,
|
||||
flag |= GPU_MATFLAG_SSS;
|
||||
}
|
||||
|
||||
float use_multi_scatter = (node->custom1 == SHD_GLOSSY_MULTI_GGX) ? 1.0f : 0.0f;
|
||||
|
||||
GPU_material_flag_set(mat, flag);
|
||||
|
||||
return GPU_stack_link(mat,
|
||||
@@ -180,6 +182,7 @@ static int node_shader_gpu_bsdf_principled(GPUMaterial *mat,
|
||||
in,
|
||||
out,
|
||||
GPU_builtin(GPU_VIEW_POSITION),
|
||||
GPU_constant(&use_multi_scatter),
|
||||
GPU_constant(&node->ssr_id),
|
||||
GPU_constant(&node->sss_id),
|
||||
sss_scale);
|
||||
|
||||
Reference in New Issue
Block a user