Skip to content

Commit

Permalink
[Skybox] Small tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Unarelith committed Jul 14, 2020
1 parent 10cac46 commit 1160813
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion source/client/graphics/CelestialObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void CelestialObject::updateVertexBuffer() const {
}

void CelestialObject::draw(gk::RenderTarget &target, gk::RenderStates states) const {
states.transform.rotate(-fmod(gk::GameClock::getInstance().getTicks() * 4 / 1000.f, 360), {0, 1, 0});
states.transform.rotate(-fmod(gk::GameClock::getInstance().getTicks() * 1.f / 1000.f, 360), {0, 1, 0});
states.transform *= getTransform();

states.vertexAttributes = VertexAttribute::All;
Expand Down
8 changes: 4 additions & 4 deletions source/client/graphics/Skybox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ Skybox::Skybox(gk::Camera &camera) : m_camera(camera) {
m_shader.linkProgram();

m_sun.setColor(gk::Color::Yellow);
m_sun.setPosition(150, -10, -10);
m_sun.setPosition(300, -10, -10);

m_moon.setColor(gk::Color::White);
m_moon.setPosition(-150, -10, -10);
m_moon.setColor(gk::Color{240, 240, 240});
m_moon.setPosition(-300, -10, -10);
}

void Skybox::draw(gk::RenderTarget &target, gk::RenderStates states) const {
states.shader = &m_shader;

// Subtract the camera position - see comment in ClientWorld::draw()
const gk::Vector3d &cameraPosition = m_camera.getDPosition();
states.transform.translate(cameraPosition.x, cameraPosition.y, cameraPosition.z);
states.transform.translate(cameraPosition.x, cameraPosition.y, cameraPosition.z - 50);

target.draw(m_sun, states);
target.draw(m_moon, states);
Expand Down
4 changes: 2 additions & 2 deletions source/client/states/GameState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ GameState::GameState()
m_clientCommandHandler.setupCallbacks();

m_camera.setAspectRatio((float)Config::screenWidth / Config::screenHeight);
m_camera.setFarClippingPlane(10000.0f);
m_camera.setFarClippingPlane(1000.0f);

m_world.setClient(m_clientCommandHandler);
m_world.setCamera(m_player.camera());
Expand Down Expand Up @@ -201,7 +201,7 @@ void GameState::onGuiScaleChanged(const GuiScaleChangedEvent &event) {
}

void GameState::draw(gk::RenderTarget &target, gk::RenderStates states) const {
float time = std::fmod(gk::GameClock::getInstance().getTicks() * 4.f / 1000.f, 360.f) / 360.f;
float time = std::fmod(gk::GameClock::getInstance().getTicks() * 1.f / 1000.f, 360.f) / 360.f;
if (m_world.sky()) {
const float pi = 3.1415927f;
float sunlight = std::clamp(0.5f + std::sin(2 * pi * time) * 2.0f, 0.0f, 1.0f);
Expand Down

0 comments on commit 1160813

Please sign in to comment.