fix ray tracer projection plane
This commit is contained in:
parent
29df264479
commit
7321acfb3d
6 changed files with 37 additions and 16 deletions
|
|
@ -57,7 +57,7 @@ Mat4F Camera::calculateProjectionMatrix() const {
|
|||
return out;
|
||||
}
|
||||
|
||||
Vec3F Camera::project(Vec2F normalized) {
|
||||
Vec3F Camera::project(Vec2F normalized) const {
|
||||
auto camMat = calculateTransformationMatrix();
|
||||
auto inv = camMat.inv();
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ Vec3F Camera::project(Vec2F normalized) {
|
|||
return Vec3F(inv * world_pos4);
|
||||
}
|
||||
|
||||
Vec2F Camera::project(const Vec3F& world) {
|
||||
Vec2F Camera::project(const Vec3F& world) const {
|
||||
Vec4F world_pos4(world.x, world.y, world.z, 1);
|
||||
Vec4F transformed = calculateViewMatrix() * world_pos4;
|
||||
transformed = calculateProjectionMatrix() * transformed;
|
||||
|
|
|
|||
|
|
@ -39,8 +39,10 @@ namespace tp {
|
|||
[[nodiscard]] Mat4F calculateTransformationMatrix() const;
|
||||
[[nodiscard]] Mat<halnf, 4, 4> calculateProjectionMatrix() const;
|
||||
[[nodiscard]] Mat<halnf, 4, 4> calculateViewMatrix() const;
|
||||
[[nodiscard]] Vec3F project(Vec2F normalized);
|
||||
[[nodiscard]] Vec2F project(const Vec3F& world);
|
||||
|
||||
// from -1 -1 is top left corner. z is distance to the target
|
||||
[[nodiscard]] Vec3F project(Vec2F normalized) const;
|
||||
[[nodiscard]] Vec2F project(const Vec3F& world) const;
|
||||
[[nodiscard]] static Vec2F project(const tp::Vec3F& world, const tp::Mat4F& viewMat, const tp::Mat4F& projMat);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue