Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
BVHRenderer.hpp
1#pragma once
2
3#include "PathTracer.hpp"
4#include "raycaster/RaycasterVisualisation.hpp"
5#include "scene/Scene.hpp"
6#include "renderers/Renderer.hpp"
7#include "resources/Texture.hpp"
8#include "input/ControllableCamera.hpp"
9
10#include "Common.hpp"
11
17class BVHRenderer final : public Renderer {
18
19public:
22 explicit BVHRenderer();
23
28 void setScene(const std::shared_ptr<Scene> & scene, const Raycaster & raycaster);
29
31 void draw(const Camera & camera, Texture * dstColor, Texture * dstDepth, uint layer = 0) override;
32
34 ~BVHRenderer() override;
35
40 void castRay(const glm::vec3 & position, const glm::vec3 & direction);
41
43 void clearRay();
44
48 bool & showBVH(){ return _showBVH; }
49
53 glm::ivec2 & range(){ return _bvhRange; }
54
58 int maxLevel();
59
60private:
61
64 std::vector<Mesh> _bvhLevels;
65 std::vector<Mesh> _rayLevels;
66 Mesh _rayVis = Mesh("rayVis");
67
68 std::shared_ptr<Scene> _scene;
69 std::unique_ptr<RaycasterVisualisation> _visuHelper;
70
71 glm::ivec2 _bvhRange = glm::ivec2(0, 1);
72 bool _showBVH = true;
73};
Renderer coupled with a basic diffuse path tracer. The user can move the camera anywhere and trigger ...
Definition: BVHRenderer.hpp:17
~BVHRenderer() override
Definition: BVHRenderer.cpp:81
std::unique_ptr< RaycasterVisualisation > _visuHelper
Helper for raycaster internal data visualisation.
Definition: BVHRenderer.hpp:69
void castRay(const glm::vec3 &position, const glm::vec3 &direction)
Definition: BVHRenderer.cpp:91
Program * _bvhProgram
BVH visualisation program.
Definition: BVHRenderer.hpp:63
void setScene(const std::shared_ptr< Scene > &scene, const Raycaster &raycaster)
Definition: BVHRenderer.cpp:16
bool & showBVH()
Definition: BVHRenderer.hpp:48
int maxLevel()
Definition: BVHRenderer.cpp:117
Program * _objectProgram
Basic object program.
Definition: BVHRenderer.hpp:62
Mesh _rayVis
Mesh representing a ray and its intersected triangle.
Definition: BVHRenderer.hpp:66
glm::ivec2 _bvhRange
The subset of the BVH to display.
Definition: BVHRenderer.hpp:71
std::vector< Mesh > _bvhLevels
The BVH visualisation mesh.
Definition: BVHRenderer.hpp:64
void draw(const Camera &camera, Texture *dstColor, Texture *dstDepth, uint layer=0) override
Definition: BVHRenderer.cpp:29
std::vector< Mesh > _rayLevels
BVH nodes intersected with a ray.
Definition: BVHRenderer.hpp:65
void clearRay()
Definition: BVHRenderer.cpp:109
std::shared_ptr< Scene > _scene
The scene to render.
Definition: BVHRenderer.hpp:68
glm::ivec2 & range()
Definition: BVHRenderer.hpp:53
BVHRenderer()
Definition: BVHRenderer.cpp:8
bool _showBVH
Show the raytracer BVH.
Definition: BVHRenderer.hpp:72
This class represents a camera as used in real-time rendering APIs. It provides a view and projection...
Definition: Camera.hpp:11
Represents a geometric mesh composed of vertices, other attributes and triangles.
Definition: Mesh.hpp:15
Represents a group of shaders used for rendering.
Definition: Program.hpp:31
Allows to cast rays against a polygonal mesh, on the CPU. Relies on an internal acceleration structur...
Definition: Raycaster.hpp:10
Base structure of a renderer.
Definition: Renderer.hpp:10
Represents a texture containing one or more images, stored on the CPU and/or GPU.
Definition: Texture.hpp:12