Photon Engine 2.0.0-beta
A physically based renderer.
|
Carve out some part of an intersectable. This is a masking approach based on intersection routine. Another common approach to shape masking is BSDF-based, where the mask determines whether the incoming light simply passes through (a no-op, perfectly transmitting BSDF). There is a trade-off between these approaches: masking in intersection routine samples the mask texture (usually a slower operation) in the tight loop of acceleration structure traversal, while masking in BSDF will need to re-enter the acceleration structure multiple times (such as when rendering a forest) which can also be slow. More...
#include <MaskedIntersectable.h>
Public Member Functions | |
MaskedIntersectable (const Intersectable *intersectable, const std::shared_ptr< TTexture< real > > &mask, uint8 maxIterations=4) | |
bool | isIntersecting (const Ray &ray, HitProbe &probe) const override |
Determine whether a given ray hits the object. | |
bool | reintersect (const Ray &ray, HitProbe &probe, const Ray &srcRay, HitProbe &srcProbe) const override |
Intersect the intersected object again with a different ray. | |
void | calcHitDetail (const Ray &ray, HitProbe &probe, HitDetail *out_detail) const override |
Calculates properties of a hit, such as coordinates and normal. | |
math::AABB3D | calcAABB () const override |
Calculates Axis-Aligned Bounding Box (AABB) of itself. | |
Public Member Functions inherited from ph::Intersectable | |
virtual | ~Intersectable ()=default |
virtual bool | isOccluding (const Ray &ray) const |
Determines whether this object blocks the ray. | |
virtual bool | mayOverlapVolume (const math::AABB3D &volume) const |
Conservatively checks whether this object overlaps a volume. | |
Carve out some part of an intersectable. This is a masking approach based on intersection routine. Another common approach to shape masking is BSDF-based, where the mask determines whether the incoming light simply passes through (a no-op, perfectly transmitting BSDF). There is a trade-off between these approaches: masking in intersection routine samples the mask texture (usually a slower operation) in the tight loop of acceleration structure traversal, while masking in BSDF will need to re-enter the acceleration structure multiple times (such as when rendering a forest) which can also be slow.
ph::MaskedIntersectable::MaskedIntersectable | ( | const Intersectable * | intersectable, |
const std::shared_ptr< TTexture< real > > & | mask, | ||
uint8 | maxIterations = 4 ) |
intersectable | The intersectable to apply the mask on. |
mask | The mask to apply. Commonly called alpha mask or opacity mask. |
maxIterations | For some shape, such as sphere, ray intersection must be performed iteratively if earlier intersections are being rejected by the mask. The default value should be plenty for most shapes (e.g., a sphere has at most 2 intersections for a single ray). |
|
overridevirtual |
Calculates Axis-Aligned Bounding Box (AABB) of itself.
Implements ph::Intersectable.
|
overridevirtual |
Calculates properties of a hit, such as coordinates and normal.
This method calculates a detailed description of a hit from the ray and probe involved in a hit event. For example, the ray and probe used for calling isIntersecting() can be the inputs of this method (if an intersection is found). The process of calculating intersection detail will destroy the input probe.
ray | The ray from a hit event. |
probe | The probe from a hit event. The process of detail calculation will destroy the probe. |
out_detail | Stores the calculated details. This method calculates the essential details only. Some information such as coordinate bases will only be available if specifically requested afterwards (for an example, see HitDetail::computeBases() ). |
Primitive
for more methods that can generate a hit event. Implements ph::Intersectable.
|
overridevirtual |
Determine whether a given ray hits the object.
Checks whether the specified ray intersects this intersectable. If there is an intersection, true
is returned and a brief hit report is stored inside the probe. If there is no intersection, false
is returned and the state of the probe is undefined. ray
and probe
can be used for obtaining hit detail if an intersection is found.
ray
and probe
). Implements ph::Intersectable.
|
overridevirtual |
Intersect the intersected object again with a different ray.
This method is different to isIntersecting(const Ray, HitProbe&) const. Given srcRay
and srcProbe
, this method performs an intersection test against the chain of intersectables recorded in srcProbe
(so it is impossible to "discover" new intersectables with this method). Taking BVH as an example, the implementation may only record the intersected object in the probe so this method can bypass the entire BVH traversal.
ray | The ray to test for intersection. |
probe | The probe to record the intersection. |
srcRay | The ray from a previous hit event. |
srcProbe | The probe from a hit event. The process of re-intersect will destroy the probe. |
ray
intersects the object.ray
and probe
). srcProbe
. Implements ph::Intersectable.