Skip to content

Commit

Permalink
[Skybox] Stars now follow sky rotation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Unarelith committed Jul 17, 2020
1 parent 1ded0d9 commit 1e6bd6a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions source/client/graphics/Skybox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,18 @@ void Skybox::loadSky(const Sky &sky) {
auto &star = m_stars.emplace_back();
star.setColor(gk::Color{0, 0, 0, 0});
star.setSize(stars.size, stars.size);
star.setPosition(650 * ((rand() % 2) * 2 - 1), (rand() % 500) * 2 - 500, (rand() % 500) * 2 - 500);

glm::vec3 v{rand() % 256, rand() % 256, rand() % 256};
v = glm::normalize(v);
v *= 600 * (rand() % 2 * 2 - 1);
star.setPosition(v.x, v.y, v.z);
// star.setPosition(650 * ((rand() % 2) * 2 - 1), (rand() % 500) * 2 - 500, (rand() % 500) * 2 - 500);

star.setRotationOffset(rand() % GameTime::dayLength);
star.setRotationAxis({rand() % 100 / 100.f, rand() % 100 / 100.f, rand() % 100 / 100.f});
star.setRotationSpeed(sky.daylightCycleSpeed());
star.setRotationAxis({0, 1, 0});
// Maybe sometimes stars could have a random axis?
// star.setRotationAxis({rand() % 100 / 100.f, rand() % 100 / 100.f, rand() % 100 / 100.f});
}
}

Expand Down Expand Up @@ -108,8 +116,6 @@ void Skybox::draw(gk::RenderTarget &target, gk::RenderStates states) const {
target.draw(m_moon, states);

if (Config::isStarRenderingEnabled && skyColor != starColor) {
glDisable(GL_CULL_FACE);

for (auto &it : m_stars)
target.draw(it, states);
}
Expand Down

0 comments on commit 1e6bd6a

Please sign in to comment.