19 #include <nori/camera.h>
20 #include <nori/rfilter.h>
21 #include <nori/warp.h>
22 #include <Eigen/Geometry>
36 m_outputSize.x() = propList.
getInteger(
"width", 1280);
37 m_outputSize.y() = propList.
getInteger(
"height", 720);
38 m_invOutputSize = m_outputSize.cast<
float>().cwiseInverse();
44 m_fov = propList.
getFloat(
"fov", 30.0f);
47 m_nearClip = propList.
getFloat(
"nearClip", 1e-4f);
48 m_farClip = propList.
getFloat(
"farClip", 1e4f);
54 float aspect = m_outputSize.x() / (float) m_outputSize.y();
64 float recip = 1.0f / (m_farClip - m_nearClip),
65 cot = 1.0f / std::tan(degToRad(m_fov / 2.0f));
67 Eigen::Matrix4f perspective;
71 0, 0, m_farClip * recip, -m_nearClip * m_farClip * recip,
79 Eigen::DiagonalMatrix<float, 3>(
Vector3f(0.5f, -0.5f * aspect, 1.0f)) *
80 Eigen::Translation<float, 3>(1.0f, -1.0f/aspect, 0.0f) * perspective).
inverse();
92 const Point2f &apertureSample)
const {
96 samplePosition.x() * m_invOutputSize.x(),
97 samplePosition.y() * m_invOutputSize.y(), 0.0f);
102 float invZ = 1.0f / d.z();
104 ray.
o = m_cameraToWorld *
Point3f(0, 0, 0);
105 ray.
d = m_cameraToWorld * d;
106 ray.
mint = m_nearClip * invZ;
107 ray.
maxt = m_farClip * invZ;
115 case EReconstructionFilter:
117 throw NoriException(
"Camera: tried to register multiple reconstruction filters!");
122 throw NoriException(
"Camera::addChild(<%s>) is not supported!",
130 "PerspectiveCamera[\n"
131 " cameraToWorld = %s,\n"
132 " outputSize = %s,\n"
134 " clip = [%f, %f],\n"
137 indent(m_cameraToWorld.
toString(), 18),
Generic camera interface.
Simple exception class, which stores a human-readable error description.
static NoriObject * createInstance(const std::string &name, const PropertyList &propList)
Construct an instance from the class of the given name.
Base class of all objects.
virtual void activate()
Perform some action associated with the object.
virtual std::string toString() const =0
Return a brief string summary of the instance (for debugging purposes)
static std::string classTypeName(EClassType type)
Turn a class type into a human-readable string.
virtual EClassType getClassType() const =0
Return the type of object (i.e. Mesh/BSDF/etc.) provided by this instance.
Perspective camera with depth of field.
virtual void activate() override
Perform some action associated with the object.
Color3f sampleRay(Ray3f &ray, const Point2f &samplePosition, const Point2f &apertureSample) const
Importance sample a ray according to the camera's response function.
virtual std::string toString() const override
Return a human-readable summary.
virtual void addChild(NoriObject *obj) override
Add a child object to the current instance.
This is an associative container used to supply the constructors of NoriObject subclasses with parame...
Transform getTransform(const std::string &name) const
Get a transform property, and throw an exception if it does not exist.
float getFloat(const std::string &name) const
Get a float property, and throw an exception if it does not exist.
int getInteger(const std::string &name) const
Get an integer property, and throw an exception if it does not exist.
Generic radially symmetric image reconstruction filter.
Represents a linear RGB color value.
VectorType d
Ray direction.
Scalar mint
Minimum position on the ray segment.
void update()
Update the reciprocal ray directions after changing 'd'.
Scalar maxt
Maximum position on the ray segment.
std::string toString() const
Return a human-readable string summary.