Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
PLatLongEnvSphere.h
Go to the documentation of this file.
1#pragma once
2
4#include "Math/TVector2.h"
5#include "Math/TVector3.h"
8
9#include <array>
10
11namespace ph
12{
13
21{
22 // TODO: currently not fully time aware
23public:
24 explicit PLatLongEnvSphere(real radius);
25
27 real radius,
28 const math::StaticRigidTransform* localToWorld,
29 const math::StaticRigidTransform* worldToLocal);
30
31 bool isIntersecting(const Ray& ray, HitProbe& probe) const override;
32 bool isOccluding(const Ray& ray) const override;
33
34 void calcHitDetail(
35 const Ray& ray,
36 HitProbe& probe,
37 HitDetail* out_detail) const override;
38
39 void calcPosPdf(PrimitivePosPdfQuery& query) const override;
40
41 void genPosSample(
43 SampleFlow& sampleFlow,
44 HitProbe& probe) const override;
45
46 bool mayOverlapVolume(const math::AABB3D& volume) const override;
47 math::AABB3D calcAABB() const override;
48 real calcExtendedArea() const override;
49
50private:
57 void genPosSampleWithObservationPos(
58 const math::Vector2R& latLong01,
59 real latLong01Pdf,
61 HitProbe& probe) const;
62
69 void genPosSampleWithoutObservationPos(
70 const math::Vector2R& latLong01,
71 real latLong01Pdf,
73 SampleFlow& sampleFlow,
74 HitProbe& probe) const;
75
79 void calcPosPdfWithObservationPos(
80 const math::Vector2R& latLong01,
81 real latLong01Pdf,
82 PrimitivePosPdfQuery& query) const;
83
93 bool latLong01ToSurface(
94 const math::Vector2R& latLong01,
95 const math::Vector3R& observationPos,
96 math::Vector3R* out_surface,
97 math::Vector3R* out_unitObservationDir) const;
98
106 void latLong01ToSurface(
107 const math::Vector2R& latLong01,
108 const std::array<real, 2>& uniformSample,
109 math::Vector3R* out_surface,
110 math::Vector3R* out_unitObservationDir,
111 real* out_pdfA) const;
112
113 const math::StaticRigidTransform* m_localToWorld;
114 const math::StaticRigidTransform* m_worldToLocal;
115 math::Vector3R m_worldOrigin;
116};
117
118inline bool PLatLongEnvSphere::mayOverlapVolume(const math::AABB3D& volume) const
119{
120 // Rather than transforming `volume` to local space, we transform the sphere to world space
121 // instead. Under static rigid transform the sphere shape is rotational invariant, we can
122 // inversely translate `volume` and test against the sphere at the origin
123 auto effectiveVolume = volume.getTranslated(m_worldOrigin.negate());
124 return PBasicSphere::mayOverlapVolume(effectiveVolume);
125}
126
128{
129 // Under static rigid transform, only translation will matter to the AABB of a sphere
130 return PBasicSphere::calcAABB().translate(m_worldOrigin);
131}
132
134{
135 // Does not change under rigid transform
137}
138
139}// end namespace ph
Detailed information regarding a ray-primitive intersection.
Definition HitDetail.h:26
Lightweight ray intersection testing and reporting object. If an intersection is found,...
Definition HitProbe.h:27
Definition PBasicSphere.h:14
math::AABB3D calcAABB() const override
Calculates Axis-Aligned Bounding Box (AABB) of itself.
Definition PBasicSphere.cpp:47
real calcExtendedArea() const override
Calculates the area extended by this primitive. The term "extended" implies single-sided,...
Definition PBasicSphere.cpp:52
bool mayOverlapVolume(const math::AABB3D &volume) const override
Conservatively checks whether this object overlaps a volume.
Definition PBasicSphere.cpp:42
A sphere specifically built for environment lighting. This primitive is for environment map with lati...
Definition PLatLongEnvSphere.h:21
bool isIntersecting(const Ray &ray, HitProbe &probe) const override
Determine whether a given ray hits the object.
Definition PLatLongEnvSphere.cpp:46
bool isOccluding(const Ray &ray) const override
Determines whether this object blocks the ray.
Definition PLatLongEnvSphere.cpp:53
void calcHitDetail(const Ray &ray, HitProbe &probe, HitDetail *out_detail) const override
Calculates properties of a hit, such as coordinates and normal.
Definition PLatLongEnvSphere.cpp:60
PLatLongEnvSphere(real radius)
Definition PLatLongEnvSphere.cpp:22
bool mayOverlapVolume(const math::AABB3D &volume) const override
Conservatively checks whether this object overlaps a volume.
Definition PLatLongEnvSphere.h:118
void calcPosPdf(PrimitivePosPdfQuery &query) const override
Given a point on the surface of this primitive, calculates the PDF of sampling this point.
Definition PLatLongEnvSphere.cpp:142
real calcExtendedArea() const override
Calculates the area extended by this primitive. The term "extended" implies single-sided,...
Definition PLatLongEnvSphere.h:133
math::AABB3D calcAABB() const override
Calculates Axis-Aligned Bounding Box (AABB) of itself.
Definition PLatLongEnvSphere.h:127
void genPosSample(PrimitivePosSampleQuery &query, SampleFlow &sampleFlow, HitProbe &probe) const override
Generates a sample point on the surface of this primitive.
Definition PLatLongEnvSphere.cpp:116
Information for the probability of generating a specific sample point on a primitive.
Definition PrimitivePosPdfQuery.h:91
Information for generating a sample point on a primitive.
Definition PrimitivePosSampleQuery.h:132
Represents a ray in space.
Definition Ray.h:21
A sample with arbitrary dimensions with fine-grained sampling control.
Definition SampleFlow.h:19
Definition StaticRigidTransform.h:19
TAABB3D getTranslated(const TVector3< T > &amount) const
Definition TAABB3D.ipp:262
TAABB3D & translate(const TVector3< T > &amount)
Definition TAABB3D.ipp:216
Derived negate() const
Applies a negative sign to the array's elements. These methods is only defined for signed element typ...
Definition TArithmeticArrayBase.ipp:520
The root for all renderer implementations.
Definition EEngineProject.h:6