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

Comparing ray/src/cv/bsdf2rad.c (file contents):
Revision 2.21 by greg, Mon Apr 10 15:44:19 2017 UTC vs.
Revision 2.24 by greg, Tue Apr 11 18:26:55 2017 UTC

# Line 26 | Line 26 | double overall_max = .0;               /* overall maximum BSDF valu
26  
27   char    ourTempDir[TEMPLEN] = "";       /* our temporary directory */
28  
29 const FVECT     Yaxis = {0., 1., 0.};
30
29   const char      frpref[] = "frefl";
30   const char      ftpref[] = "ftrans";
31   const char      brpref[] = "brefl";
32   const char      btpref[] = "btrans";
33   const char      dsuffix[] = ".txt";
34  
35 < const char      sph_mat[] = "BSDFmat";
35 > const char      sph_fmat[] = "fBSDFmat";
36 > const char      sph_bmat[] = "bBSDFmat";
37   const double    sph_rad = 10.;
38   const double    sph_xoffset = 15.;
39  
# Line 373 | Line 372 | static int
372   put_BSDFs(void)
373   {
374          const double    scalef = bsdf_rad/(log10(overall_max) - min_log10);
375 <        FVECT           ivec, sorg;
375 >        FVECT           ivec, sorg, upv;
376          RREAL           vMtx[3][3];
377          char            *fname;
378          char            cmdbuf[256];
# Line 385 | Line 384 | put_BSDFs(void)
384                          NINCIDENT);
385  
386          printf("\nvoid glow arrow_glow\n0\n0\n4 1 0 1 0\n");
387 <        printf("\nvoid mixfunc arrow_mat\n4 arrow_glow void 0.5 .\n0\n0\n");
387 >        printf("\nvoid mixfunc arrow_mat\n4 arrow_glow void 0.25 .\n0\n0\n");
388  
389          if (front_comp & SDsampR)                       /* front reflection */
390                  for (i = 0; i < NINCIDENT; i++) {
# Line 393 | Line 392 | put_BSDFs(void)
392                          put_mirror_arrow(ivec, 1);
393                          cvt_sposition(sorg, ivec, 1);
394                          ivec[0] = -ivec[0]; ivec[1] = -ivec[1]; /* normal */
395 +                        upv[0] = ivec[0]*ivec[1]*(ivec[2] - 1.);
396 +                        upv[1] = ivec[0]*ivec[0] + ivec[1]*ivec[1]*ivec[2];
397 +                        upv[2] = -ivec[1]*(ivec[0]*ivec[0] + ivec[1]*ivec[1]);
398                          sprintf(xfargs, "-s %f -t %f %f %f", bsdf_rad,
399                                          sorg[0], sorg[1], sorg[2]);
400                          nxfa = 6;
# Line 400 | Line 402 | put_BSDFs(void)
402                          printf("%d bsdf_red bsdf_grn bsdf_blu bsdf2rad.cal\n\t%s\n0\n0\n",
403                                          4+nxfa, xfargs);
404                          printf("\nscale_pat glow scale_mat\n0\n0\n4 1 1 1 0\n");
405 <                        SDcompXform(vMtx, ivec, Yaxis);
405 >                        if (SDcompXform(vMtx, ivec, upv) != SDEnone)
406 >                                continue;
407                          nxfa = addrot(xfargs, vMtx[0], vMtx[1], vMtx[2]);
408                          sprintf(xfargs+strlen(xfargs), " -s %f -t %f %f %f",
409                                          scalef, sorg[0], sorg[1], sorg[2]);
# Line 418 | Line 421 | put_BSDFs(void)
421                          put_trans_arrow(ivec, 1);
422                          cvt_sposition(sorg, ivec, 1);
423                          ivec[0] = -ivec[0]; ivec[1] = -ivec[1]; /* normal */
424 +                        upv[0] = ivec[0]*ivec[1]*(ivec[2] - 1.);
425 +                        upv[1] = ivec[0]*ivec[0] + ivec[1]*ivec[1]*ivec[2];
426 +                        upv[2] = -ivec[1]*(ivec[0]*ivec[0] + ivec[1]*ivec[1]);
427                          sprintf(xfargs, "-s %f -t %f %f %f", bsdf_rad,
428                                          sorg[0], sorg[1], sorg[2]);
429                          nxfa = 6;
# Line 425 | Line 431 | put_BSDFs(void)
431                          printf("%d bsdf_red bsdf_grn bsdf_blu bsdf2rad.cal\n\t%s\n0\n0\n",
432                                          4+nxfa, xfargs);
433                          printf("\nscale_pat glow scale_mat\n0\n0\n4 1 1 1 0\n");
434 <                        SDcompXform(vMtx, ivec, Yaxis);
434 >                        if (SDcompXform(vMtx, ivec, upv) != SDEnone)
435 >                                continue;
436                          nxfa = addrot(xfargs, vMtx[0], vMtx[1], vMtx[2]);
437                          sprintf(xfargs+strlen(xfargs), " -s %f -t %f %f %f",
438                                          scalef, sorg[0], sorg[1], sorg[2]);
# Line 443 | Line 450 | put_BSDFs(void)
450                          put_mirror_arrow(ivec, -1);
451                          cvt_sposition(sorg, ivec, -1);
452                          ivec[0] = -ivec[0]; ivec[1] = -ivec[1]; /* normal */
453 +                        upv[0] = ivec[0]*ivec[1]*(ivec[2] - 1.);
454 +                        upv[1] = ivec[0]*ivec[0] + ivec[1]*ivec[1]*ivec[2];
455 +                        upv[2] = -ivec[1]*(ivec[0]*ivec[0] + ivec[1]*ivec[1]);
456                          sprintf(xfargs, "-s %f -t %f %f %f", bsdf_rad,
457                                          sorg[0], sorg[1], sorg[2]);
458                          nxfa = 6;
# Line 450 | Line 460 | put_BSDFs(void)
460                          printf("%d bsdf_red bsdf_grn bsdf_blu bsdf2rad.cal\n\t%s\n0\n0\n",
461                                          4+nxfa, xfargs);
462                          printf("\nscale_pat glow scale_mat\n0\n0\n4 1 1 1 0\n");
463 <                        SDcompXform(vMtx, ivec, Yaxis);
463 >                        if (SDcompXform(vMtx, ivec, upv) != SDEnone)
464 >                                continue;
465                          nxfa = addrot(xfargs, vMtx[0], vMtx[1], vMtx[2]);
466                          sprintf(xfargs+strlen(xfargs), " -s %f -t %f %f %f",
467                                          scalef, sorg[0], sorg[1], sorg[2]);
# Line 468 | Line 479 | put_BSDFs(void)
479                          put_trans_arrow(ivec, -1);
480                          cvt_sposition(sorg, ivec, -1);
481                          ivec[0] = -ivec[0]; ivec[1] = -ivec[1]; /* normal */
482 +                        upv[0] = ivec[0]*ivec[1]*(ivec[2] - 1.);
483 +                        upv[1] = ivec[0]*ivec[0] + ivec[1]*ivec[1]*ivec[2];
484 +                        upv[2] = -ivec[1]*(ivec[0]*ivec[0] + ivec[1]*ivec[1]);
485                          sprintf(xfargs, "-s %f -t %f %f %f", bsdf_rad,
486                                          sorg[0], sorg[1], sorg[2]);
487                          nxfa = 6;
# Line 475 | Line 489 | put_BSDFs(void)
489                          printf("%d bsdf_red bsdf_grn bsdf_blu bsdf2rad.cal\n\t%s\n0\n0\n",
490                                          4+nxfa, xfargs);
491                          printf("\nscale_pat glow scale_mat\n0\n0\n4 1 1 1 0\n");
492 <                        SDcompXform(vMtx, ivec, Yaxis);
492 >                        if (SDcompXform(vMtx, ivec, upv) != SDEnone)
493 >                                continue;
494                          nxfa = addrot(xfargs, vMtx[0], vMtx[1], vMtx[2]);
495                          sprintf(xfargs+strlen(xfargs), " -s %f -t %f %f %f",
496                                          scalef, sorg[0], sorg[1], sorg[2]);
# Line 501 | Line 516 | put_matBSDF(const char *XMLfile)
516                  printf("\nvoid brightfunc latlong\n2 latlong bsdf2rad.cal\n0\n0\n");
517                  if ((front_comp|back_comp) & SDsampT)
518                          printf("\nlatlong trans %s\n0\n0\n7 .75 .75 .75 0 .04 .5 .8\n",
519 <                                        sph_mat);
519 >                                        sph_fmat);
520                  else
521                          printf("\nlatlong plastic %s\n0\n0\n5 .5 .5 .5 0 0\n",
522 <                                        sph_mat);
522 >                                        sph_fmat);
523 >                printf("\ninherit alias %s %s\n", sph_bmat, sph_fmat);
524                  return;
525          }
526          switch (XMLfile[0]) {           /* avoid RAYPATH search */
# Line 517 | Line 533 | put_matBSDF(const char *XMLfile)
533                  exit(1);
534                  break;
535          }
536 <        printf("\n# Actual BSDF material for rendering the hemispheres\n");
537 <        printf("\nvoid BSDF BSDFmat\n6 0 \"%s%s\" 0 1 0 .\n0\n0\n",
536 >        printf("\n# Actual BSDF materials for rendering the hemispheres\n");
537 >        printf("\nvoid BSDF BSDF_f\n6 0 \"%s%s\" upx upy upz bsdf2rad.cal\n0\n0\n",
538                          curdir, XMLfile);
539          printf("\nvoid plastic black\n0\n0\n5 0 0 0 0 0\n");
540 <        printf("\nvoid mixfunc %s\n4 BSDFmat black latlong bsdf2rad.cal\n0\n0\n",
541 <                        sph_mat);
540 >        printf("\nvoid mixfunc %s\n4 BSDF_f black latlong bsdf2rad.cal\n0\n0\n",
541 >                        sph_fmat);
542 >        printf("\nvoid BSDF BSDF_b\n8 0 \"%s%s\" upx upy upz bsdf2rad.cal -ry 180\n0\n0\n",
543 >                        curdir, XMLfile);
544 >        printf("\nvoid mixfunc %s\n4 BSDF_b black latlong bsdf2rad.cal\n0\n0\n",
545 >                        sph_bmat);
546   }
547  
548   /* Put out overhead parallel light source */
# Line 546 | Line 566 | put_hemispheres(void)
566          if (front_comp) {
567                  printf(
568   "\n!genrev %s Front \"R*sin(A*t)\" \"R*cos(A*t)\" %d -e \"R:%g;A:%f\" -s | xform -t %g 0 0\n",
569 <                                sph_mat, nsegs, sph_rad, 0.495*PI, sph_xoffset);
569 >                                sph_fmat, nsegs, sph_rad, 0.495*PI, sph_xoffset);
570                  printf("\nvoid brighttext front_text\n3 helvet.fnt . FRONT\n0\n");
571                  printf("12\n\t%f %f 0\n\t%f 0 0\n\t0 %f 0\n\t.01 1 -.1\n",
572                                  -.22*sph_rad + sph_xoffset, -1.4*sph_rad,
# Line 562 | Line 582 | put_hemispheres(void)
582          if (back_comp) {
583                  printf(
584   "\n!genrev %s Back \"R*cos(A*t)\" \"R*sin(A*t)\" %d -e \"R:%g;A:%f\" -s | xform -t %g 0 0\n",
585 <                                sph_mat, nsegs, sph_rad, 0.495*PI, -sph_xoffset);
585 >                                sph_bmat, nsegs, sph_rad, 0.495*PI, -sph_xoffset);
586                  printf("\nvoid brighttext back_text\n3 helvet.fnt . BACK\n0\n");
587                  printf("12\n\t%f %f 0\n\t%f 0 0\n\t0 %f 0\n\t.01 1 -.1\n",
588                                  -.22*sph_rad - sph_xoffset, -1.4*sph_rad,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines