update skybox & fix block overlay

This commit is contained in:
MihailRis 2025-05-09 22:46:07 +03:00
parent 657b4304b4
commit 36e5ff2472
2 changed files with 14 additions and 11 deletions

View File

@ -268,7 +268,7 @@ void main() {
camera_vector, // the camera vector (ray direction of this pixel)
1e12f, // max dist, essentially the scene depth
vec3(0.0f), // scene color, the color of the current pixel being rendered
u_lightDir, // light direction
vec3(u_lightDir.x, pow(u_lightDir.y, 3.0), u_lightDir.z), // light direction
vec3(40.0*fog), // light intensity, 40 looks nice
PLANET_POS, // position of the planet
PLANET_RADIUS, // radius of the planet in meters

View File

@ -375,30 +375,31 @@ void WorldRenderer::draw(
auto& shadowsShader = assets.require<Shader>("shadows");
if (gbufferPipeline) {
int resolution = shadowMap->getResolution();
float shadowMapScale = 0.05f;
float shadowMapSize = shadowMap->getResolution() * shadowMapScale;
float shadowMapSize = resolution * shadowMapScale;
*shadowCamera = Camera(camera.position, shadowMapSize);
shadowCamera->near = 0.1f;
shadowCamera->far = 800.0f;
shadowCamera->perspective = false;
shadowCamera->setAspectRatio(1.0f);
shadowCamera->rotate(glm::radians(-64.0f), glm::radians(-35.0f), glm::radians(-35.0f));
//shadowCamera.perspective = false;
// shadowCamera->rotation = glm::inverse(
// glm::lookAt({}, glm::normalize(camera.position-shadowCamera->position), glm::vec3(0, 1, 0))
// );
shadowCamera->rotate(
glm::radians(90.0f - worldInfo.daytime * 360.0f),
glm::radians(-40.0f),
glm::radians(-0.0f)
);
shadowCamera->updateVectors();
//shadowCamera->position += camera.dir * shadowMapSize * 0.5f;
shadowCamera->position -= shadowCamera->front * 200.0f;
shadowCamera->position -= shadowCamera->right * (shadowMap->getResolution() * shadowMapScale) * 0.5f;
shadowCamera->position -= shadowCamera->up * (shadowMap->getResolution() * shadowMapScale) * 0.5f;
shadowCamera->position -= shadowCamera->right * (resolution * shadowMapScale) * 0.5f;
shadowCamera->position -= shadowCamera->up * (resolution * shadowMapScale) * 0.5f;
shadowCamera->position = glm::floor(shadowCamera->position * 0.25f) * 4.0f;
{
frustumCulling->update(shadowCamera->getProjView());
auto sctx = pctx.sub();
sctx.setDepthTest(true);
sctx.setCullFace(true);
sctx.setViewport({shadowMap->getResolution(), shadowMap->getResolution()});
sctx.setViewport({resolution, resolution});
shadowMap->bind();
setupWorldShader(shadowsShader, *shadowCamera, settings, 0.0f);
chunks->drawChunks(*shadowCamera, shadowsShader);
@ -436,7 +437,6 @@ void WorldRenderer::draw(
DrawContext ctx = wctx.sub();
texts->render(ctx, camera, settings, hudVisible, true);
}
renderBlockOverlay(wctx);
}
postProcessing.render(
@ -446,7 +446,10 @@ void WorldRenderer::draw(
camera,
gbufferPipeline ? shadowMap->getDepthMap() : 0
);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, 0);
renderBlockOverlay(pctx);
}
void WorldRenderer::renderBlockOverlay(const DrawContext& wctx) {