Commit 1bfdaddc authored by Georg Schaefer's avatar Georg Schaefer
Browse files

add universe rotation

parent 26cd597e
......@@ -8,9 +8,10 @@ out float _size_;
out vec3 _color_;
uniform mat4 view;
uniform mat4 model;
void main() {
vec4 position = view * vec4(_position, 1.f);
vec4 position = view * model * vec4(_position, 1.f);
gl_Position = position;
_size_ = _size;
_color_ = _color;
......
......@@ -153,7 +153,7 @@ namespace gdw {
void render_navMesh(camera_component &camera);
void render_final_image();
void generate_starfield();
void render_starfield(camera_component& camera);
void render_starfield(float delta_time, camera_component& camera);
void register_component(camera_component* component);
......
......@@ -330,7 +330,7 @@ namespace gdw {
render_gbuffer(delta_time, *camera);
render_lights(*camera);
render_starfield(*camera);
render_starfield(delta_time, *camera);
render_non_opauqe_geometry(delta_time, *camera);
render_final_image();
if(engine_.getConfig().get("navDebug",true))
......@@ -830,7 +830,18 @@ namespace gdw {
starfield_size_ = stars.size();
}
void rendering_system::render_starfield(camera_component& camera) {
void rendering_system::render_starfield(float delta_time, camera_component& camera) {
static auto alpha = 0.f;
static const auto planet_acceleration_ = 0.005f;
static const auto planet_center = glm::vec3(80.f, -20.f, -100.f);
alpha += planet_acceleration_ * delta_time;
if (alpha >= 2.f * glm::pi<float>()) {
alpha = 0.f;
}
auto model = glm::translate(glm::mat4(1.f), planet_center);
model *= glm::toMat4(glm::angleAxis(alpha, glm::vec3(0.f, 1.f, 0.f)));
model *= glm::translate(glm::mat4(1.f), -planet_center);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
glEnable(GL_BLEND);
......@@ -839,6 +850,7 @@ namespace gdw {
starfield_program_.use();
starfield_program_.uniform("projection", false, camera.projection());
starfield_program_.uniform("view", false, camera.view());
starfield_program_.uniform("model", false, model);
starfield_program_.uniform("albedo_texture", 0);
star_texture_->bind(0);
glDrawArraysInstanced(GL_POINTS, 0, 1, starfield_size_);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment