Working on the night mode

This commit is contained in:
Vladislav Khorev committed 2026-06-04 13:27:52 +03:00
1 parent e6bfe85e2e
commit 442d3a7945
18 files changed
+1060 -2

No files matched your search

+10
View File
@@ -825,6 +825,16 @@ namespace ZL {
}
}
void Renderer::RenderUniform3fvArray(const std::string& uniformName, int count, const float* value)
{
auto shader = shaderManager.GetCurrentShader();
auto uniform = shader->uniformList.find(uniformName);
if (uniform != shader->uniformList.end())
{
glUniform3fv(uniform->second, count, value);
}
}
void Renderer::RenderUniform4fv(const std::string& uniformName, const float* value)
{
auto shader = shaderManager.GetCurrentShader();
+1
View File
@@ -135,6 +135,7 @@ namespace ZL {
void RenderUniformMatrix4fvArray(const std::string& uniformName, int count, bool transpose, const float* value);
void RenderUniform1i(const std::string& uniformName, const int value);
void RenderUniform3fv(const std::string& uniformName, const float* value);
void RenderUniform3fvArray(const std::string& uniformName, int count, const float* value);
void RenderUniform4fv(const std::string& uniformName, const float* value);
void RenderUniform1f(const std::string& uniformName, float value);
+23
View File
@@ -133,6 +133,29 @@ namespace ZL {
lightSpaceMatrix = lightProjectionMatrix * lightViewMatrix;
}
static Eigen::Matrix4f perspective(float fovY, float aspect, float zNear, float zFar) {
float t = std::tan(fovY * 0.5f);
Eigen::Matrix4f m = Eigen::Matrix4f::Zero();
m(0, 0) = 1.0f / (aspect * t);
m(1, 1) = 1.0f / t;
m(2, 2) = -(zFar + zNear) / (zFar - zNear);
m(2, 3) = -(2.0f * zFar * zNear) / (zFar - zNear);
m(3, 2) = -1.0f;
return m;
}
void ShadowMap::updateSpotlightMatrix(const Eigen::Vector3f& lightPos,
const Eigen::Vector3f& lightDir,
float fovY, float nearZ, float farZ) {
Eigen::Vector3f d = lightDir.normalized();
Eigen::Vector3f up(0.f, 1.f, 0.f);
if (std::abs(d.dot(up)) > 0.99f)
up = Eigen::Vector3f(1.f, 0.f, 0.f);
lightViewMatrix = lookAt(lightPos, lightPos + d, up);
lightProjectionMatrix = perspective(fovY, 1.0f, nearZ, farZ);
lightSpaceMatrix = lightProjectionMatrix * lightViewMatrix;
}
void ShadowMap::bind() {
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glViewport(0, 0, resolution, resolution);
+3
View File
@@ -29,6 +29,9 @@ namespace ZL {
void setLightDirection(const Eigen::Vector3f& dir);
void updateLightSpaceMatrix(const Eigen::Vector3f& sceneCenter);
void updateSpotlightMatrix(const Eigen::Vector3f& lightPos,
const Eigen::Vector3f& lightDir,
float fovY, float nearZ, float farZ);
void bind();
void unbind();