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>2021-02-13 20:50:09 +0300
committerClément Foucault <foucault.clem@gmail.com>2021-02-13 20:52:19 +0300
commit83ac8628c490eda4fa5237b7a4256bc670dc0682 (patch)
tree89563a6d46dcea4ea51b70d23b3a73e7637161a6 /source/blender/gpu
parent06492fd61984c1a92fb1f93d30028de97ead451f (diff)
EEVEE: Update LUT GGX generation shader
This modifies the principled BSDF and the Glass BSDF which now have better fit to multiscatter GGX. Code to generate the LUT have been updated and can run at runtime. The refraction LUT has been changed to have the critical angle always centered around one pixel so that interpolation can be mitigated. Offline LUT data will be updated in another commit This simplify the BTDF retreival removing the manual clean cut at low roughness. This maximize the precision of the LUT by scalling the sides by the critical angle. I also touched the ior > 1.0 approximation to be smoother. Also incluse some cleanup of bsdf_sampling.glsl
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/shaders/material/gpu_shader_material_glass.glsl21
-rw-r--r--source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl11
2 files changed, 22 insertions, 10 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 ba02ae6d886..6788b34c938 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_glass.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_glass.glsl
@@ -6,8 +6,8 @@ void node_bsdf_glass(vec4 color,
float roughness,
float ior,
vec3 N,
- float use_multiscatter,
- float ssr_id,
+ const float do_multiscatter,
+ const float ssr_id,
out Closure result)
{
CLOSURE_VARS_DECLARE_2(Glossy, Refraction);
@@ -23,11 +23,16 @@ void node_bsdf_glass(vec4 color,
result = CLOSURE_DEFAULT;
- float fresnel = F_eta(in_Refraction_1.ior, dot(in_Glossy_0.N, cameraVec));
+ float NV = dot(in_Refraction_1.N, cameraVec);
+
+ float fresnel = (do_multiscatter != 0.0) ?
+ btdf_lut(NV, in_Refraction_1.roughness, in_Refraction_1.ior).y :
+ F_eta(in_Refraction_1.ior, NV);
+
+ vec2 split_sum = brdf_lut(NV, in_Glossy_0.roughness);
+ vec3 brdf = (do_multiscatter != 0.0) ? F_brdf_multi_scatter(vec3(1.0), vec3(1.0), split_sum) :
+ F_brdf_single_scatter(vec3(1.0), vec3(1.0), split_sum);
- vec2 split_sum = brdf_lut(dot(in_Glossy_0.N, cameraVec), in_Glossy_0.roughness);
- vec3 brdf = (use_multiscatter != 0.0) ? F_brdf_multi_scatter(vec3(1.0), vec3(1.0), split_sum) :
- F_brdf_single_scatter(vec3(1.0), vec3(1.0), split_sum);
out_Glossy_0.radiance = closure_mask_ssr_radiance(out_Glossy_0.radiance, ssr_id);
out_Glossy_0.radiance *= brdf;
out_Glossy_0.radiance = render_pass_glossy_mask(vec3(1.0), out_Glossy_0.radiance);
@@ -35,6 +40,10 @@ void node_bsdf_glass(vec4 color,
closure_load_ssr_data(
out_Glossy_0.radiance, in_Glossy_0.roughness, in_Glossy_0.N, ssr_id, result);
+ float btdf = (do_multiscatter != 0.0) ?
+ 1.0 :
+ btdf_lut(NV, in_Refraction_1.roughness, in_Refraction_1.ior).x;
+ out_Refraction_1.radiance *= btdf;
out_Refraction_1.radiance = render_pass_glossy_mask(vec3(1.0), out_Refraction_1.radiance);
out_Refraction_1.radiance *= color.rgb * (1.0 - fresnel);
/* Simulate 2nd absorption event. */
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl
index 15958dcf65e..139dcb33222 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl
@@ -70,7 +70,6 @@ void node_bsdf_principled(vec4 base_color,
in_Refraction_3.N = N; /* Normalized during eval. */
in_Refraction_3.roughness = do_multiscatter != 0.0 ? roughness : transmission_roughness;
in_Refraction_3.ior = ior;
-
CLOSURE_EVAL_FUNCTION_4(node_bsdf_principled, Diffuse, Glossy, Glossy, Refraction);
@@ -92,9 +91,9 @@ void node_bsdf_principled(vec4 base_color,
vec3 base_color_tint = tint_from_color(base_color.rgb);
- /* TODO(fclem) This isn't good for rough glass using multiscatter (since the fresnel is applied
- * on each microfacet in cycles). */
- float fresnel = F_eta(in_Refraction_3.ior, NV);
+ float fresnel = (do_multiscatter != 0.0) ?
+ btdf_lut(NV, in_Glossy_1.roughness, in_Refraction_3.ior).y :
+ F_eta(in_Refraction_3.ior, NV);
{
/* Glossy reflections.
@@ -159,7 +158,11 @@ void node_bsdf_principled(vec4 base_color,
}
if (transmission > 1e-5) {
+ float btdf = (do_multiscatter != 0.0) ?
+ 1.0 :
+ btdf_lut(NV, in_Refraction_3.roughness, in_Refraction_3.ior).x;
/* TODO(fclem) This could be going to a transmission render pass instead. */
+ out_Refraction_3.radiance *= btdf;
out_Refraction_3.radiance = render_pass_glossy_mask(vec3(1), out_Refraction_3.radiance);
out_Refraction_3.radiance *= base_color.rgb;
/* Simulate 2nd transmission event. */