Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2020-09-19 01:06:45 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-09-19 01:09:51 +0300
commit6f3c279d9e7082b963f3ca758f6ba0561c4bcc9c (patch)
tree1ea2b44e57e192dd9a23223d605d1244734bff9e /source/blender/nodes
parentaa2e978bd8b47dbc06826698b07d850cdd499568 (diff)
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
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c10
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c3
3 files changed, 16 insertions, 2 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c
index b0e17ed7716..7ce085d2c82 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c
@@ -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 */
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
index 2bbd260fe0e..13b1b21c7fc 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
@@ -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 */
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
index ccc5198832a..b9f0e793a61 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
@@ -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);