From 0c628c218a797d20cf9a84158ccb66e381a2503f Mon Sep 17 00:00:00 2001 From: "Gregory J. Ward" Date: Sat, 27 Mar 2021 20:08:30 +0000 Subject: [PATCH] fix: Use reciprocity for diffuse transmittance if given only one side's BTDF --- src/common/bsdf_m.c | 9 +++++++-- src/common/bsdf_t.c | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/common/bsdf_m.c b/src/common/bsdf_m.c index 28f1a95b..42459cbe 100644 --- a/src/common/bsdf_m.c +++ b/src/common/bsdf_m.c @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: bsdf_m.c,v 3.41 2021/03/27 17:50:18 greg Exp $"; +static const char RCSid[] = "$Id: bsdf_m.c,v 3.42 2021/03/27 20:08:30 greg Exp $"; #endif /* * bsdf_m.c @@ -710,7 +710,12 @@ SDloadMtx(SDData *sd, ezxml_t wtl) sd->rf = extract_diffuse(&sd->rLambFront, sd->rf); sd->rb = extract_diffuse(&sd->rLambBack, sd->rb); sd->tf = extract_diffuse(&sd->tLambFront, sd->tf); - sd->tb = extract_diffuse(&sd->tLambBack, sd->tb); + if (sd->tb != NULL) { + sd->tb = extract_diffuse(&sd->tLambBack, sd->tb); + if (sd->tf == NULL) + sd->tLambFront = sd->tLambBack; + } else if (sd->tf != NULL) + sd->tLambBack = sd->tLambFront; /* return success */ return SDEnone; } diff --git a/src/common/bsdf_t.c b/src/common/bsdf_t.c index 5a8cbb6e..4b36f175 100644 --- a/src/common/bsdf_t.c +++ b/src/common/bsdf_t.c @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: bsdf_t.c,v 3.50 2021/03/27 17:50:18 greg Exp $"; +static const char RCSid[] = "$Id: bsdf_t.c,v 3.51 2021/03/27 20:08:30 greg Exp $"; #endif /* * bsdf_t.c @@ -1431,7 +1431,12 @@ SDloadTre(SDData *sd, ezxml_t wtl) extract_diffuse(&sd->rLambFront, sd->rf); extract_diffuse(&sd->rLambBack, sd->rb); extract_diffuse(&sd->tLambFront, sd->tf); - extract_diffuse(&sd->tLambBack, sd->tb); + if (sd->tb != NULL) { + extract_diffuse(&sd->tLambBack, sd->tb); + if (sd->tf == NULL) + sd->tLambFront = sd->tLambBack; + } else if (sd->tf != NULL) + sd->tLambBack = sd->tLambFront; /* return success */ return SDEnone; }