Skip to content

Commit bd96957

Browse files
authored
Clamp BSDL/MTX Fresnel inputs and fix bootstrap Imath link (#2081)
Clamp generalized Schlick F0/F90 to [0, 1] in the MTX Schlick Fresnel constructor, and clamp the MTX conductor average-Fresnel fit to [0, 1] to avoid invalid albedo estimates from the approximation. Also update BSDL bootstrap linking to use Imath::Imath directly instead of ${ARNOLD_IMATH_TARGETS}. Signed-off-by: Alejandro Conty <aconty@imageworks.com>
1 parent ae8fa4e commit bd96957

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/libbsdl/bsdl.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function(ADD_BSDL_LIBRARY NAME)
99
# Bootstrap version of BSDL (without luts)
1010
add_library(BSDL_BOOTSTRAP INTERFACE)
1111
target_include_directories(BSDL_BOOTSTRAP INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/${bsdl_SUBDIR}/include)
12-
target_link_libraries(BSDL_BOOTSTRAP INTERFACE ${ARNOLD_IMATH_TARGETS})
12+
target_link_libraries(BSDL_BOOTSTRAP INTERFACE Imath::Imath)
1313

1414
# LUT generation tool
1515
set(BSDL_GEN_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/${bsdl_SUBDIR}/geninclude)

src/libbsdl/include/BSDL/MTX/bsdf_conductor_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ ConductorFresnel::avg() const
7070
d = -0.07785134f;
7171
const float x = IOR[i], y = extinction[i];
7272
const float p = a + b * x + c * y + d * x * y;
73-
return p / (1 + p);
73+
return CLAMP(p / (1 + p), 0.0f, 1.0f);
7474
},
7575
lambda_0);
7676
}

src/libbsdl/include/BSDL/MTX/bsdf_schlick_impl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ namespace mtx {
1616
SchlickFresnel::SchlickFresnel(Power F0, Power F90, float exponent, float _eta,
1717
bool backfacing)
1818
: DielectricFresnel(_eta, backfacing)
19-
, F0(F0)
20-
, F90(F90)
19+
, F0(F0.clamped(0, 1))
20+
, F90(F90.clamped(0, 1))
2121
, exponent(exponent)
2222
, tir_cos(eta >= 1
2323
? 0

0 commit comments

Comments
 (0)