| 1 |
/* RCSid $Id: pmapmat.h,v 2.13 2019/02/04 18:20:27 rschregle Exp $ */ |
| 2 |
/* |
| 3 |
====================================================================== |
| 4 |
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 |
supported by the German Research Foundation |
| 9 |
(DFG LU-204/10-2, "Fassadenintegrierte Regelsysteme FARESYS") |
| 10 |
(c) Lucerne University of Applied Sciences and Arts, |
| 11 |
supported by the Swiss National Science Foundation |
| 12 |
(SNSF #147053, "Daylight Redirecting Components") |
| 13 |
====================================================================== |
| 14 |
|
| 15 |
*/ |
| 16 |
|
| 17 |
|
| 18 |
#ifndef PMAPMAT_H |
| 19 |
#define PMAPMAT_H |
| 20 |
|
| 21 |
#include "pmap.h" |
| 22 |
|
| 23 |
/* |
| 24 |
Check for paths already accounted for in photon map to avoid |
| 25 |
double-counting during backward raytracing. |
| 26 |
|
| 27 |
ambRayInPmap(): Check for DIFFUSE -> (DIFFUSE|SPECULAR) -> * |
| 28 |
subpaths. These occur during the backward pass |
| 29 |
when an ambient ray spawns an indirect diffuse or |
| 30 |
specular ray. These subpaths are already |
| 31 |
accounted for in the global photon map. |
| 32 |
*/ |
| 33 |
#define ambRayInPmap(r) ((r) -> crtype & AMBIENT && photonMapping && \ |
| 34 |
(ambounce < 0 || (r) -> rlvl > 1)) |
| 35 |
|
| 36 |
/* |
| 37 |
shadowRayInPmap(): Check for DIFFUSE -> SPECULAR -> LIGHT |
| 38 |
subpaths. These occur during the backward pass |
| 39 |
when a shadow ray is transferred through a |
| 40 |
transparent material. These subpaths are already |
| 41 |
accounted for by caustic photons in the global, |
| 42 |
contrib, or dedicated caustic photon map. |
| 43 |
|
| 44 |
!!! DISABLED FOR TESTING PENDING REPLACEMENT BY srcRayInPmap() !!! |
| 45 |
*/ |
| 46 |
#if 1 |
| 47 |
#define shadowRayInPmap(r) 0 |
| 48 |
#else |
| 49 |
#define shadowRayInPmap(r) (((globalPmap && ambounce < 0) || \ |
| 50 |
causticPmap || contribPmap) && \ |
| 51 |
(r) -> crtype & SHADOW) |
| 52 |
#endif |
| 53 |
|
| 54 |
/* srcRayInPmap(): Check whether a source ray transferred through |
| 55 |
* medium (e.g. glass/dielectric) is already |
| 56 |
* accounted for in the photon map. This is used by |
| 57 |
* badcomponent() in source.c when checking source |
| 58 |
* hits (glows and lights, hence ambient and shadow |
| 59 |
* rays). |
| 60 |
*/ |
| 61 |
#define srcRayInPmap(r) (((globalPmap && ambounce < 0) || \ |
| 62 |
causticPmap || contribPmap) && \ |
| 63 |
(r) -> crtype & (AMBIENT | SHADOW) && \ |
| 64 |
(r) -> rtype & (TRANS | REFRACTED)) |
| 65 |
|
| 66 |
/* Check if scattered ray spawns a caustic photon; |
| 67 |
* !!! NOTE this returns a single bit as boolean value (0|1), rather |
| 68 |
* !!! than the original short int, hence the explicit test against zero. |
| 69 |
* !!! This allows the macro the be used in a conditional statement |
| 70 |
* !!! and when setting a photon's caustic flag in newPhoton(). */ |
| 71 |
#define PMAP_CAUSTICRAY(r) (((r) -> rtype & SPECULAR) != 0) |
| 72 |
|
| 73 |
|
| 74 |
/* Scattered photon ray types for photonRay() */ |
| 75 |
#define PMAP_DIFFREFL (REFLECTED | AMBIENT) |
| 76 |
#define PMAP_DIFFTRANS (REFLECTED | AMBIENT | TRANS) |
| 77 |
#define PMAP_SPECREFL (REFLECTED | SPECULAR) |
| 78 |
#define PMAP_SPECTRANS (REFLECTED | SPECULAR | TRANS) |
| 79 |
#define PMAP_REFRACT (REFRACTED | SPECULAR) |
| 80 |
#define PMAP_XFER (TRANS) |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
/* Dispatch table for photon scattering functions */ |
| 85 |
extern int (*photonScatter []) (OBJREC*, RAY*); |
| 86 |
|
| 87 |
/* List of antimatter sensor modifier names */ |
| 88 |
extern char *photonSensorList [MAXSET + 1]; |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
/* Spawn a new photon ray from a previous one; this is effectively a |
| 93 |
* customised rayorigin(). */ |
| 94 |
void photonRay (const RAY *rayIn, RAY *rayOut, int rayOutType, |
| 95 |
COLOR fluxAtten); |
| 96 |
|
| 97 |
/* Init photonScatter[] dispatch table with material specific scattering |
| 98 |
routines */ |
| 99 |
void initPhotonScatterFuncs (); |
| 100 |
|
| 101 |
/* Find antimatter geometry declared as photon sensors */ |
| 102 |
void getPhotonSensors (char **sensorList); |
| 103 |
|
| 104 |
#endif |