Tweaked shadow map cascades and adaptively send the program to sleep to reach a specfied refresh rate
parent
e9ba7f77cc
commit
ce1a6ce9a4
|
@ -23,6 +23,7 @@ struct RuntimeModule {
|
||||||
struct RuntimeModuleManager {
|
struct RuntimeModuleManager {
|
||||||
std::vector<RuntimeModule*> mModules;
|
std::vector<RuntimeModule*> mModules;
|
||||||
int mNumUpdatesSinceLastModuleChange = 0;
|
int mNumUpdatesSinceLastModuleChange = 0;
|
||||||
|
int mTargetFPS = 30;
|
||||||
|
|
||||||
void RegisterModule(const char* name);
|
void RegisterModule(const char* name);
|
||||||
void UnregisterModules();
|
void UnregisterModules();
|
||||||
|
|
|
@ -231,7 +231,11 @@ int main(void)
|
||||||
|
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
|
|
||||||
usleep(16000);
|
// Send the application to sleep if we have some time left for this frame
|
||||||
|
double frame_target_time = 1.0 / module_manager.mTargetFPS;
|
||||||
|
if (frame_delta_time < frame_target_time) {
|
||||||
|
usleep ((frame_target_time - frame_delta_time) * 1000000 * 0.98);
|
||||||
|
}
|
||||||
|
|
||||||
if (glfwGetKey(gWindow, GLFW_KEY_F5) == GLFW_PRESS) {
|
if (glfwGetKey(gWindow, GLFW_KEY_F5) == GLFW_PRESS) {
|
||||||
gFileModificationObserver->Update();
|
gFileModificationObserver->Update();
|
||||||
|
|
|
@ -280,7 +280,10 @@ void Light::UpdateSplits(const Camera& camera) {
|
||||||
assert(camera.mIsOrthographic == false);
|
assert(camera.mIsOrthographic == false);
|
||||||
|
|
||||||
float near = camera.mNear;
|
float near = camera.mNear;
|
||||||
float far = camera.mFar;
|
// Clamp the far plane of the camera so that we only
|
||||||
|
// create shadow maps for things that are relatively near
|
||||||
|
// the camera.
|
||||||
|
float far = fmin(camera.mFar, 10.0f);
|
||||||
float length = far - near;
|
float length = far - near;
|
||||||
float split_near = near;
|
float split_near = near;
|
||||||
float aspect = camera.mWidth / camera.mHeight;
|
float aspect = camera.mWidth / camera.mHeight;
|
||||||
|
@ -296,8 +299,8 @@ void Light::UpdateSplits(const Camera& camera) {
|
||||||
Matrix44f light_matrix_inv = light_matrix.inverse();
|
Matrix44f light_matrix_inv = light_matrix.inverse();
|
||||||
|
|
||||||
mShadowSplits[0] = near;
|
mShadowSplits[0] = near;
|
||||||
mShadowSplits[1] = near + length * 0.02;
|
mShadowSplits[1] = near + length * 0.1;
|
||||||
mShadowSplits[2] = near + length * 0.2;
|
mShadowSplits[2] = near + length * 0.25;
|
||||||
mShadowSplits[3] = far;
|
mShadowSplits[3] = far;
|
||||||
|
|
||||||
for (int i = 0; i < cNumSplits; ++i) {
|
for (int i = 0; i < cNumSplits; ++i) {
|
||||||
|
|
Loading…
Reference in New Issue