ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/cmbsdf.c
(Generate patch)

Comparing ray/src/util/cmbsdf.c (file contents):
Revision 2.8 by greg, Tue Mar 17 23:24:05 2020 UTC vs.
Revision 2.9 by greg, Tue Jan 19 23:32:00 2021 UTC

# Line 144 | Line 144 | cm_bsdf_Lamb(const COLOR diffBSDF)
144  
145   /* Load and convert a matrix BTDF from the given XML file */
146   CMATRIX *
147 < cm_loadBTDF(char *fname)
147 > cm_loadBTDF(const char *fname)
148   {
149          CMATRIX         *Tmat;
150          int             recip;
151          SDError         ec;
152          SDData          myBSDF;
153          SDSpectralDF    *tdf;
154 <        COLOR           diffBSDF;
154 >        COLOR           diffBTDF;
155  
156          SDclearBSDF(&myBSDF, fname);    /* load XML and check type */
157          ec = SDloadFile(&myBSDF, fname);
158          if (ec)
159                  error(USER, transSDError(ec));
160 <        ccy2rgb(&myBSDF.tLamb.spec, myBSDF.tLamb.cieY/PI, diffBSDF);
160 >        ccy2rgb(&myBSDF.tLamb.spec, myBSDF.tLamb.cieY/PI, diffBTDF);
161          recip = (myBSDF.tb == NULL);
162          tdf = recip ? myBSDF.tf : myBSDF.tb;
163          if (tdf == NULL) {              /* no non-Lambertian transmission? */
164                  SDfreeBSDF(&myBSDF);
165 <                return(cm_bsdf_Lamb(diffBSDF));
165 >                return(cm_bsdf_Lamb(diffBTDF));
166          }
167          if (tdf->ncomp != 1 || tdf->comp[0].func != &SDhandleMtx) {
168                  sprintf(errmsg, "unsupported BSDF '%s'", fname);
169                  error(USER, errmsg);
170          }
171                                          /* convert BTDF to matrix */
172 <        Tmat = recip ? cm_bsdf_recip(diffBSDF, (SDMat *)tdf->comp[0].dist)
173 <                        : cm_bsdf(diffBSDF, (SDMat *)tdf->comp[0].dist);
172 >        Tmat = recip ? cm_bsdf_recip(diffBTDF, (SDMat *)tdf->comp[0].dist)
173 >                        : cm_bsdf(diffBTDF, (SDMat *)tdf->comp[0].dist);
174                                          /* free BSDF and return */
175          SDfreeBSDF(&myBSDF);
176          return(Tmat);
177 + }
178 +
179 + /* Load and convert a matrix BRDF from the given XML file */
180 + CMATRIX *
181 + cm_loadBRDF(const char *fname, int backside)
182 + {
183 +        CMATRIX         *Rmat;
184 +        SDError         ec;
185 +        SDData          myBSDF;
186 +        SDSpectralDF    *rdf;
187 +        COLOR           diffBRDF;
188 +
189 +        SDclearBSDF(&myBSDF, fname);    /* load XML and check type */
190 +        ec = SDloadFile(&myBSDF, fname);
191 +        if (ec)
192 +                error(USER, transSDError(ec));
193 +        if (backside) {
194 +                ccy2rgb(&myBSDF.rLambBack.spec, myBSDF.rLambBack.cieY/PI, diffBRDF);
195 +                rdf = myBSDF.rb;
196 +        } else {
197 +                ccy2rgb(&myBSDF.rLambFront.spec, myBSDF.rLambFront.cieY/PI, diffBRDF);
198 +                rdf = myBSDF.rf;
199 +        }
200 +        if (rdf == NULL) {              /* no non-Lambertian reflection? */
201 +                SDfreeBSDF(&myBSDF);
202 +                return(cm_bsdf_Lamb(diffBRDF));
203 +        }
204 +        if (rdf->ncomp != 1 || rdf->comp[0].func != &SDhandleMtx) {
205 +                sprintf(errmsg, "unsupported BSDF '%s'", fname);
206 +                error(USER, errmsg);
207 +        }
208 +                                        /* convert BRDF to matrix */
209 +        Rmat = cm_bsdf(diffBRDF, (SDMat *)rdf->comp[0].dist);
210 +                                        /* free BSDF and return */
211 +        SDfreeBSDF(&myBSDF);
212 +        return(Rmat);
213   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines