1 #pragma once
2 /****************************************************************************
3  *		mcintegrator.h: A basic abstract integrator for MC sampling
4  *		This is part of the yafray package
5  *		Copyright (C) 2010  Rodrigo Placencia (DarkTide)
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
9  *		License as published by the Free Software Foundation; either
10  *		version 2.1 of the License, or (at your option) any later version.
11  *
12  *		This library is distributed in the hope that it will be useful,
13  *		but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  *		Lesser General Public License for more details.
16  *
17  *		You should have received a copy of the GNU Lesser General Public
18  *		License along with this library; if not, write to the Free Software
19  *		Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */
21 
22 #ifndef Y_MCINTEGRATOR_H
23 #define Y_MCINTEGRATOR_H
24 
25 #include "tiledintegrator.h"
26 
27 __BEGIN_YAFRAY
28 
29 class background_t;
30 class photon_t;
31 
32 enum photonMapProcessing_t
33 {
34 	PHOTONS_GENERATE_ONLY,
35 	PHOTONS_GENERATE_AND_SAVE,
36 	PHOTONS_LOAD,
37 	PHOTONS_REUSE
38 };
39 
40 class YAFRAYCORE_EXPORT mcIntegrator_t: public tiledIntegrator_t
41 {
42 	public:
mcIntegrator_t()43 		mcIntegrator_t() {};
44 
45 	protected:
46 		/*! Estimates direct light from all sources in a mc fashion and completing MIS (Multiple Importance Sampling) for a given surface point */
47 		virtual color_t estimateAllDirectLight(renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo, colorPasses_t &colorPasses) const;
48 		/*! Like previous but for only one random light source for a given surface point */
49 		virtual color_t estimateOneDirectLight(renderState_t &state, const surfacePoint_t &sp, vector3d_t wo, int n, colorPasses_t &colorPasses) const;
50 		/*! Does the actual light estimation on a specific light for the given surface point */
51 		virtual color_t doLightEstimation(renderState_t &state, light_t *light, const surfacePoint_t &sp, const vector3d_t &wo, const unsigned int &loffs, colorPasses_t &colorPasses) const;
52 		/*! Does recursive mc raytracing with MIS (Multiple Importance Sampling) for a given surface point */
53 		virtual void recursiveRaytrace(renderState_t &state, diffRay_t &ray, BSDF_t bsdfs, surfacePoint_t &sp, vector3d_t &wo, color_t &col, float &alpha, colorPasses_t &colorPasses, int additionalDepth) const;
54 		/*! Creates and prepares the caustic photon map */
55 		virtual bool createCausticMap();
56 		/*! Estimates caustic photons for a given surface point */
57 		virtual color_t estimateCausticPhotons(renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo) const;
58 		/*! Samples ambient occlusion for a given surface point */
59 		virtual color_t sampleAmbientOcclusion(renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo) const;
60 		virtual color_t sampleAmbientOcclusionPass(renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo) const;
61 		virtual color_t sampleAmbientOcclusionPassClay(renderState_t &state, const surfacePoint_t &sp, const vector3d_t &wo) const;
62 		virtual void causticWorker(photonMap_t * causticMap, int threadID, const scene_t *scene, unsigned int nCausPhotons, pdf1D_t *lightPowerD, int numLights, const std::string &integratorName, const std::vector<light_t *> &causLights, int causDepth, progressBar_t *pb, int pbStep, unsigned int &totalPhotonsShot);
63 
64 		int rDepth; //! Ray depth
65 		bool trShad; //! Use transparent shadows
66 		int sDepth; //! Shadow depth for transparent shadows
67 
68 		bool usePhotonCaustics; //! Use photon caustics
69 		unsigned int nCausPhotons; //! Number of caustic photons (to be shoot but it should be the target
70 		int nCausSearch; //! Amount of caustic photons to be gathered in estimation
71 		float causRadius; //! Caustic search radius for estimation
72 		int causDepth; //! Caustic photons max path depth
73 		pdf1D_t *lightPowerD;
74 
75 		bool useAmbientOcclusion; //! Use ambient occlusion
76 		int aoSamples; //! Ambient occlusion samples
77 		float aoDist; //! Ambient occlusion distance
78 		color_t aoCol; //! Ambient occlusion color
79 
80 		photonMapProcessing_t photonMapProcessing = PHOTONS_GENERATE_ONLY;
81 
82 		background_t *background; //! Background shader
83 		int nPaths; //! Number of samples for mc raytracing
84 		int maxBounces; //! Max. path depth for mc raytracing
85 		std::vector<light_t*> lights; //! An array containing all the scene lights
86 		bool transpBackground; //! Render background as transparent
87 		bool transpRefractedBackground; //! Render refractions of background as transparent
88 };
89 
90 __END_YAFRAY
91 
92 #endif
93