feat: lights debug mode

This commit is contained in:
MihailRis 2025-04-29 15:59:52 +03:00
parent 87dc9ed167
commit 4e5199d89a
6 changed files with 25 additions and 10 deletions

View File

@ -7,10 +7,13 @@ out vec4 f_color;
uniform sampler2D u_texture0;
uniform samplerCube u_cubemap;
uniform bool u_alphaClip;
uniform bool u_debugLights;
void main() {
vec3 fogColor = texture(u_cubemap, a_dir).rgb;
vec4 tex_color = texture(u_texture0, a_texCoord);
if (u_debugLights)
tex_color.rgb = vec3(1.0);
float alpha = a_color.a * tex_color.a;
if (u_alphaClip) {
if (alpha < 0.2f)

View File

@ -203,7 +203,8 @@ void Engine::updateHotkeys() {
if (input->jpressed(Keycode::F2)) {
saveScreenshot();
}
if (input->jpressed(Keycode::F8)) {
if (input->pressed(Keycode::LEFT_CONTROL) && input->pressed(Keycode::F3) &&
input->jpressed(Keycode::U)) {
gui->toggleDebug();
}
if (input->jpressed(Keycode::F11)) {

View File

@ -184,16 +184,21 @@ void LevelScreen::saveWorldPreview() {
void LevelScreen::updateHotkeys() {
auto& settings = engine.getSettings();
if (input.jpressed(Keycode::O)) {
settings.graphics.frustumCulling.toggle();
}
if (input.jpressed(Keycode::F1)) {
hudVisible = !hudVisible;
}
if (input.jpressed(Keycode::F3)) {
debug = !debug;
hud->setDebug(debug);
renderer->setDebug(debug);
if (!input.pressed(Keycode::LEFT_CONTROL)) {
if (input.jpressed(Keycode::F3)) {
debug = !debug;
hud->setDebug(debug);
renderer->setDebug(debug);
}
} else if (input.pressed(Keycode::F3)) {
if (input.jpressed(Keycode::L)) {
renderer->toggleLightsDebug();
} else if (input.jpressed(Keycode::O)) {
settings.graphics.frustumCulling.toggle();
}
}
}

View File

@ -118,6 +118,7 @@ void WorldRenderer::setupWorldShader(
shader.uniform1f("u_gamma", settings.graphics.gamma.get());
shader.uniform1f("u_fogFactor", fogFactor);
shader.uniform1f("u_fogCurve", settings.graphics.fogCurve.get());
shader.uniform1i("u_debugLights", lightsDebug);
shader.uniform1f("u_weatherFogOpacity", weather.fogOpacity());
shader.uniform1f("u_weatherFogDencity", weather.fogDencity());
shader.uniform1f("u_weatherFogCurve", weather.fogCurve());
@ -442,6 +443,10 @@ void WorldRenderer::setDebug(bool flag) {
debug = flag;
}
void WorldRenderer::toggleLightsDebug() {
lightsDebug = !lightsDebug;
}
Weather& WorldRenderer::getWeather() {
return weather;
}

View File

@ -48,6 +48,7 @@ class WorldRenderer {
float timer = 0.0f;
bool debug = false;
bool lightsDebug = false;
/// @brief Render block selection lines
void renderBlockSelection();
@ -107,5 +108,7 @@ public:
void setDebug(bool flag);
void toggleLightsDebug();
Weather& getWeather();
};

View File

@ -22,8 +22,6 @@ struct ChunkVertex {
{{}, 0}};
};
/// @brief Chunk mesh vertex attributes
template<typename VertexStructure>
class Mesh;