diff options
Diffstat (limited to 'c2.cpp')
-rw-r--r-- | c2.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
@@ -2,6 +2,7 @@ #include "camera.hpp" #include "debugdraw.hpp" #include "editor.hpp" +#include "lighting.hpp" #include "model.hpp" #include "physics.hpp" #include "scene.hpp" @@ -639,6 +640,7 @@ struct C2 : public App { Texture_Id default_texture; Entity_Id monkey, monkey2, box, floor; Model_Scene scene; + Lighting lighting; Orbit_Cam camera; Fullscreen_Quad quad; Sky sky; @@ -718,6 +720,7 @@ struct C2 : public App { ui->layout(w, h); fps_label = ui->create_element<UI::Label>(ui->root, ""); scene.init(&scene_arena, 32, clamped_linear); + lighting.init(dev); sky.init(dev, &assets); eprobe.init(dev, &assets, 256); tonemap.init(dev, &assets); @@ -739,6 +742,13 @@ struct C2 : public App { ); } { + auto sun = world->create_entity(); + auto [light] = world->add<Sun_Light>(sun); + light.colour = v3f(1.0f); + light.dir = v3f(0.57f, 0.57f, 0.57f); + light.brightness = 1.0f; + } + { box_col = make_box(&asset_arena, v3f(1.0f, 1.0f, 1.0f)); floor_col = make_box(&asset_arena, v3f(10.0f, 0.1f, 10.0f)); box = world->create_entity(); @@ -752,9 +762,13 @@ struct C2 : public App { ); floor = world->create_entity(); - auto [transf, rbf] = world->add<Transform, Rigidbody>(floor); + auto [transf, rbf, modf] = world->add<Transform, Rigidbody, C_Model>(floor); transf.mat = m4f::identity(); rbf.init(floor_col, v3f(0.0f), quat::identity(), 0.0f); + modf.i = scene.instantiate( + dev, + (Model*)assets.load("scene.mdl") + ); } world->get<Transform>(monkey).mat = m4f::translate( m4f::identity(), @@ -877,13 +891,14 @@ struct C2 : public App { camera.asp = (float)bb.w / (float)bb.h; camera.update_orbit(*this); camera.update(); - update_scene(scene, dev, camera, *world); + lighting.update(dev, ctx, *world); + update_scene(scene, dev, lighting, camera, *world); ctx.debug_push("scene"); ctx.debug_push("depth prepass"); - scene.render(dev, &frame_arena, depth_prepass, 0, clamped_linear); + scene.render(dev, &frame_arena, depth_prepass, &lighting, 0, clamped_linear); ctx.debug_pop(); ctx.debug_push("forward"); - scene.render(dev, &frame_arena, pass2, eprobe.get_cubemap(), clamped_linear); + scene.render(dev, &frame_arena, pass2, &lighting, eprobe.get_cubemap(), clamped_linear); ctx.debug_pop(); ctx.debug_pop(); @@ -984,6 +999,7 @@ struct C2 : public App { quad.destroy(dev); scene.destroy(dev); sky.destroy(dev); + lighting.destroy(dev); lr.destroy(dev); eprobe.destroy(dev); tonemap.destroy(dev); |