skybox.cpp 809 Bytes
Newer Older
Johannes Braun's avatar
Johannes Braun committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "skybox.h"

// --------------- STDLIB ---------------


// --------------- EXTERN ---------------

// --------------- INTERN ---------------
#include <raytrace/data/global_collector.h>

namespace glare::raytrace
{
	SkyboxCollector::SkyboxCollector() {}
	SkyboxCollector::~SkyboxCollector() {}
	
	void SkyboxCollector::collect(const math::Flags &flags, const core::SceneNode &node)
	{
		if (flags & DirtyFlags::eSkybox)
		{
			if (auto&& skybox = node.getComponent<core::Skybox>()) {
				m_skybox = skybox;
			}
		}
	}

	void SkyboxCollector::apply(core::Program &program)
	{
Johannes Braun's avatar
Johannes Braun committed
28
		if (m_skybox)
Johannes Braun's avatar
Johannes Braun committed
29
		{
Johannes Braun's avatar
Johannes Braun committed
30
			program.uniformStruct("u_environment", *m_skybox);
Johannes Braun's avatar
Johannes Braun committed
31
32
33
34
35
36
37
38
		}
		else
		{
			program.uniform("u_environment.color", glm::vec4(0.7f, 0.9f, 0.97f, 1));
			program.uniform("u_environment.has_cubemap", 0);
		}
	}
}