| 1 |
rschregle |
2.12 |
/* RCSid $Id: pmapmat.h,v 4.18 2016/02/04 18:02:47 taschreg Exp taschreg $ */
|
| 2 |
greg |
2.1 |
/*
|
| 3 |
rschregle |
2.12 |
======================================================================
|
| 4 |
greg |
2.1 |
Photon map support routines for scattering by materials.
|
| 5 |
|
|
|
| 6 |
|
|
Roland Schregle (roland.schregle@{hslu.ch, gmail.com})
|
| 7 |
|
|
(c) Fraunhofer Institute for Solar Energy Systems,
|
| 8 |
rschregle |
2.2 |
(c) Lucerne University of Applied Sciences and Arts,
|
| 9 |
rschregle |
2.12 |
supported by the Swiss National Science Foundation (SNSF, #147053)
|
| 10 |
|
|
======================================================================
|
| 11 |
greg |
2.1 |
|
| 12 |
|
|
*/
|
| 13 |
|
|
|
| 14 |
|
|
|
| 15 |
|
|
#ifndef PMAPMAT_H
|
| 16 |
|
|
#define PMAPMAT_H
|
| 17 |
|
|
|
| 18 |
|
|
#include "pmap.h"
|
| 19 |
|
|
|
| 20 |
rschregle |
2.12 |
/*
|
| 21 |
|
|
Check for paths already accounted for in photon map to avoid
|
| 22 |
|
|
double-counting during backward raytracing.
|
| 23 |
|
|
|
| 24 |
|
|
ambRayInPmap(): Check for DIFFUSE -> (DIFFUSE|SPECULAR) -> *
|
| 25 |
|
|
subpaths. These occur during the backward pass
|
| 26 |
|
|
when an ambient ray spawns an indirect diffuse or
|
| 27 |
|
|
specular ray. These subpaths are already
|
| 28 |
|
|
accounted for in the global photon map.
|
| 29 |
greg |
2.10 |
*/
|
| 30 |
rschregle |
2.12 |
#define ambRayInPmap(r) ((r) -> crtype & AMBIENT && photonMapping && \
|
| 31 |
|
|
(ambounce < 0 || (r) -> rlvl > 1))
|
| 32 |
greg |
2.10 |
|
| 33 |
rschregle |
2.12 |
/*
|
| 34 |
greg |
2.1 |
shadowRayInPmap(): Check for DIFFUSE -> SPECULAR -> LIGHT
|
| 35 |
|
|
subpaths. These occur during the backward pass
|
| 36 |
|
|
when a shadow ray is transferred through a
|
| 37 |
|
|
transparent material. These subpaths are already
|
| 38 |
|
|
accounted for by caustic photons in the global,
|
| 39 |
|
|
contrib, or dedicated caustic photon map.
|
| 40 |
rschregle |
2.12 |
|
| 41 |
|
|
!!! DISABLED FOR TESTING PENDING REPLACEMENT BY srcRayInPmap() !!!
|
| 42 |
greg |
2.1 |
*/
|
| 43 |
rschregle |
2.12 |
#if 1
|
| 44 |
|
|
#define shadowRayInPmap(r) 0
|
| 45 |
|
|
#else
|
| 46 |
|
|
#define shadowRayInPmap(r) (((globalPmap && ambounce < 0) || \
|
| 47 |
|
|
causticPmap || contribPmap) && \
|
| 48 |
|
|
(r) -> crtype & SHADOW)
|
| 49 |
|
|
#endif
|
| 50 |
rschregle |
2.11 |
|
| 51 |
rschregle |
2.12 |
/* srcRayInPmap(): Check whether a source ray transferred through
|
| 52 |
|
|
* medium (e.g. glass/dielectric) is already
|
| 53 |
|
|
* accounted for in the photon map. This is used by
|
| 54 |
|
|
* badcomponent() in source.c when checking source
|
| 55 |
|
|
* hits (glows and lights, hence ambient and shadow
|
| 56 |
|
|
* rays).
|
| 57 |
|
|
*/
|
| 58 |
|
|
#define srcRayInPmap(r) (((globalPmap && ambounce < 0) || \
|
| 59 |
|
|
causticPmap || contribPmap) && \
|
| 60 |
|
|
(r) -> crtype & (AMBIENT | SHADOW) && \
|
| 61 |
|
|
(r) -> rtype & (TRANS | REFRACTED))
|
| 62 |
|
|
|
| 63 |
|
|
/* Check if scattered ray spawns a caustic photon;
|
| 64 |
|
|
* !!! NOTE this has to set bit 0 to properly handle caustic contrib
|
| 65 |
|
|
* !!! photons, so the explicit test against zero *IS* required! */
|
| 66 |
|
|
#define PMAP_CAUSTICRAY(r) (((r) -> rtype & SPECULAR) != 0)
|
| 67 |
greg |
2.1 |
|
| 68 |
|
|
|
| 69 |
|
|
/* Scattered photon ray types for photonRay() */
|
| 70 |
|
|
#define PMAP_DIFFREFL (REFLECTED | AMBIENT)
|
| 71 |
|
|
#define PMAP_DIFFTRANS (REFLECTED | AMBIENT | TRANS)
|
| 72 |
|
|
#define PMAP_SPECREFL (REFLECTED | SPECULAR)
|
| 73 |
|
|
#define PMAP_SPECTRANS (REFLECTED | SPECULAR | TRANS)
|
| 74 |
|
|
#define PMAP_REFRACT (REFRACTED | SPECULAR)
|
| 75 |
|
|
#define PMAP_XFER (TRANS)
|
| 76 |
|
|
|
| 77 |
|
|
|
| 78 |
|
|
|
| 79 |
|
|
/* Dispatch table for photon scattering functions */
|
| 80 |
|
|
extern int (*photonScatter []) (OBJREC*, RAY*);
|
| 81 |
|
|
|
| 82 |
|
|
/* List of antimatter sensor modifier names */
|
| 83 |
|
|
extern char *photonSensorList [MAXSET + 1];
|
| 84 |
|
|
|
| 85 |
|
|
|
| 86 |
|
|
|
| 87 |
|
|
/* Spawn a new photon ray from a previous one; this is effectively a
|
| 88 |
|
|
* customised rayorigin(). */
|
| 89 |
|
|
void photonRay (const RAY *rayIn, RAY *rayOut, int rayOutType,
|
| 90 |
|
|
COLOR fluxAtten);
|
| 91 |
|
|
|
| 92 |
|
|
/* Init photonScatter[] dispatch table with material specific scattering
|
| 93 |
|
|
routines */
|
| 94 |
|
|
void initPhotonScatterFuncs ();
|
| 95 |
|
|
|
| 96 |
|
|
/* Find antimatter geometry declared as photon sensors */
|
| 97 |
|
|
void getPhotonSensors (char **sensorList);
|
| 98 |
|
|
|
| 99 |
|
|
#endif
|