#include <photonmap.h>
Public Member Functions | |
| PhotonMap () | |
| ~PhotonMap () | |
| int | GetSizeInMemory () const |
| Returns the size (in bytes) of the photon map in memory. | |
| void | StorePhoton (const sheep::Point3 &position, const Color3 &power, const sheep::Vector3 &direction, const sheep::Vector3 &normal) |
| void | ScalePhotonPower (sheep::Real scale) |
| void | Balance () |
| Color3 | ComputeRadiance (const Context &context, const sheep::Point3 &point, const sheep::Vector3 &normal, const sheep::Vector3 &outgoing, const ShadingData &shadingdata, sheep::Real max_dist, int max_photons) const |
| Color3 | ApproximateRadiance (const sheep::Point3 &point, const sheep::Vector3 &normal, const ShadingData &shadingdata, sheep::Real max_dist, int max_photons) const |
| void | PrecomputeRadiances (int spacing, sheep::Real max_dist, int max_photons, sheep::ProgressMonitor *progmon=0) |
| Color3 | GetPrecomputedRadiance (const sheep::Point3 &point, const sheep::Vector3 &normal, const ShadingData &shadingdata, sheep::Real max_dist) const |
| void | BuildPhotonDirectionHistogram (const sheep::Point3 &position, const SurfaceBasis &surfacebasis, sheep::Real max_dist, int max_photons, sheep::Real *histogram, int m, int n, sheep::Real *total_power) const |
| bool | WriteToFile (const std::string &filename, sheep::ProgressMonitor *progmon=0) const |
| Writes the photon map to disk. Returns true if writing was successful. | |
| int | GetPhotonCount () const |
| const Photon & | GetPhoton (int i) const |
Static Public Member Functions | |
| PhotonMap * | CreateFromFile (const std::string &filename, sheep::ProgressMonitor *progmon=0) |
Private Types | |
| enum | { BUF_SIZE = 10000 } |
| Some buffers used by the IrradianceEstimate() method. More... | |
Private Member Functions | |
| void | median_split (Photon **p, int start, int end, int median, int axis) const |
| void | balance_segment (Photon **pbal, Photon **porg, int index, int start, int end) |
| void | locate_photons (nearest_photons *np, int index) const |
| void | locate_nearest_photon_with_irradiance (const sheep::Vector3 &normal, nearest_photons *np, int index) const |
Private Attributes | |
| int | m_stored_photons |
| int | m_half_stored_photons |
| int | m_prev_scale |
| std::vector< Photon > | m_photons |
| The array of photons. | |
| sheep::float32 | m_bbox_min [3] |
| Bounding box of the photon array. | |
| sheep::float32 | m_bbox_max [3] |
| sheep::float32 * | m_dist2_buf |
| const Photon ** | m_index_buf |
Static Private Attributes | |
| const std::string | m_photon_map_sig = "toxic photon map file version 1" |
| Signature string identifying photon map files. | |
Definition at line 49 of file photonmap.h.
|
|
Some buffers used by the IrradianceEstimate() method.
Definition at line 171 of file photonmap.h. |
|
|
Definition at line 46 of file photonmap.cpp. References BUF_SIZE, m_bbox_max, m_bbox_min, m_dist2_buf, m_index_buf, and m_photons. Referenced by CreateFromFile(). |
|
|
Definition at line 62 of file photonmap.cpp. References m_dist2_buf, and m_index_buf. |
|
||||||||||||||||||||||||
|
Same as the ComputeRadiance() method, except that the surface is considered as a perfect lambertian surface. This method is faster than the ComputeRadiance() method, but it is also less accurate. The point and the surface normal are expressed in world space. The returned value is a radiance (W.m^-2.sr^-1).
Definition at line 235 of file photonmap.cpp. References BUF_SIZE, fnz(), toxic::Photon::GetIncidentDirection(), toxic::Photon::GetPower(), toxic::Photon::GetSurfaceNormal(), locate_photons(), toxic::PhotonMap::nearest_photons::m_dist2, m_dist2_buf, toxic::PhotonMap::nearest_photons::m_found, toxic::PhotonMap::nearest_photons::m_got_heap, toxic::PhotonMap::nearest_photons::m_index, m_index_buf, toxic::PhotonMap::nearest_photons::m_max, toxic::PhotonMap::nearest_photons::m_position, toxic::ShadingData::m_reflectance, and sheep::PI. Referenced by PrecomputeRadiances(). |
|
|
Creates a left-balanced kd-tree from the flat array of photons. This function must be called prior to calling any of the ComputeRadiance(), ApproximateRadiance(), PrecomputeRadiances() and GetPrecomputedRadiance() methods.
Definition at line 113 of file photonmap.cpp. References balance_segment(), m_half_stored_photons, m_photons, and m_stored_photons. Referenced by main(). |
|
||||||||||||||||||||||||
|
See "Realistic Image Synthesis Using Photon Mapping" chapter 6 for an explanation of this function. Definition at line 617 of file photonmap.cpp. References m_bbox_max, m_bbox_min, toxic::Photon::m_position, median_split(), and toxic::Photon::SetSplittingPlaneAxis(). Referenced by Balance(). |
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
|
||||||||||||
|
Creates a photon map by reading it from disk. Returns a pointer to the newly created photon map if successful, and 0 otherwise. Definition at line 511 of file photonmap.cpp. References sheep::BinaryStream::IsOpen(), m_bbox_max, m_bbox_min, m_half_stored_photons, m_photon_map_sig, m_photons, m_stored_photons, PhotonMap(), PHOTONMAP_IO_BUFFER_SIZE, sheep::BinaryStream::Read(), toxic::Photon::ReadFromStream(), and sheep::BinaryStream::SetBufferSize(). Referenced by main(). |
|
|
Definition at line 250 of file photonmap.h. |
|
|
Definition at line 245 of file photonmap.h. Referenced by main(). |
|
||||||||||||||||||||
|
Same as the ApproximateRadiance() method, but several times faster. The point and the surface normal are expressed in world space. The returned value is a radiance (W.m^-2.sr^-1). Be sure to call the PrecomputeRadiances() method prior to calling this method. Definition at line 337 of file photonmap.cpp. References toxic::Photon::GetPrecomputedRadiance(), locate_nearest_photon_with_irradiance(), toxic::PhotonMap::nearest_photons::m_dist2, m_dist2_buf, toxic::PhotonMap::nearest_photons::m_index, m_index_buf, toxic::PhotonMap::nearest_photons::m_position, and toxic::ShadingData::m_reflectance. Referenced by toxic::Renderer::compute_indirect_illumination(). |
|
|
Returns the size (in bytes) of the photon map in memory.
Definition at line 67 of file photonmap.cpp. References BUF_SIZE, and m_photons. Referenced by main(). |
|
||||||||||||||||
|
||||||||||||
|
locate_photons() finds the nearest photons in the photon map given the parameters in np.
Definition at line 677 of file photonmap.cpp. References toxic::Photon::GetSplittingPlaneAxis(), toxic::PhotonMap::nearest_photons::m_dist2, toxic::PhotonMap::nearest_photons::m_found, toxic::PhotonMap::nearest_photons::m_got_heap, m_half_stored_photons, toxic::PhotonMap::nearest_photons::m_index, toxic::PhotonMap::nearest_photons::m_max, m_photons, toxic::Photon::m_position, and toxic::PhotonMap::nearest_photons::m_position. Referenced by ApproximateRadiance(), BuildPhotonDirectionHistogram(), and ComputeRadiance(). |
|
||||||||||||||||||||||||
|
median_split() splits the photon array into two separate pieces around the median, with all photons below the median in the lower half and all photons above the median in the upper half. The comparison criteria is the axis (indicated by the axis parameter). Inspired by routine in "Algorithms in C++" by Sedgewick. Definition at line 583 of file photonmap.cpp. References toxic::Photon::m_position. Referenced by balance_segment(). |
|
||||||||||||||||||||
|
Precomputes the reflected radiance at photons location. This method calls the ApproximateRadiance() to compute the reflected radiance at a given photon's location, thus the surface carrying the photon is considered as a perfect lambertian surface. Be sure to call the Balance() method prior to calling this method, and be sure to call this method prior to the first call of the GetPrecomputedRadiance() method. Definition at line 302 of file photonmap.cpp. References ApproximateRadiance(), toxic::Photon::GetPosition(), toxic::Photon::GetSurfaceNormal(), m_photons, toxic::ShadingData::m_reflectance, m_stored_photons, and toxic::Photon::SetPrecomputedRadiance(). Referenced by main(). |
|
|
This method is used to scale the power of all photons once they have been emitted from the light source. scale = 1 / (#emitted photons) Call this function after each light source is processed. Definition at line 106 of file photonmap.cpp. References m_photons, m_prev_scale, and m_stored_photons. Referenced by toxic::IPhotonTracer::BuildPhotonMap(). |
|
||||||||||||||||||||
|
Creates and stores a photon into the photon map. 'direction' must be unit-length. Both 'position' and 'direction' must be expressed in world space. The power is expressed in W. Definition at line 75 of file photonmap.cpp. References m_bbox_max, m_bbox_min, m_photons, m_stored_photons, toxic::Photon::SetIncidentDirection(), toxic::Photon::SetPosition(), toxic::Photon::SetPower(), and toxic::Photon::SetSurfaceNormal(). Referenced by toxic::GlobalPhotonTracer::trace_photon(), and toxic::CausticsPhotonTracer::trace_photon(). |
|
||||||||||||
|
Writes the photon map to disk. Returns true if writing was successful.
Definition at line 455 of file photonmap.cpp. References sheep::BinaryStream::IsOpen(), m_bbox_max, m_bbox_min, m_half_stored_photons, m_photon_map_sig, m_photons, m_stored_photons, PHOTONMAP_IO_BUFFER_SIZE, sheep::BinaryStream::SetBufferSize(), and sheep::BinaryStream::Write(). Referenced by main(). |
|
|
Definition at line 168 of file photonmap.h. Referenced by balance_segment(), CreateFromFile(), PhotonMap(), StorePhoton(), and WriteToFile(). |
|
|
Bounding box of the photon array.
Definition at line 167 of file photonmap.h. Referenced by balance_segment(), CreateFromFile(), PhotonMap(), StorePhoton(), and WriteToFile(). |
|
|
Definition at line 172 of file photonmap.h. Referenced by ApproximateRadiance(), BuildPhotonDirectionHistogram(), ComputeRadiance(), GetPrecomputedRadiance(), PhotonMap(), and ~PhotonMap(). |
|
|
Definition at line 160 of file photonmap.h. Referenced by Balance(), CreateFromFile(), locate_nearest_photon_with_irradiance(), locate_photons(), and WriteToFile(). |
|
|
Definition at line 173 of file photonmap.h. Referenced by ApproximateRadiance(), BuildPhotonDirectionHistogram(), ComputeRadiance(), GetPrecomputedRadiance(), PhotonMap(), and ~PhotonMap(). |
|
|
Signature string identifying photon map files. Signature string identifying photon map files. Increment version number each time the file structure change. Definition at line 41 of file photonmap.cpp. Referenced by CreateFromFile(), and WriteToFile(). |
|
|
The array of photons.
Definition at line 164 of file photonmap.h. Referenced by Balance(), CreateFromFile(), GetSizeInMemory(), locate_nearest_photon_with_irradiance(), locate_photons(), PhotonMap(), PrecomputeRadiances(), ScalePhotonPower(), StorePhoton(), and WriteToFile(). |
|
|
Definition at line 161 of file photonmap.h. Referenced by ScalePhotonPower(). |
|
|
Definition at line 159 of file photonmap.h. Referenced by Balance(), CreateFromFile(), PrecomputeRadiances(), ScalePhotonPower(), StorePhoton(), and WriteToFile(). |
1.3.6