summaryrefslogtreecommitdiff
path: root/gfx/gl/shadowStenciller.h
blob: 925f82a01bc425d299d584743ee9d3cd32572dce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#pragma once

#include "gfx/gl/program.h"
#include "gfx/models/mesh.h"
#include "gfx/models/texture.h"
#include "glArrays.h"

class ShadowStenciller {
public:
	ShadowStenciller();

	[[nodiscard]]
	static glTexture createStencilTexture(GLsizei width, GLsizei height);
	void setLightDirection(const Direction3D & lightDir, const Direction3D & lightDirUp);
	void renderStencil(const glTexture &, const MeshBase &, const Texture::AnyPtr texture) const;

private:
	glFrameBuffer fbo;
	Program shadowCaster;
	Program::RequiredUniformLocation viewProjectionLoc {shadowCaster, "viewProjection"};

	glm::mat4 lightDirMat {};
};