RayGenerator.h 1.54 KB
Newer Older
unknown's avatar
unknown committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#ifndef __RAYGENERATOR_H
#define __RAYGENERATOR_H

#include <memory>
#include <engine/rendering/ShaderProgram.h>
#include <engine/rendering/GBuffer.h>
#include <engine/Math.h>

namespace glare
{
	namespace advanced
	{
		class Raytracer;

unknown's avatar
unknown committed
15
16
17
18
19
20
		struct TraceProperties
		{
			float accuracy_importance;
			float shadow_importance;

			//Padding properties
21
22
			glm::uint bounce_amount;
			float travelled_distance;
unknown's avatar
unknown committed
23
24
		};

unknown's avatar
unknown committed
25
26
27
28
		struct Trace
		{
			math::Ray ray;
			math::Hit hit;
unknown's avatar
unknown committed
29
30

			TraceProperties properties;
unknown's avatar
unknown committed
31
32
33
34
35
36
37
38
39
		};

		class RayGeneratorBase
		{
		public:
			RayGeneratorBase() {}
			RayGeneratorBase(RayGeneratorBase &other) = delete;
			virtual ~RayGeneratorBase() = default;
			virtual void generate(Raytracer &raytracer);
40
41

			static uint32_t randomSeed();
unknown's avatar
unknown committed
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
		protected:
			bool m_updated_size = false;
			unsigned m_last_width = 0;
			unsigned m_last_height = 0;
		};

		class RayGeneratorDefault : public RayGeneratorBase
		{
		public:
			RayGeneratorDefault();
			~RayGeneratorDefault() {};

			void generate(Raytracer &raytracer) override;
			
		private:
			std::unique_ptr<core::ShaderProgram> m_generator_shader_default;
		};

		class RayGeneratorGBuffer : public RayGeneratorBase
		{
		public:
			RayGeneratorGBuffer();
			~RayGeneratorGBuffer() {};

			void generate(Raytracer &raytracer) override;

		private:
			std::unique_ptr<core::ShaderProgram> m_generator_shader_gbuffer;
			std::unique_ptr<core::ShaderProgram> m_buffer_depthtest;
			std::unique_ptr<core::VertexArray> m_vertex_array;
			std::unique_ptr<core::Framebuffer> m_framebuffer;
		};
	}
}

#endif //__RAYGENERATOR_H