Skip to content

Commit

Permalink
anything over 1.2 disables fog
Browse files Browse the repository at this point in the history
  • Loading branch information
Kade-github committed Apr 16, 2024
1 parent 6568b80 commit b1f39ac
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion Assets/Shaders/frag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@ void main()
float d = distance(CameraPos, Position);
float fogFactor = getFogFactor(d);

FragColor = mix(color, vec4(FogColor, 1.0), fogFactor);
if (FogFar < 1000)
FragColor = mix(color, vec4(FogColor, 1.0), fogFactor);
else
FragColor = color;
}
3 changes: 3 additions & 0 deletions src/Game/Scenes/Gameplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ void Gameplay::Draw()

int fog = (camera->cameraFar / 2) * Settings::instance->fogDistance;

if (Settings::instance->fogDistance >= 1.19)
fog = 10000;

Game::instance->shader->SetUniform3f("CameraPos", camera->position.x, camera->position.y, camera->position.z);
Game::instance->shader->SetUniform3f("FogColor", LightingManager::GetInstance()->sun.color.x, LightingManager::GetInstance()->sun.color.y, LightingManager::GetInstance()->sun.color.z);
Game::instance->shader->SetUniform1f("FogFar", fog);
Expand Down
6 changes: 3 additions & 3 deletions src/Game/Scenes/SettingsMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void SettingsMenu::Create()

c2d->AddObject(renderDistance);

float fogDistancePerc = Settings::instance->fogDistance;
float fogDistancePerc = Settings::instance->fogDistance / 1.2f;

if (fogDistancePerc < 0.1f)
fogDistancePerc = 0.1f;
Expand All @@ -84,7 +84,7 @@ void SettingsMenu::Create()

fogDistance = new DragBar(glm::vec3(0, 0, 0), "Fog Distance", fogDistancePerc);

fogDistance->max = 1;
fogDistance->max = 1.2;

fogDistance->position = glm::vec3(c2d->_w / 2, c2d->_h / 2 - 200, 0);

Expand Down Expand Up @@ -124,7 +124,7 @@ void SettingsMenu::Draw()

Settings::instance->fov = fov->value * 140;
Settings::instance->renderDistance = renderDistance->value;
Settings::instance->fogDistance = fogDistance->value;
Settings::instance->fogDistance = fogDistance->value * 1.2;

Scene::Draw();
}
Expand Down

0 comments on commit b1f39ac

Please sign in to comment.