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

Comparing ray/src/common/testBSDF.c (file contents):
Revision 1.6 by greg, Thu Feb 2 00:27:55 2017 UTC vs.
Revision 1.11 by greg, Tue Apr 11 16:14:05 2017 UTC

# Line 24 | Line 24 | Usage(const char *prog)
24          printf("  i\t\t\t\t Report general information (metadata)\n");
25          printf("  c\t\t\t\t Report diffuse and specular components\n");
26          printf("  q theta_i phi_i theta_o phi_o\t Query BSDF for given path (CIE-XYZ)\n");
27 <        printf("  s N theta phi\t\t\t Generate N ray directions at given incidence\n");
28 <        printf("  h theta phi\t\t\t Report hemispherical total at given incidence\n");
29 <        printf("  r theta phi\t\t\t Report hemispherical reflection at given incidence\n");
30 <        printf("  t theta phi\t\t\t Report hemispherical transmission at given incidence\n");
27 >        printf("  s[r|t][s|d] N theta phi\t Generate N ray directions & colors at given incidence\n");
28 >        printf("  h[s|d] theta phi\t\t Report hemispherical scattering at given incidence\n");
29 >        printf("  r[s|d] theta phi\t\t Report hemispherical reflection at given incidence\n");
30 >        printf("  t[s|d] theta phi\t\t Report hemispherical transmission at given incidence\n");
31          printf("  a theta phi [t2 p2]\t\t Report resolution (in proj. steradians) for given direction(s)\n");
32          printf("  ^D\t\t\t\t Quit program\n");
33   }
# Line 47 | Line 47 | vec_from_deg(FVECT v, double theta, double phi)
47   static void
48   printXYZ(const char *intro, const SDValue *vp)
49   {
50 +        if (vp->cieY <= 1e-9) {
51 +                printf("%s0 0 0\n", intro);
52 +                return;
53 +        }
54          printf("%s%.3e %.3e %.3e\n", intro,
55                          vp->spec.cx/vp->spec.cy*vp->cieY,
56                          vp->cieY,
# Line 71 | Line 75 | main(int argc, char *argv[])
75          SDretainSet = SDretainBSDFs;            /* keep BSDFs in memory */
76  
77                                                  /* loop on command */
78 <        while (fgets(inp, sizeof(inp), stdin) != NULL) {
78 >        while (fgets(inp, sizeof(inp), stdin)) {
79                  int     sflags = SDsampAll;
80                  char    *cp = inp;
81                  char    *cp2;
82                  FVECT   vin, vout;
83                  double  proja[2];
84 <                int     n;
84 >                int     n, i;
85                  SDValue val;
86                  
87                  while (isspace(*cp)) cp++;
# Line 98 | Line 102 | main(int argc, char *argv[])
102                          bsdf = SDcacheFile(path);
103                          continue;
104                  case 'I':                       /* report general info. */
105 <                        if (bsdf == NULL)
105 >                        if (!bsdf)
106                                  goto noBSDFerr;
107                          printf("Material: '%s'\n", bsdf->matn);
108                          printf("Manufacturer: '%s'\n", bsdf->makr);
105                        printf("Has geometry: %s\n", bsdf->mgf!=NULL ? "yes" : "no");
109                          printf("Width, Height, Thickness (m): %.4e, %.4e, %.4e\n",
110                                          bsdf->dim[0], bsdf->dim[1], bsdf->dim[2]);
111 +                        printf("Has geometry: %s\n", bsdf->mgf ? "yes" : "no");
112                          continue;
113                  case 'C':                       /* report constant values */
114 <                        if (bsdf == NULL)
114 >                        if (!bsdf)
115                                  goto noBSDFerr;
116 <                        if (bsdf->rf != NULL)
116 >                        if (bsdf->rf)
117                                  printf("Peak front hemispherical reflectance: %.3e\n",
118                                                  bsdf->rLambFront.cieY +
119                                                  bsdf->rf->maxHemi);
120 <                        if (bsdf->rb != NULL)
120 >                        if (bsdf->rb)
121                                  printf("Peak back hemispherical reflectance: %.3e\n",
122                                                  bsdf->rLambBack.cieY +
123                                                  bsdf->rb->maxHemi);
124 <                        if (bsdf->tf != NULL)
124 >                        if (bsdf->tf)
125                                  printf("Peak front hemispherical transmittance: %.3e\n",
126                                                  bsdf->tLamb.cieY + bsdf->tf->maxHemi);
127 <                        if (bsdf->tb != NULL)
127 >                        if (bsdf->tb)
128                                  printf("Peak back hemispherical transmittance: %.3e\n",
129                                                  bsdf->tLamb.cieY + bsdf->tb->maxHemi);
130                          printXYZ("Diffuse Front Reflectance: ", &bsdf->rLambFront);
# Line 128 | Line 132 | main(int argc, char *argv[])
132                          printXYZ("Diffuse Transmittance: ", &bsdf->tLamb);
133                          continue;
134                  case 'Q':                       /* query BSDF value */
135 <                        if (bsdf == NULL)
135 >                        if (!bsdf)
136                                  goto noBSDFerr;
137                          if (!*sskip2(cp,4))
138                                  break;
# Line 138 | Line 142 | main(int argc, char *argv[])
142                                  printXYZ("", &val);
143                          continue;
144                  case 'S':                       /* sample BSDF */
145 <                        if (bsdf == NULL)
145 >                        if (!bsdf)
146                                  goto noBSDFerr;
147                          if (!*sskip2(cp,3))
148                                  break;
149 <                        n = atoi(sskip2(cp,1));
149 >                        if (toupper(cp[1]) == 'R') {
150 >                                sflags &= ~SDsampT;
151 >                                ++cp;
152 >                        } else if (toupper(cp[1]) == 'T') {
153 >                                sflags &= ~SDsampR;
154 >                                ++cp;
155 >                        }
156 >                        if (toupper(cp[1]) == 'S')
157 >                                sflags &= ~SDsampDf;
158 >                        else if (toupper(cp[1]) == 'D')
159 >                                sflags &= ~SDsampSp;
160 >                        i = n = atoi(sskip2(cp,1));
161                          vec_from_deg(vin, atof(sskip2(cp,2)), atof(sskip2(cp,3)));
162 <                        while (n-- > 0) {
163 <                                if (SDreportError(SDsampBSDF(&val, vin,
164 <                                                rand()*(1./(RAND_MAX+.5)),
162 >                        while (i-- > 0) {
163 >                                VCOPY(vout, vin);
164 >                                if (SDreportError(SDsampBSDF(&val, vout,
165 >                                                (i+rand()*(1./(RAND_MAX+.5)))/(double)n,
166                                                  sflags, bsdf), stderr))
167                                          break;
168 <                                printf("%.8f %.8f %.8f\n", vin[0], vin[1], vin[2]);
168 >                                printf("%.8f %.8f %.8f ", vout[0], vout[1], vout[2]);
169 >                                printXYZ("", &val);
170                          }
171                          continue;
172 <                case 'H':                       /* hemispherical totals */
172 >                case 'H':                       /* hemispherical values */
173                  case 'R':
174                  case 'T':
175 <                        if (bsdf == NULL)
175 >                        if (!bsdf)
176                                  goto noBSDFerr;
177                          if (!*sskip2(cp,2))
178                                  break;
179 <                        if (tolower(*cp) == 'r')
179 >                        if (toupper(cp[0]) == 'R')
180                                  sflags &= ~SDsampT;
181 <                        else if (tolower(*cp) == 't')
181 >                        else if (toupper(cp[0]) == 'T')
182                                  sflags &= ~SDsampR;
183 +                        if (toupper(cp[1]) == 'S')
184 +                                sflags &= ~SDsampDf;
185 +                        else if (toupper(cp[1]) == 'D')
186 +                                sflags &= ~SDsampSp;
187                          vec_from_deg(vin, atof(sskip2(cp,1)), atof(sskip2(cp,2)));
188                          printf("%.4e\n", SDdirectHemi(vin, sflags, bsdf));
189                          continue;
190                  case 'A':                       /* resolution in proj. steradians */
191 <                        if (bsdf == NULL)
191 >                        if (!bsdf)
192                                  goto noBSDFerr;
193                          if (!*sskip2(cp,2))
194                                  break;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines