add 'u_lightDir' to main shader

This commit is contained in:
MihailRis 2024-10-28 11:33:46 +03:00
parent bed49e54fd
commit ca69b55875
3 changed files with 9 additions and 1 deletions

View File

@ -180,10 +180,11 @@ void Skybox::refresh(const DrawContext& pctx, float t, float mie, uint quality)
};
t *= M_PI*2.0f;
lightDir = glm::normalize(glm::vec3(sin(t), -cos(t), 0.0f));
shader->uniform1i("u_quality", quality);
shader->uniform1f("u_mie", mie);
shader->uniform1f("u_fog", mie - 1.0f);
shader->uniform3f("u_lightDir", glm::normalize(glm::vec3(sin(t), -cos(t), 0.0f)));
shader->uniform3f("u_lightDir", lightDir);
for (uint face = 0; face < 6; face++) {
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, cubemap->getId(), 0);
shader->uniform3f("u_xaxis", xaxs[face]);

View File

@ -3,6 +3,7 @@
#include <memory>
#include <string>
#include <vector>
#include <glm/glm.hpp>
#include "typedefs.hpp"
#include "maths/fastmaths.hpp"
@ -27,6 +28,7 @@ class Skybox {
Shader* shader;
bool ready = false;
FastRandom random;
glm::vec3 lightDir;
std::unique_ptr<Mesh> mesh;
std::unique_ptr<Batch3D> batch3d;
@ -52,4 +54,8 @@ public:
bool isReady() const {
return ready;
}
const glm::vec3 getLightDir() const {
return lightDir;
}
};

View File

@ -166,6 +166,7 @@ void WorldRenderer::setupWorldShader(
shader->uniform1f("u_fogFactor", fogFactor);
shader->uniform1f("u_fogCurve", settings.graphics.fogCurve.get());
shader->uniform1f("u_dayTime", level->getWorld()->getInfo().daytime);
shader->uniform2f("u_lightDir", skybox->getLightDir());
shader->uniform3f("u_cameraPos", camera.position);
shader->uniform1i("u_cubemap", 1);