Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
film.h
Go to the documentation of this file.
1 /*
2  This file is part of Mitsuba, a physically based rendering system.
3 
4  Copyright (c) 2007-2014 by Wenzel Jakob and others.
5 
6  Mitsuba is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License Version 3
8  as published by the Free Software Foundation.
9 
10  Mitsuba is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #pragma once
20 #if !defined(__MITSUBA_RENDER_FILM_H_)
21 #define __MITSUBA_RENDER_FILM_H_
22 
23 #include <mitsuba/render/sampler.h>
25 
27 
28 /** \brief Abstract film base class - used to store samples
29  * generated by \ref Integrator implementations.
30  *
31  * To avoid lock-related bottlenecks when rendering with many cores,
32  * rendering threads first store results in an "image block", which
33  * is then committed to the film.
34  *
35  * \ingroup librender
36  */
38 public:
39  /// Ignoring the crop window, return the resolution of the underlying sensor
40  inline const Vector2i &getSize() const { return m_size; }
41 
42  /// Return the size of the crop window
43  inline const Vector2i &getCropSize() const { return m_cropSize; }
44 
45  /// Return the offset of the crop window
46  inline const Point2i &getCropOffset() const { return m_cropOffset; }
47 
48  /// Clear the film
49  virtual void clear() = 0;
50 
51  /// Merge an image block into the film
52  virtual void put(const ImageBlock *block) = 0;
53 
54  /// Overwrite the film with the given bitmap and optionally multiply it by a scalar
55  virtual void setBitmap(const Bitmap *bitmap, Float multiplier = 1.0f) = 0;
56 
57  /// Accumulate a bitmap on top of the radiance values stored in the film
58  virtual void addBitmap(const Bitmap *bitmap, Float multiplier = 1.0f) = 0;
59 
60  /// Set the target filename (with or without extension)
61  virtual void setDestinationFile(const fs::path &filename, uint32_t blockSize) = 0;
62 
63  /// Develop the film and write the result to the previously specified filename
64  virtual void develop(const Scene *scene, Float renderTime) = 0;
65 
66  /**
67  * \brief Develop the contents of a subregion of the film and store
68  * it inside the given bitmap
69  *
70  * This may fail when the film does not have an explicit representation
71  * of the bitmap in question (e.g. when it is writing to a tiled EXR image)
72  *
73  * \return \c true upon success
74  */
75  virtual bool develop(
76  const Point2i &offset,
77  const Vector2i &size,
78  const Point2i &targetOffset,
79  Bitmap *target) const = 0;
80 
81  /// Does the destination file already exist?
82  virtual bool destinationExists(const fs::path &basename) const = 0;
83 
84  /**
85  * Should regions slightly outside the image plane be sampled to improve
86  * the quality of the reconstruction at the edges? This only makes
87  * sense when reconstruction filters other than the box filter are used.
88  */
89  inline bool hasHighQualityEdges() const { return m_highQualityEdges; }
90 
91  /// Return whether or not this film records the alpha channel
92  virtual bool hasAlpha() const = 0;
93 
94  /// Return the image reconstruction filter
95  inline ReconstructionFilter *getReconstructionFilter() { return m_filter.get(); }
96 
97  /// Return the image reconstruction filter (const version)
98  inline const ReconstructionFilter *getReconstructionFilter() const { return m_filter.get(); }
99 
100  // =============================================================
101  //! @{ \name ConfigurableObject interface
102  // =============================================================
103 
104  /// Add a child node
105  virtual void addChild(const std::string &name, ConfigurableObject *child);
106 
107  /// Add an unnamed child
108  inline void addChild(ConfigurableObject *child) { addChild("", child); }
109 
110  /// Configure the film
111  virtual void configure();
112 
113  /// Serialize this film to a binary data stream
114  virtual void serialize(Stream *stream, InstanceManager *manager) const;
115 
116  //! @}
117  // =============================================================
118 
120 protected:
121  /// Create a film
122  Film(const Properties &props);
123 
124  /// Unserialize a film
125  Film(Stream *stream, InstanceManager *manager);
126 
127  /// Virtual destructor
128  virtual ~Film();
129 protected:
130  Point2i m_cropOffset;
131  Vector2i m_size, m_cropSize;
132  bool m_highQualityEdges;
134 };
135 
137 
138 #endif /* __MITSUBA_RENDER_FILM_H_ */
const Point2i & getCropOffset() const
Return the offset of the crop window.
Definition: film.h:46
void addChild(ConfigurableObject *child)
Add an unnamed child.
Definition: film.h:108
General-purpose bitmap class with read and write support for several common file formats.
Definition: bitmap.h:50
Generic serializable object, which supports construction from a Properties instance.
Definition: cobject.h:40
Principal scene data structure.
Definition: scene.h:49
const ReconstructionFilter * getReconstructionFilter() const
Return the image reconstruction filter (const version)
Definition: film.h:98
#define MTS_NAMESPACE_BEGIN
Definition: platform.h:137
const Vector2i & getSize() const
Ignoring the crop window, return the resolution of the underlying sensor.
Definition: film.h:40
Generic interface to separable image reconstruction filters.
Definition: rfilter.h:44
virtual void serialize(Stream *stream, InstanceManager *manager) const
Serialize this object to a binary data stream.
virtual void addChild(const std::string &name, ConfigurableObject *child)
Add a child (default implementation throws an error)
ReconstructionFilter * getReconstructionFilter()
Return the image reconstruction filter.
Definition: film.h:95
bool hasHighQualityEdges() const
Definition: film.h:89
Abstract seekable stream class.
Definition: stream.h:58
#define MTS_DECLARE_CLASS()
This macro must be used in the initial definition in classes that derive from Object.
Definition: class.h:158
const Vector2i & getCropSize() const
Return the size of the crop window.
Definition: film.h:43
Definition: fwd.h:99
Abstract film base class - used to store samples generated by Integrator implementations.
Definition: film.h:37
virtual void configure()
Configure the object (called once after construction and addition of all child ConfigurableObject ins...
Reference counting helper.
Definition: ref.h:40
Storage for an image sub-block (a.k.a render bucket)
Definition: imageblock.h:40
Associative parameter map for constructing subclasses of ConfigurableObject.
Definition: properties.h:46
Coordinates the serialization and unserialization of object graphs.
Definition: serialization.h:65
#define MTS_EXPORT_RENDER
Definition: platform.h:109
Definition: fwd.h:95
#define MTS_NAMESPACE_END
Definition: platform.h:138