Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
PathTracer.hpp
1#pragma once
2#include "raycaster/Raycaster.hpp"
3#include "scene/Scene.hpp"
4#include "Common.hpp"
5
11public:
13 PathTracer() = default;
14
18 explicit PathTracer(const std::shared_ptr<Scene> & scene);
19
26 void render(const Camera & camera, size_t samples, size_t depth, Image & render);
27
29 const Raycaster & raycaster() const { return _raycaster; }
30
31private:
32
37 static glm::ivec2 getSampleGrid(size_t samples);
38
46 static glm::vec2 getSamplePosition(size_t sid, const glm::ivec2 & cellCount, const glm::vec2 & cellSize);
47
55 static glm::mat3 buildLocalFrame(const Object & obj, const Raycaster::Hit & hit, const glm::vec3 & rayDir, const glm::vec2 & uv);
56
63 bool checkVisibility(const glm::vec3 & startPos, const glm::vec3 & rayDir, float maxDist) const;
64
72 glm::vec3 evalBackground(const glm::vec3 & rayDir, const glm::vec3 & rayPos, const glm::vec2 & ndcPos, bool directHit) const;
73
75 std::shared_ptr<Scene> _scene;
76};
This class represents a camera as used in real-time rendering APIs. It provides a view and projection...
Definition: Camera.hpp:11
Represents an image composed of pixels with values in [0,1]. Provide image loading/saving utilities,...
Definition: Image.hpp:8
Represent a 3D textured object.
Definition: Object.hpp:16
Unidirectional path tracer. Generates renderings of a scene by emitting rays from the user viewpoint ...
Definition: PathTracer.hpp:10
static glm::ivec2 getSampleGrid(size_t samples)
Definition: PathTracer.cpp:57
void render(const Camera &camera, size_t samples, size_t depth, Image &render)
Definition: PathTracer.cpp:159
glm::vec3 evalBackground(const glm::vec3 &rayDir, const glm::vec3 &rayPos, const glm::vec2 &ndcPos, bool directHit) const
Definition: PathTracer.cpp:23
const Raycaster & raycaster() const
Definition: PathTracer.hpp:29
static glm::mat3 buildLocalFrame(const Object &obj, const Raycaster::Hit &hit, const glm::vec3 &rayDir, const glm::vec2 &uv)
Definition: PathTracer.cpp:86
Raycaster _raycaster
The internal raycaster.
Definition: PathTracer.hpp:74
std::shared_ptr< Scene > _scene
The scene.
Definition: PathTracer.hpp:75
bool checkVisibility(const glm::vec3 &startPos, const glm::vec3 &rayDir, float maxDist) const
Definition: PathTracer.cpp:124
static glm::vec2 getSamplePosition(size_t sid, const glm::ivec2 &cellCount, const glm::vec2 &cellSize)
Definition: PathTracer.cpp:71
PathTracer()=default
Allows to cast rays against a polygonal mesh, on the CPU. Relies on an internal acceleration structur...
Definition: Raycaster.hpp:10
Definition: Raycaster.hpp:16