From 92dded67bbcd72afbec947fa573c4ce8d6c7c5db Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Thu, 7 Jul 2022 18:56:34 -0700 Subject: [PATCH] Fix initialization warning in GLSL This changelist refactors the implementation of mx_surface_transmission in GLSL, addressing an initialization warning when the function is called in WebGL. --- .../pbrlib/genglsl/lib/mx_transmission_refract.glsl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libraries/pbrlib/genglsl/lib/mx_transmission_refract.glsl b/libraries/pbrlib/genglsl/lib/mx_transmission_refract.glsl index 14df438860..d3b2cd7d5e 100644 --- a/libraries/pbrlib/genglsl/lib/mx_transmission_refract.glsl +++ b/libraries/pbrlib/genglsl/lib/mx_transmission_refract.glsl @@ -2,14 +2,19 @@ vec3 mx_surface_transmission(vec3 N, vec3 V, vec3 X, vec2 alpha, int distribution, FresnelData fd) { + vec3 transmission; if ($refractionEnv) { - // Approximate the appearance of dielectric transmission as glossy + // Approximate the appearance of surface transmission as glossy // environment map refraction, ignoring any scene geometry that might // be visible through the surface. fd.refraction = true; - return mx_environment_radiance(N, V, X, alpha, distribution, fd); + transmission = mx_environment_radiance(N, V, X, alpha, distribution, fd); + } + else + { + transmission = $refractionColor; } - return $refractionColor; + return transmission; }