diff --git a/src/RuntimeModuleManager.cc b/src/RuntimeModuleManager.cc index 57bbea9..de1572f 100644 --- a/src/RuntimeModuleManager.cc +++ b/src/RuntimeModuleManager.cc @@ -79,7 +79,7 @@ void RuntimeModuleManager::Update(float dt) { } // We need to sleep to make sure we load the new files - usleep(100000); + usleep(200000); } for (int i = 0; i < mModules.size(); i++) { diff --git a/src/modules/RenderModule.cc b/src/modules/RenderModule.cc index 7da0406..7d9173d 100644 --- a/src/modules/RenderModule.cc +++ b/src/modules/RenderModule.cc @@ -681,7 +681,7 @@ void Renderer::setupShaders() { uint8_t grid_color_border [4] = {255, 255, 255, 255}; // uint8_t grid_color_border [4] = {0, 0, 0, 0}; uint8_t grid_color_0[4] = {192, 192, 192, 255}; - uint8_t grid_color_1[4] = {96, 96, 96, 255}; + uint8_t grid_color_1[4] = {128, 128, 128, 255}; uint8_t* texture_data = NULL; texture_data = new uint8_t[grid_size * grid_size * 4]; for (int i = 0; i < grid_size; i++) { @@ -1061,9 +1061,9 @@ void Renderer::paintGL() { bgfx::setUniform(lights[i].u_shadowMapParams, &shadow_map_params); float eye[3]; - eye[0] = -lights[i].pos[0]; - eye[1] = -lights[i].pos[1]; - eye[2] = -lights[0].pos[2]; + eye[0] = lights[i].pos[0]; + eye[1] = lights[i].pos[1]; + eye[2] = lights[0].pos[2]; float at[3]; at[0] = - lights[i].pos[0] + lights[i].dir[0]; @@ -1072,9 +1072,9 @@ void Renderer::paintGL() { bx::mtxLookAt(lights[i].mtxView, eye, at); - lights[i].area = 2.5f; + lights[i].area = 20.0f; lights[i].near = 0.f; - lights[i].far = 5.f; + lights[i].far = 40.f; // bx::mtxProj(lightProj, 20.0f, 1., 5.f, 10.0f); @@ -1258,6 +1258,7 @@ void Renderer::paintGL() { } } + // Advance to next frame. Rendering thread will be kicked to // process submitted rendering primitives. bgfx::frame(); @@ -1269,6 +1270,23 @@ void Renderer::paintGL() { inputState.mouseScroll, width, height); + + ImGui::SetNextWindowSize (ImVec2(400.f, 100.0f), ImGuiSetCond_Once); + ImGui::SetNextWindowPos (ImVec2(10.f, 300.0f), ImGuiSetCond_Once); + + ImGui::Begin("Render Settings"); + + ImGui::Checkbox("Draw Debug", &drawDebug); + + for (int i = 0; i < lights.size(); i++) { + ImGui::SliderFloat("Bias", + &lights[i].shadowMapBias, + 0.0001f, + 0.10f + ); + } + + ImGui::End(); } Entity* Renderer::createEntity() { diff --git a/src/modules/RenderModule.h b/src/modules/RenderModule.h index d843967..4ce7606 100644 --- a/src/modules/RenderModule.h +++ b/src/modules/RenderModule.h @@ -106,7 +106,7 @@ struct Light { u_lightMtx (BGFX_INVALID_HANDLE), shadowMapTexture (BGFX_INVALID_HANDLE), shadowMapFB (BGFX_INVALID_HANDLE), - pos {1.f, 1.f, 1.f}, + pos {10.f, 10.f, 10.f}, dir {-1.f, -1.f, -1.f}, mtxView { 1.f, 0.f, 0.f, 0.f, @@ -126,9 +126,9 @@ struct Light { 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f }, - shadowMapBias (0.0001f), - shadowMapSize (1024), - near (-100.f), + shadowMapBias (0.004f), + shadowMapSize (2048), + near (0.1f), far (100.f), area (10.f), enabled (false) diff --git a/src/modules/TestModule.cc b/src/modules/TestModule.cc index 37b2abb..0cea096 100644 --- a/src/modules/TestModule.cc +++ b/src/modules/TestModule.cc @@ -273,7 +273,7 @@ static void module_reload(struct module_state *state) { cout << "Creating render entity ... success!" << endl; cout << "Creating render entity mesh ..." << endl; - state->character->entity->mesh = bgfxutils::createUVSphere (25, 25); + state->character->entity->mesh = bgfxutils::createUVSphere (45, 45); cout << "Creating render entity mesh ... success!" << endl; glfwSetScrollCallback (gWindow, mouse_scroll_callback);