BRL-CAD
sh_plastic.c
Go to the documentation of this file.
1 /* S H _ P L A S T I C . C
2  * BRL-CAD
3  *
4  * Copyright (c) 1998-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 /** @file liboptical/sh_plastic.c
21  *
22  * Notes -
23  * The normals on all surfaces point OUT of the solid.
24  * The incoming light rays point IN. Thus the sign change.
25  *
26  */
27 
28 #include "common.h"
29 
30 #include <stddef.h>
31 #include <stdio.h>
32 #include <math.h>
33 
34 #include "vmath.h"
35 #include "mater.h"
36 #include "raytrace.h"
37 #include "optical.h"
38 #include "light.h"
39 #include "plastic.h"
40 #include "photonmap.h"
41 
42 #ifdef RT_MULTISPECTRAL
43 # include "spectrum.h"
44 #endif
45 
46 
47 /* Fast approximation to specular term */
48 #define PHAST_PHONG 1 /* See Graphics Gems IV pg 387 */
49 
50 /* from view.c */
51 extern double AmbientIntensity;
52 
53 
55  {"%d", 1, "shine", PL_O(shine), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
56  {"%d", 1, "sh", PL_O(shine), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
57  {"%g", 1, "specular", PL_O(wgt_specular), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
58  {"%g", 1, "sp", PL_O(wgt_specular), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
59  {"%g", 1, "diffuse", PL_O(wgt_diffuse), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
60  {"%g", 1, "di", PL_O(wgt_diffuse), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
61  {"%g", 1, "transmit", PL_O(transmit), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
62  {"%g", 1, "tr", PL_O(transmit), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
63  {"%g", 1, "reflect", PL_O(reflect), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
64  {"%g", 1, "re", PL_O(reflect), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
65  {"%g", 1, "ri", PL_O(refrac_index), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
66  {"%g", 1, "extinction_per_meter", PL_O(extinction), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
67  {"%g", 1, "extinction", PL_O(extinction), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
68  {"%g", 1, "ex", PL_O(extinction), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
69  {"%g", 3, "emission", PL_O(emission), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
70  {"%g", 3, "em", PL_O(emission), BU_STRUCTPARSE_FUNC_NULL, NULL, NULL },
71  {"", 0, (char *)0, 0, BU_STRUCTPARSE_FUNC_NULL, NULL, NULL }
72 };
73 
74 
75 HIDDEN int phong_setup(register struct region *rp, struct bu_vls *matparm, void **dpp, const struct mfuncs *mfp, struct rt_i *rtip);
76 HIDDEN int mirror_setup(register struct region *rp, struct bu_vls *matparm, void **dpp, const struct mfuncs *mfp, struct rt_i *rtip);
77 HIDDEN int glass_setup(register struct region *rp, struct bu_vls *matparm, void **dpp, const struct mfuncs *mfp, struct rt_i *rtip);
78 HIDDEN int phong_render(register struct application *ap, const struct partition *pp, struct shadework *swp, void *dp);
79 HIDDEN void phong_print(register struct region *rp, void *dp);
80 HIDDEN void phong_free(void *cp);
81 
82 /* This can't be const, so the forward link can be written later */
83 struct mfuncs phg_mfuncs[] = {
84  {MF_MAGIC, "default", 0, MFI_NORMAL, 0, phong_setup, phong_render, phong_print, phong_free },
85  {MF_MAGIC, "phong", 0, MFI_NORMAL, 0, phong_setup, phong_render, phong_print, phong_free },
86  {MF_MAGIC, "plastic", 0, MFI_NORMAL, 0, phong_setup, phong_render, phong_print, phong_free },
87  {MF_MAGIC, "mirror", 0, MFI_NORMAL, 0, mirror_setup, phong_render, phong_print, phong_free },
88  {MF_MAGIC, "glass", 0, MFI_NORMAL, 0, glass_setup, phong_render, phong_print, phong_free },
89  {0, (char *)0, 0, 0, 0, 0, 0, 0, 0 }
90 };
91 
92 
93 #ifndef PHAST_PHONG
94 extern double phg_ipow();
95 #endif
96 
97 #define RI_AIR 1.0 /* Refractive index of air. */
98 
99 HIDDEN int
100 phong_setup(register struct region *rp, struct bu_vls *matparm, void **dpp, const struct mfuncs *mfp, struct rt_i *UNUSED(rtip))
101 {
102  register struct phong_specific *pp;
103 
104  BU_CK_VLS(matparm);
105  BU_GET(pp, struct phong_specific);
106  *dpp = pp;
107 
108  pp->magic = PL_MAGIC;
109  pp->shine = 10;
110  pp->wgt_specular = 0.7;
111  pp->wgt_diffuse = 0.3;
112  pp->transmit = 0.0;
113  pp->reflect = 0.0;
114  pp->refrac_index = RI_AIR;
115  pp->extinction = 0.0;
116  pp->mfp = mfp;
117 
118  if (bu_struct_parse(matparm, phong_parse, (char *)pp, NULL) < 0) {
119  BU_PUT(pp, struct phong_specific);
120  return -1;
121  }
122 
123  if (pp->transmit > 0)
124  rp->reg_transmit = 1;
125  return 1;
126 }
127 
128 
129 HIDDEN int
130 mirror_setup(register struct region *rp, struct bu_vls *matparm, void **dpp, const struct mfuncs *mfp, struct rt_i *UNUSED(rtip))
131 {
132  register struct phong_specific *pp;
133 
134  BU_CK_VLS(matparm);
135  BU_GET(pp, struct phong_specific);
136  *dpp = pp;
137 
138  pp->magic = PL_MAGIC;
139  pp->shine = 4;
140  pp->wgt_specular = 0.6;
141  pp->wgt_diffuse = 0.4;
142  pp->transmit = 0.0;
143  pp->reflect = 0.75;
144  pp->refrac_index = 1.65;
145  pp->extinction = 0.0;
146  pp->mfp = mfp;
147 
148  if (bu_struct_parse(matparm, phong_parse, (char *)pp, NULL) < 0) {
149  BU_PUT(pp, struct phong_specific);
150  return -1;
151  }
152 
153  if (pp->transmit > 0)
154  rp->reg_transmit = 1;
155  return 1;
156 }
157 
158 
159 HIDDEN int
160 glass_setup(register struct region *rp, struct bu_vls *matparm, void **dpp, const struct mfuncs *mfp, struct rt_i *UNUSED(rtip))
161 {
162  register struct phong_specific *pp;
163 
164  BU_CK_VLS(matparm);
165  BU_GET(pp, struct phong_specific);
166  *dpp = pp;
167 
168  pp->magic = PL_MAGIC;
169  pp->shine = 4;
170  pp->wgt_specular = 0.7;
171  pp->wgt_diffuse = 0.3;
172  pp->transmit = 0.8;
173  pp->reflect = 0.1;
174  /* leaving 0.1 for diffuse/specular */
175  pp->refrac_index = 1.65;
176  pp->extinction = 0.0;
177  pp->mfp = mfp;
178 
179  if (bu_struct_parse(matparm, phong_parse, (char *)pp, NULL) < 0) {
180  BU_PUT(pp, struct phong_specific);
181  return -1;
182  }
183 
184  if (pp->transmit > 0)
185  rp->reg_transmit = 1;
186  return 1;
187 }
188 
189 
190 HIDDEN void
191 phong_print(register struct region *rp, void *dp)
192 {
193  bu_struct_print(rp->reg_name, phong_parse, (char *)dp);
194 }
195 
196 
197 HIDDEN void
198 phong_free(void *cp)
199 {
200  BU_PUT(cp, struct phong_specific);
201 }
202 
203 
204 /*
205  Color pixel based on the energy of a point light source (Eps)
206  plus some diffuse illumination (Epd) reflected from the point
207  <x, y> :
208 
209  E = Epd + Eps (1)
210 
211  The energy reflected from diffuse illumination is the product
212  of the reflectance coefficient at point P (Rp) and the diffuse
213  illumination (Id) :
214 
215  Epd = Rp * Id (2)
216 
217  The energy reflected from the point light source is calculated
218  by the sum of the diffuse reflectance (Rd) and the specular
219  reflectance (Rs), multiplied by the intensity of the light
220  source (Ips) :
221 
222  Eps = (Rd + Rs) * Ips (3)
223 
224  The diffuse reflectance is calculated by the product of the
225  reflectance coefficient (Rp) and the cosine of the angle of
226  incidence (I) :
227 
228  Rd = Rp * cos(I) (4)
229 
230  The specular reflectance is calculated by the product of the
231  specular reflectance coefficient and (the cosine of the angle (S)
232  raised to the nth power) :
233 
234  Rs = W(I) * cos(S)**n (5)
235 
236  Where,
237  I is the angle of incidence.
238  S is the angle between the reflected ray and the observer.
239  W returns the specular reflection coefficient as a function
240  of the angle of incidence.
241  n (roughly 1 to 10) represents the shininess of the surface.
242  *
243  This is the heart of the lighting model which is based on a model
244  developed by Bui-Tuong Phong, [see Wm M. Newman and R. F. Sproull,
245  "Principles of Interactive Computer Graphics", McGraw-Hill, 1979]
246 
247  Er = Ra(m)*cos(Ia) + Rd(m)*cos(I1) + W(I1, m)*cos(s)^^n
248  where,
249 
250  Er is the energy reflected in the observer's direction.
251  Ra is the diffuse reflectance coefficient at the point
252  of intersection due to ambient lighting.
253  Ia is the angle of incidence associated with the ambient
254  light source (angle between ray direction (negated) and
255  surface normal).
256  Rd is the diffuse reflectance coefficient at the point
257  of intersection due to primary lighting.
258  I1 is the angle of incidence associated with the primary
259  light source (angle between light source direction and
260  surface normal).
261  m is the material identification code.
262  W is the specular reflectance coefficient,
263  a function of the angle of incidence, range 0.0 to 1.0,
264  for the material.
265  s is the angle between the reflected ray and the observer.
266  ` n 'Shininess' of the material, range 1 to 10.
267 */
268 HIDDEN int
269 phong_render(register struct application *ap, const struct partition *pp, struct shadework *swp, void *dp)
270 {
271  struct light_specific *lp;
272 #ifndef RT_MULTISPECTRAL
273  fastf_t *intensity;
274  fastf_t dist;
275  point_t pt;
276  vect_t color;
277 #endif
278  fastf_t *to_light;
279  fastf_t cosine;
280  fastf_t refl;
281  int i;
282  vect_t reflected;
283  vect_t work;
284 
285 #ifdef RT_MULTISPECTRAL
286  struct bn_tabdata *ms_matcolor = BN_TABDATA_NULL;
287 #else
288  point_t matcolor; /* Material color */
289 #endif
290  struct phong_specific *ps =
291  (struct phong_specific *)dp;
292 
293  if (!ps || ps->magic != PL_MAGIC)
294  bu_bomb("phong_render: bad magic\n");
295 
296  if (pp == NULL)
297  bu_bomb("phong_render: bad partition\n");
298 
299  if (rdebug&RDEBUG_SHADE)
300  bu_struct_print("phong_render", phong_parse, (char *)ps);
301 
302  swp->sw_transmit = ps->transmit;
303  swp->sw_reflect = ps->reflect;
304  swp->sw_refrac_index = ps->refrac_index;
305  swp->sw_extinction = ps->extinction;
306 #if SW_SET_TRANSMIT
307  if (swp->sw_phong_set_vector & SW_SET_TRANSMIT) swp->sw_transmit = swp->sw_phong_transmit;
308  if (swp->sw_phong_set_vector & SW_SET_REFLECT) swp->sw_reflect = swp->sw_phong_reflect;
309  if (swp->sw_phong_set_vector & SW_SET_REFRAC_INDEX) swp->sw_refrac_index = swp->sw_phong_ri;
310  if (swp->sw_phong_set_vector & SW_SET_EXTINCTION) swp->sw_extinction = swp->sw_phong_extinction;
311 #endif /* SW_SET_TRANSMIT */
312  if (swp->sw_xmitonly) {
313  if (swp->sw_xmitonly > 1)
314  return 1; /* done -- wanted parameters only */
315  if (swp->sw_reflect > 0 || swp->sw_transmit > 0) {
316  if (rdebug&RDEBUG_SHADE)
317  bu_log("calling rr_render from phong, sw_xmitonly\n");
318  (void)rr_render(ap, pp, swp);
319  }
320  return 1; /* done */
321  }
322 
323 
324 #ifdef RT_MULTISPECTRAL
325  ms_matcolor = bn_tabdata_dup(swp->msw_color);
326 #else
327  VMOVE(matcolor, swp->sw_color);
328 #endif
329 
330  /* Photon Mapping */
331 #ifndef RT_MULTISPECTRAL
332  color[0]= swp->sw_color[0];
333  color[1]= swp->sw_color[1];
334  color[2]= swp->sw_color[2];
335 #endif
336 
337 #ifndef RT_MULTISPECTRAL
338  if (!PM_Visualize)
339 #endif
340  {
341  /* Diffuse reflectance from "Ambient" light source (at eye) */
342  if ((cosine = -VDOT(swp->sw_hit.hit_normal, ap->a_ray.r_dir)) > 0.0) {
343  if (cosine > 1.00001) {
344  bu_log("cosAmb=1+%g %s surfno=%d (x%d, y%d, lvl%d)\n",
345  cosine-1,
346  pp->pt_inseg->seg_stp->st_dp->d_namep,
347  swp->sw_hit.hit_surfno,
348  ap->a_x, ap->a_y, ap->a_level);
349  VPRINT(" normal", swp->sw_hit.hit_normal);
350  VPRINT(" r_dir ", ap->a_ray.r_dir);
351  cosine = 1;
352  }
353 #if SW_SET_TRANSMIT
354  if (swp->sw_phong_set_vector & SW_SET_AMBIENT) {
355  cosine *= swp->sw_phong_ambient;
356  } else {
357  cosine *= AmbientIntensity;
358  }
359 #else
360  cosine *= AmbientIntensity;
361 #endif
362 #ifdef RT_MULTISPECTRAL
363  bn_tabdata_scale(swp->msw_color, ms_matcolor, cosine);
364 #else
365  VSCALE(swp->sw_color, matcolor, cosine);
366 #endif
367  } else {
368 #ifdef RT_MULTISPECTRAL
369  bn_tabdata_constval(swp->msw_color, 0.0);
370 #else
371  VSETALL(swp->sw_color, 0);
372 #endif
373  }
374 
375  /* Emission. 0..1 is normal range, -1..0 sucks light out, like OpenGL */
376 #ifdef RT_MULTISPECTRAL
377  {
378  float emission[3];
379  struct bn_tabdata *ms_emission = BN_TABDATA_NULL;
380  VMOVE(emission, ps->emission);
381 #if SW_SET_TRANSMIT
382  if (swp->sw_phong_set_vector & SW_SET_EMISSION) {
383  VSETALL(emission, swp->sw_phong_emission);
384  }
385 #endif
386  /* XXX Really should get a curve at prep, not expand RGB samples */
387  BN_GET_TABDATA(ms_emission, spectrum);
388  rt_spect_reflectance_rgb(ms_emission, emission);
389  bn_tabdata_add(swp->msw_color, swp->msw_color, ms_emission);
390  bn_tabdata_free(ms_emission);
391  }
392 #else
393 #if SW_SET_TRANSMIT
394  if (swp->sw_phong_set_vector & SW_SET_EMISSION) {
395  vect_t tmp;
396  VSETALL(tmp, swp->sw_phong_emission);
397  VADD2(swp->sw_color, swp->sw_color, tmp);
398  } else {
399  VADD2(swp->sw_color, swp->sw_color, ps->emission);
400  }
401 #else
402  VADD2(swp->sw_color, swp->sw_color, ps->emission);
403 #endif /* SW_SET_TRANSMIT */
404 #endif
405 
406  /* With the advent of procedural shaders, the caller can no longer
407  * provide us reliable light visibility information. The hit point
408  * may have been changed by another shader in a stack. There is no
409  * way that anyone else can tell us whether lights are visible.
410  */
411  light_obs(ap, swp, ps->mfp->mf_inputs);
412 
413  /* Consider effects of each light source */
414  for (i=ap->a_rt_i->rti_nlights-1; i>=0; i--) {
415 
416  if ((lp = (struct light_specific *)swp->sw_visible[i]) == LIGHT_NULL)
417  continue;
418 
419  if (rdebug & RDEBUG_LIGHT) {
420  bu_log("phong_render light=%s lightfract=%g\n",
421  lp->lt_name, swp->sw_lightfract[i]);
422  }
423 
424  /* Light is not shadowed -- add this contribution */
425 #ifndef RT_MULTISPECTRAL
426  intensity = swp->sw_intensity+3*i;
427 #endif
428  to_light = swp->sw_tolight+3*i;
429 
430  /* Diffuse reflectance from this light source. */
431  if ((cosine=VDOT(swp->sw_hit.hit_normal, to_light)) > 0.0) {
432  if (cosine > 1.00001) {
433  bu_log("cosI=1+%g (x%d, y%d, lvl%d)\n", cosine-1,
434  ap->a_x, ap->a_y, ap->a_level);
435  cosine = 1;
436  }
437  /* Get Obj Hit Point For Attenuation */
438 #ifndef RT_MULTISPECTRAL
439  if (PM_Activated) {
440  VJOIN1(pt, ap->a_ray.r_pt, pp->pt_inhit->hit_dist, ap->a_ray.r_dir);
441  dist= sqrt((pt[0]-lp->lt_pos[0])*(pt[0]-lp->lt_pos[0]) + (pt[1]-lp->lt_pos[1])*(pt[1]-lp->lt_pos[1]) + (pt[2]-lp->lt_pos[2])*(pt[2]-lp->lt_pos[2]))/1000.0;
442  dist= (1.0/(0.1 + 1.0*dist + 0.01*dist*dist));
443  refl= dist * ps->wgt_diffuse * cosine * swp->sw_lightfract[i] * lp->lt_intensity;
444  /* bu_log("pt: [%.3f][%.3f, %.3f, %.3f]\n", dist, pt[0], pt[1], pt[2]);*/
445  } else
446 #endif
447  {
448  refl= ps->wgt_diffuse * swp->sw_lightfract[i] * cosine * lp->lt_fraction;
449  }
450 
451 #ifdef RT_MULTISPECTRAL
452  bn_tabdata_incr_mul3_scale(swp->msw_color,
453  lp->lt_spectrum,
454  swp->msw_intensity[i],
455  ms_matcolor,
456  refl);
457 #else
458  VELMUL3(work, matcolor, lp->lt_color, intensity);
459  VJOIN1(swp->sw_color, swp->sw_color, refl, work);
460 #endif
461  }
462 
463  /* Calculate specular reflectance.
464  * Reflected ray = (2 * cos(i) * Normal) - Incident ray.
465  * Cos(s) = Reflected ray DOT Incident ray.
466  */
467  cosine *= 2;
468  VSCALE(work, swp->sw_hit.hit_normal, cosine);
469  VSUB2(reflected, work, to_light);
470  if ((cosine = -VDOT(reflected, ap->a_ray.r_dir)) > 0) {
471  if (cosine > 1.00001) {
472  bu_log("cosS=1+%g (x%d, y%d, lvl%d)\n", cosine-1,
473  ap->a_x, ap->a_y, ap->a_level);
474  cosine = 1;
475  }
476  refl = ps->wgt_specular * swp->sw_lightfract[i] *
477  lp->lt_fraction *
478 #ifdef PHAST_PHONG
479  /* It is unnecessary to compute the actual
480  * exponential here since phong is just a
481  * gross hack. We approximate re:
482  * Graphics Gems IV "A Fast Alternative to
483  * Phong's Specular Model" Pg 385
484  */
485  cosine /
486  (ps->shine - ps->shine*cosine + cosine);
487 #else
488  phg_ipow(cosine, ps->shine);
489 #endif /* PHAST_PHONG */
490 #ifdef RT_MULTISPECTRAL
491  bn_tabdata_incr_mul2_scale(swp->msw_color,
492  lp->lt_spectrum,
493  swp->msw_intensity[i],
494  refl);
495 #else
496  VELMUL(work, lp->lt_color, intensity);
497  VJOIN1(swp->sw_color, swp->sw_color, refl, work);
498 #endif
499  }
500  }
501 
502 #ifndef RT_MULTISPECTRAL
503  if (PM_Activated) {
504  IrradianceEstimate(ap, work, swp->sw_hit.hit_point, swp->sw_hit.hit_normal);
505  VELMUL(work, work, color);
506  VADD2(swp->sw_color, work, swp->sw_color);
507  if (swp->sw_color[0] > 1.0) swp->sw_color[0]= 1.0;
508  if (swp->sw_color[1] > 1.0) swp->sw_color[1]= 1.0;
509  if (swp->sw_color[2] > 1.0) swp->sw_color[2]= 1.0;
510  }
511 
512  } else {
513 
514  if (PM_Activated) {
515  /* IrradianceEstimate(work, swp->sw_hit.hit_point, swp->sw_hit.hit_normal);
516  VELMUL(swp->sw_color, work, color);*/
517  IrradianceEstimate(ap, swp->sw_color, swp->sw_hit.hit_point, swp->sw_hit.hit_normal);
518  if (swp->sw_color[0] > 1.0) swp->sw_color[0]= 1.0;
519  if (swp->sw_color[1] > 1.0) swp->sw_color[1]= 1.0;
520  if (swp->sw_color[2] > 1.0) swp->sw_color[2]= 1.0;
521  }
522 #endif
523  }
524 
525 
526  if (swp->sw_reflect > 0 || swp->sw_transmit > 0)
527  (void)rr_render(ap, pp, swp);
528 
529 #ifdef RT_MULTISPECTRAL
530  bn_tabdata_free(ms_matcolor);
531 #endif
532  return 1;
533 }
534 
535 
536 #ifndef PHAST_PHONG
537 /*
538  * Raise a floating point number to an integer power
539  */
540 double
541 phg_ipow(d, cnt)
542  double d;
543  register int cnt;
544 {
545  fastf_t input, result;
546 
547  if ((input=d) < 1e-8) return 0.0;
548  if (cnt < 0 || cnt > 200) {
549  bu_log("phg_ipow(%g, %d) bad\n", d, cnt);
550  return d;
551  }
552  result = 1;
553  while (cnt-- > 0)
554  result *= input;
555  return result;
556 }
557 #endif
558 
559 /*
560  * Local Variables:
561  * mode: C
562  * tab-width: 8
563  * indent-tabs-mode: t
564  * c-file-style: "stroustrup"
565  * End:
566  * ex: shiftwidth=4 tabstop=8
567  */
char * d_namep
pointer to name string
Definition: raytrace.h:859
#define BN_TABDATA_NULL
Definition: tabdata.h:107
struct xray a_ray
Actual ray to be shot.
Definition: raytrace.h:1583
#define RDEBUG_LIGHT
Definition: optical.h:132
void bu_log(const char *,...) _BU_ATTR_PRINTF12
Definition: log.c:176
HIDDEN void phong_free(void *cp)
Definition: sh_plastic.c:198
void bn_tabdata_incr_mul2_scale(struct bn_tabdata *out, const struct bn_tabdata *in1, const struct bn_tabdata *in2, double scale)
HIDDEN int phong_setup(register struct region *rp, struct bu_vls *matparm, void **dpp, const struct mfuncs *mfp, struct rt_i *rtip)
Definition: sh_plastic.c:100
const struct directory * st_dp
Directory entry of solid.
Definition: raytrace.h:436
#define MF_MAGIC
Definition: magic.h:205
#define BN_GET_TABDATA(_data, _table)
Definition: tabdata.h:114
void bn_tabdata_free(struct bn_tabdata *data)
Definition: tabdata.c:67
struct soltab * seg_stp
pointer back to soltab
Definition: raytrace.h:372
#define VSETALL(a, s)
Definition: color.c:54
struct bu_structparse phong_parse[]
Definition: sh_plastic.c:54
Header file for the BRL-CAD common definitions.
const char * reg_name
Identifying string.
Definition: raytrace.h:539
struct mfuncs phg_mfuncs[]
Definition: sh_plastic.c:83
struct hit * pt_inhit
IN hit pointer.
Definition: raytrace.h:577
#define HIDDEN
Definition: common.h:86
void light_obs(struct application *ap, struct shadework *swp, int have)
Definition: sh_light.c:1621
void bu_struct_print(const char *title, const struct bu_structparse *parsetab, const char *base)
Definition: parse.c:1221
#define RI_AIR
Definition: sh_plastic.c:97
HIDDEN int glass_setup(register struct region *rp, struct bu_vls *matparm, void **dpp, const struct mfuncs *mfp, struct rt_i *rtip)
Definition: sh_plastic.c:160
HIDDEN void phong_print(register struct region *rp, void *dp)
Definition: sh_plastic.c:191
HIDDEN int phong_render(register struct application *ap, const struct partition *pp, struct shadework *swp, void *dp)
Definition: sh_plastic.c:269
struct rt_i * a_rt_i
this librt instance
Definition: raytrace.h:1588
#define BU_CK_VLS(_vp)
Definition: vls.h:69
int PM_Activated
Definition: photonmap.c:43
void bn_tabdata_scale(struct bn_tabdata *out, const struct bn_tabdata *in1, double scale)
int rti_nlights
number of light sources
Definition: raytrace.h:1760
int a_x
Screen X of ray, if applicable.
Definition: raytrace.h:1596
#define BU_GET(_ptr, _type)
Definition: malloc.h:201
struct seg * pt_inseg
IN seg ptr (gives stp)
Definition: raytrace.h:576
HIDDEN int to_light(struct ged *gedp, int argc, const char *argv[], ged_func_ptr func, const char *usage, int maxargs)
Definition: tclcad_obj.c:6431
#define PL_O(_m)
Definition: vrml_write.c:76
int reg_transmit
flag: material transmits light
Definition: raytrace.h:549
int a_level
recursion level (for printing)
Definition: raytrace.h:1595
#define UNUSED(parameter)
Definition: common.h:239
void bn_tabdata_add(struct bn_tabdata *out, const struct bn_tabdata *in1, const struct bn_tabdata *in2)
Definition: tabdata.c:123
#define BU_PUT(_ptr, _type)
Definition: malloc.h:215
void rt_spect_reflectance_rgb(struct bn_tabdata *curve, const float *rgb)
Definition: spectrum.c:191
HIDDEN int mirror_setup(register struct region *rp, struct bu_vls *matparm, void **dpp, const struct mfuncs *mfp, struct rt_i *rtip)
Definition: sh_plastic.c:130
void bn_tabdata_constval(struct bn_tabdata *data, double val)
Definition: tabdata.c:1072
#define BU_STRUCTPARSE_FUNC_NULL
Definition: parse.h:153
vect_t r_dir
Direction of ray (UNIT Length)
Definition: raytrace.h:219
void bn_tabdata_incr_mul3_scale(struct bn_tabdata *out, const struct bn_tabdata *in1, const struct bn_tabdata *in2, const struct bn_tabdata *in3, double scale)
point_t r_pt
Point at which ray starts.
Definition: raytrace.h:218
#define RDEBUG_SHADE
Definition: optical.h:130
int bu_struct_parse(const struct bu_vls *in_vls, const struct bu_structparse *desc, const char *base, void *data)
Definition: parse.c:878
int a_y
Screen Y of ray, if applicable.
Definition: raytrace.h:1597
struct bn_tabdata * bn_tabdata_dup(const struct bn_tabdata *in)
Definition: tabdata.c:1041
#define PL_MAGIC
Definition: magic.h:207
bn_poly_t input[3]
Definition: bn_poly_add.c:36
struct bn_table * spectrum
Definition: init.c:41
int rr_render(struct application *app, const struct partition *pp, struct shadework *swp)
int PM_Visualize
Definition: photonmap.c:44
fastf_t hit_dist
dist from r_pt to hit_point
Definition: raytrace.h:250
Definition: vls.h:56
void bu_bomb(const char *str) _BU_ATTR_NORETURN
Definition: bomb.c:91
double fastf_t
Definition: defines.h:300
#define VPRINT(a, b)
Definition: raytrace.h:1881
Header file for the BRL-CAD Optical Library, LIBOPTICAL.
int rdebug
Definition: init.c:39
double AmbientIntensity
Definition: init.c:40
void IrradianceEstimate(struct application *ap, vect_t irrad, point_t pos, vect_t normal)
Definition: photonmap.c:1577