initial support for texture baking, i.e. rendering directly to irradiance textures
parent
175da3a314
commit
d6d0203cb3
|
@ -1145,6 +1145,9 @@ bool PathVertex::cast(const Scene *scene, EVertexType desired) {
|
||||||
PositionSamplingRecord pRec(its);
|
PositionSamplingRecord pRec(its);
|
||||||
pRec.object = sensor;
|
pRec.object = sensor;
|
||||||
pRec.pdf = 0.0f;
|
pRec.pdf = 0.0f;
|
||||||
|
|
||||||
|
Vector2i size = sensor->getFilm()->getSize();
|
||||||
|
pRec.uv.x *= size.x; pRec.uv.y *= size.y;
|
||||||
getPositionSamplingRecord() = pRec;
|
getPositionSamplingRecord() = pRec;
|
||||||
degenerate = sensor->getType() & Sensor::EDeltaDirection;
|
degenerate = sensor->getType() & Sensor::EDeltaDirection;
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,9 @@ MTS_NAMESPACE_BEGIN
|
||||||
* provided surface.
|
* provided surface.
|
||||||
* Such a sensor is useful for conducting virtual experiments and
|
* Such a sensor is useful for conducting virtual experiments and
|
||||||
* testing the renderer for correctness.
|
* testing the renderer for correctness.
|
||||||
|
* The result is normalized so that an irradiance sensor inside an
|
||||||
|
* integrating sphere with constant radiance 1 records
|
||||||
|
* an irradiance value of $\pi$.
|
||||||
*
|
*
|
||||||
* To create an irradiance meter, instantiate the desired measurement
|
* To create an irradiance meter, instantiate the desired measurement
|
||||||
* shape and specify the sensor as its child. Note that when the
|
* shape and specify the sensor as its child. Note that when the
|
||||||
|
@ -114,7 +117,7 @@ public:
|
||||||
ray.setDirection(Frame(pRec.n).toWorld(
|
ray.setDirection(Frame(pRec.n).toWorld(
|
||||||
Warp::squareToCosineHemisphere(otherSample)));
|
Warp::squareToCosineHemisphere(otherSample)));
|
||||||
|
|
||||||
return Spectrum(1.0f);
|
return Spectrum(M_PI);
|
||||||
}
|
}
|
||||||
|
|
||||||
Spectrum samplePosition(PositionSamplingRecord &pRec,
|
Spectrum samplePosition(PositionSamplingRecord &pRec,
|
||||||
|
@ -127,15 +130,16 @@ public:
|
||||||
samplePos.y = (extra->y + sample.y) * m_invResolution.y;
|
samplePos.y = (extra->y + sample.y) * m_invResolution.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_shape->samplePosition(pRec, samplePos);
|
||||||
|
|
||||||
pRec.uv = Point2(samplePos.x * m_resolution.x,
|
pRec.uv = Point2(samplePos.x * m_resolution.x,
|
||||||
samplePos.y * m_resolution.y);
|
samplePos.y * m_resolution.y);
|
||||||
|
|
||||||
m_shape->samplePosition(pRec, samplePos);
|
return Spectrum(M_PI / (pRec.pdf * m_shape->getSurfaceArea()));
|
||||||
return Spectrum(1.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Spectrum evalPosition(const PositionSamplingRecord &pRec) const {
|
Spectrum evalPosition(const PositionSamplingRecord &pRec) const {
|
||||||
return Spectrum(m_shape->pdfPosition(pRec));
|
return Spectrum(M_PI / m_shape->getSurfaceArea());
|
||||||
}
|
}
|
||||||
|
|
||||||
Float pdfPosition(const PositionSamplingRecord &pRec) const {
|
Float pdfPosition(const PositionSamplingRecord &pRec) const {
|
||||||
|
@ -182,8 +186,11 @@ public:
|
||||||
a reference point within a medium or on a transmissive surface
|
a reference point within a medium or on a transmissive surface
|
||||||
will set dRec.refN = 0, hence they should always be accepted. */
|
will set dRec.refN = 0, hence they should always be accepted. */
|
||||||
if (dot(dRec.d, dRec.refN) >= 0 && dot(dRec.d, dRec.n) < 0 && dRec.pdf != 0.0f) {
|
if (dot(dRec.d, dRec.refN) >= 0 && dot(dRec.d, dRec.n) < 0 && dRec.pdf != 0.0f) {
|
||||||
dRec.uv = Point2(0.5f);
|
dRec.uv = Point2(
|
||||||
return Spectrum(1.0f / dRec.pdf);
|
dRec.uv.x * m_resolution.x,
|
||||||
|
dRec.uv.y * m_resolution.y);
|
||||||
|
|
||||||
|
return Spectrum(1.0f / (dRec.pdf * m_shape->getSurfaceArea()));
|
||||||
} else {
|
} else {
|
||||||
dRec.pdf = 0.0f;
|
dRec.pdf = 0.0f;
|
||||||
return Spectrum(0.0f);
|
return Spectrum(0.0f);
|
||||||
|
@ -200,6 +207,23 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Spectrum eval(const Intersection &its, const Vector &d, Point2 &samplePos) const {
|
||||||
|
if (dot(its.shFrame.n, d) < 0)
|
||||||
|
return Spectrum(0.0f);
|
||||||
|
|
||||||
|
samplePos = Point2(
|
||||||
|
its.uv.x * m_resolution.x,
|
||||||
|
its.uv.y * m_resolution.y);
|
||||||
|
|
||||||
|
return Spectrum(1.0f / m_shape->getSurfaceArea());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool getSamplePosition(const PositionSamplingRecord &pRec,
|
||||||
|
const DirectionSamplingRecord &dRec, Point2 &samplePosition) const {
|
||||||
|
samplePosition = pRec.uv;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void setParent(ConfigurableObject *parent) {
|
void setParent(ConfigurableObject *parent) {
|
||||||
Sensor::setParent(parent);
|
Sensor::setParent(parent);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue