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.20 by greg, Mon Apr 10 06:09:14 2017 UTC vs.
Revision 2.23 by greg, Tue Apr 11 03:47:23 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";
# Line 373 | Line 371 | static int
371   put_BSDFs(void)
372   {
373          const double    scalef = bsdf_rad/(log10(overall_max) - min_log10);
374 <        FVECT           ivec, sorg;
374 >        FVECT           ivec, sorg, upv;
375          RREAL           vMtx[3][3];
376          char            *fname;
377          char            cmdbuf[256];
# Line 385 | Line 383 | put_BSDFs(void)
383                          NINCIDENT);
384  
385          printf("\nvoid glow arrow_glow\n0\n0\n4 1 0 1 0\n");
386 <        printf("\nvoid mixfunc arrow_mat\n4 arrow_glow void 0.5 .\n0\n0\n");
386 >        printf("\nvoid mixfunc arrow_mat\n4 arrow_glow void 0.25 .\n0\n0\n");
387  
388          if (front_comp & SDsampR)                       /* front reflection */
389                  for (i = 0; i < NINCIDENT; i++) {
# Line 393 | Line 391 | put_BSDFs(void)
391                          put_mirror_arrow(ivec, 1);
392                          cvt_sposition(sorg, ivec, 1);
393                          ivec[0] = -ivec[0]; ivec[1] = -ivec[1]; /* normal */
394 +                        upv[0] = ivec[0]*ivec[1]*(ivec[2] - 1.);
395 +                        upv[1] = ivec[0]*ivec[0] + ivec[1]*ivec[1]*ivec[2];
396 +                        upv[2] = -ivec[1]*(ivec[0]*ivec[0] + ivec[1]*ivec[1]);
397                          sprintf(xfargs, "-s %f -t %f %f %f", bsdf_rad,
398                                          sorg[0], sorg[1], sorg[2]);
399                          nxfa = 6;
# Line 400 | Line 401 | put_BSDFs(void)
401                          printf("%d bsdf_red bsdf_grn bsdf_blu bsdf2rad.cal\n\t%s\n0\n0\n",
402                                          4+nxfa, xfargs);
403                          printf("\nscale_pat glow scale_mat\n0\n0\n4 1 1 1 0\n");
404 <                        SDcompXform(vMtx, ivec, Yaxis);
404 >                        if (SDcompXform(vMtx, ivec, upv) != SDEnone)
405 >                                continue;
406                          nxfa = addrot(xfargs, vMtx[0], vMtx[1], vMtx[2]);
407                          sprintf(xfargs+strlen(xfargs), " -s %f -t %f %f %f",
408                                          scalef, sorg[0], sorg[1], sorg[2]);
# Line 418 | Line 420 | put_BSDFs(void)
420                          put_trans_arrow(ivec, 1);
421                          cvt_sposition(sorg, ivec, 1);
422                          ivec[0] = -ivec[0]; ivec[1] = -ivec[1]; /* normal */
423 +                        upv[0] = ivec[0]*ivec[1]*(ivec[2] - 1.);
424 +                        upv[1] = ivec[0]*ivec[0] + ivec[1]*ivec[1]*ivec[2];
425 +                        upv[2] = -ivec[1]*(ivec[0]*ivec[0] + ivec[1]*ivec[1]);
426                          sprintf(xfargs, "-s %f -t %f %f %f", bsdf_rad,
427                                          sorg[0], sorg[1], sorg[2]);
428                          nxfa = 6;
# Line 425 | Line 430 | put_BSDFs(void)
430                          printf("%d bsdf_red bsdf_grn bsdf_blu bsdf2rad.cal\n\t%s\n0\n0\n",
431                                          4+nxfa, xfargs);
432                          printf("\nscale_pat glow scale_mat\n0\n0\n4 1 1 1 0\n");
433 <                        SDcompXform(vMtx, ivec, Yaxis);
433 >                        if (SDcompXform(vMtx, ivec, upv) != SDEnone)
434 >                                continue;
435                          nxfa = addrot(xfargs, vMtx[0], vMtx[1], vMtx[2]);
436                          sprintf(xfargs+strlen(xfargs), " -s %f -t %f %f %f",
437                                          scalef, sorg[0], sorg[1], sorg[2]);
# Line 443 | Line 449 | put_BSDFs(void)
449                          put_mirror_arrow(ivec, -1);
450                          cvt_sposition(sorg, ivec, -1);
451                          ivec[0] = -ivec[0]; ivec[1] = -ivec[1]; /* normal */
452 +                        upv[0] = ivec[0]*ivec[1]*(ivec[2] - 1.);
453 +                        upv[1] = ivec[0]*ivec[0] + ivec[1]*ivec[1]*ivec[2];
454 +                        upv[2] = -ivec[1]*(ivec[0]*ivec[0] + ivec[1]*ivec[1]);
455                          sprintf(xfargs, "-s %f -t %f %f %f", bsdf_rad,
456                                          sorg[0], sorg[1], sorg[2]);
457                          nxfa = 6;
# Line 450 | Line 459 | put_BSDFs(void)
459                          printf("%d bsdf_red bsdf_grn bsdf_blu bsdf2rad.cal\n\t%s\n0\n0\n",
460                                          4+nxfa, xfargs);
461                          printf("\nscale_pat glow scale_mat\n0\n0\n4 1 1 1 0\n");
462 <                        SDcompXform(vMtx, ivec, Yaxis);
462 >                        if (SDcompXform(vMtx, ivec, upv) != SDEnone)
463 >                                continue;
464                          nxfa = addrot(xfargs, vMtx[0], vMtx[1], vMtx[2]);
465                          sprintf(xfargs+strlen(xfargs), " -s %f -t %f %f %f",
466                                          scalef, sorg[0], sorg[1], sorg[2]);
# Line 468 | Line 478 | put_BSDFs(void)
478                          put_trans_arrow(ivec, -1);
479                          cvt_sposition(sorg, ivec, -1);
480                          ivec[0] = -ivec[0]; ivec[1] = -ivec[1]; /* normal */
481 +                        upv[0] = ivec[0]*ivec[1]*(ivec[2] - 1.);
482 +                        upv[1] = ivec[0]*ivec[0] + ivec[1]*ivec[1]*ivec[2];
483 +                        upv[2] = -ivec[1]*(ivec[0]*ivec[0] + ivec[1]*ivec[1]);
484                          sprintf(xfargs, "-s %f -t %f %f %f", bsdf_rad,
485                                          sorg[0], sorg[1], sorg[2]);
486                          nxfa = 6;
# Line 475 | Line 488 | put_BSDFs(void)
488                          printf("%d bsdf_red bsdf_grn bsdf_blu bsdf2rad.cal\n\t%s\n0\n0\n",
489                                          4+nxfa, xfargs);
490                          printf("\nscale_pat glow scale_mat\n0\n0\n4 1 1 1 0\n");
491 <                        SDcompXform(vMtx, ivec, Yaxis);
491 >                        if (SDcompXform(vMtx, ivec, upv) != SDEnone)
492 >                                continue;
493                          nxfa = addrot(xfargs, vMtx[0], vMtx[1], vMtx[2]);
494                          sprintf(xfargs+strlen(xfargs), " -s %f -t %f %f %f",
495                                          scalef, sorg[0], sorg[1], sorg[2]);
# Line 518 | Line 532 | put_matBSDF(const char *XMLfile)
532                  break;
533          }
534          printf("\n# Actual BSDF material for rendering the hemispheres\n");
535 <        printf("\nvoid BSDF BSDFmat\n6 0 \"%s%s\" 0 1 0 .\n0\n0\n",
535 >        printf("\nvoid BSDF BSDFmat\n6 0 \"%s%s\" upx upy upz bsdf2rad.cal\n0\n0\n",
536                          curdir, XMLfile);
537          printf("\nvoid plastic black\n0\n0\n5 0 0 0 0 0\n");
538          printf("\nvoid mixfunc %s\n4 BSDFmat black latlong bsdf2rad.cal\n0\n0\n",
# Line 540 | Line 554 | put_source(void)
554   static void
555   put_hemispheres(void)
556   {
557 +        const int       nsegs = 131;
558 +
559          printf("\n# Hemisphere(s) for showing BSDF appearance (if XML file)\n");
544        printf("\nvoid antimatter anti_sph\n2 void %s\n0\n0\n", sph_mat);
560          if (front_comp) {
561 <                printf("\n%s sphere Front\n0\n0\n4 %f 0 0 %f\n",
562 <                                sph_mat, sph_xoffset, sph_rad);
563 <                printf("\n!genbox anti_sph sph_eraser %f %f %f | xform -t %f %f %f\n",
549 <                                2.02*sph_rad, 2.02*sph_rad, 1.02*sph_rad,
550 <                                -1.01*sph_rad + sph_xoffset, -1.01*sph_rad, -1.01*sph_rad);
561 >                printf(
562 > "\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",
563 >                                sph_mat, nsegs, sph_rad, 0.495*PI, sph_xoffset);
564                  printf("\nvoid brighttext front_text\n3 helvet.fnt . FRONT\n0\n");
565                  printf("12\n\t%f %f 0\n\t%f 0 0\n\t0 %f 0\n\t.01 1 -.1\n",
566                                  -.22*sph_rad + sph_xoffset, -1.4*sph_rad,
# Line 561 | Line 574 | put_hemispheres(void)
574                                  .25*sph_rad + sph_xoffset, -1.3*sph_rad );
575          }
576          if (back_comp) {
577 <                printf("\n%s bubble Back\n0\n0\n4 %f 0 0 %f\n",
578 <                                sph_mat, -sph_xoffset, sph_rad);
579 <                printf("\n!genbox anti_sph sph_eraser %f %f %f | xform -t %f %f %f\n",
567 <                                2.02*sph_rad, 2.02*sph_rad, 1.02*sph_rad,
568 <                                -1.01*sph_rad - sph_xoffset, -1.01*sph_rad, -1.01*sph_rad);
577 >                printf(
578 > "\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",
579 >                                sph_mat, nsegs, sph_rad, 0.495*PI, -sph_xoffset);
580                  printf("\nvoid brighttext back_text\n3 helvet.fnt . BACK\n0\n");
581                  printf("12\n\t%f %f 0\n\t%f 0 0\n\t0 %f 0\n\t.01 1 -.1\n",
582                                  -.22*sph_rad - sph_xoffset, -1.4*sph_rad,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines