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