Skip to content
Snippets Groups Projects
Commit 598c348c authored by Alexander Gauggel's avatar Alexander Gauggel
Browse files

[#106] Add option to freeze frame for motion blur inspection

parent 9d0c4b86
No related branches found
No related tags found
1 merge request!89Resolve "Indirect Dispatch"
Pipeline #26825 passed
......@@ -96,6 +96,7 @@ void App::run() {
eMotionVectorVisualisationMode motionVectorVisualisationMode = eMotionVectorVisualisationMode::None;
eMotionVectorMode motionBlurMotionMode = eMotionVectorMode::MaxTileNeighbourhood;
bool freezeFrame = false;
float objectVerticalSpeed = 5;
float objectAmplitude = 0;
float objectMeanHeight = 1;
......@@ -104,10 +105,9 @@ void App::run() {
int cameraShutterSpeedInverse = 24;
float motionVectorVisualisationRange = 0.008;
glm::mat4 viewProjection = m_cameraManager.getActiveCamera().getMVP();
glm::mat4 viewProjectionPrevious = m_cameraManager.getActiveCamera().getMVP();
struct Object {
MeshResources meshResources;
glm::mat4 modelMatrix = glm::mat4(1.f);
......@@ -132,6 +132,8 @@ void App::run() {
};
sceneObjects.push_back(sphere);
auto frameEndTime = std::chrono::system_clock::now();
while (m_window.isWindowOpen()) {
vkcv::Window::pollEvents();
......@@ -151,21 +153,27 @@ void App::run() {
m_motionBlur.setResolution(m_windowWidth, m_windowHeight);
}
auto frameEndTime = std::chrono::system_clock::now();
if (!freezeFrame) {
frameEndTime = std::chrono::system_clock::now();
}
auto deltatime = std::chrono::duration_cast<std::chrono::microseconds>(frameEndTime - frameStartTime);
m_cameraManager.update(0.000001 * static_cast<double>(deltatime.count()));
const glm::mat4 viewProjection = m_cameraManager.getActiveCamera().getMVP();
const auto time = frameEndTime - appStartTime;
const float fCurrentTime = std::chrono::duration_cast<std::chrono::milliseconds>(time).count() * 0.001f;
// update matrices
for (Object& obj : sceneObjects) {
if (obj.modelMatrixUpdate) {
obj.modelMatrixUpdate(fCurrentTime, obj);
if (!freezeFrame) {
viewProjection = m_cameraManager.getActiveCamera().getMVP();
for (Object& obj : sceneObjects) {
if (obj.modelMatrixUpdate) {
obj.modelMatrixUpdate(fCurrentTime, obj);
}
obj.mvp = viewProjection * obj.modelMatrix;
}
obj.mvp = viewProjection * obj.modelMatrix;
}
const vkcv::CommandStreamHandle cmdStream = m_core.createCommandStream(vkcv::QueueType::Graphics);
......@@ -322,6 +330,8 @@ void App::run() {
gui.beginGUI();
ImGui::Begin("Settings");
ImGui::Checkbox("Freeze frame", &freezeFrame);
ImGui::Combo(
"Debug view",
reinterpret_cast<int*>(&motionVectorVisualisationMode),
......@@ -350,11 +360,13 @@ void App::run() {
m_core.endFrame();
viewProjectionPrevious = viewProjection;
frameStartTime = frameEndTime;
if (!freezeFrame) {
viewProjectionPrevious = viewProjection;
frameStartTime = frameEndTime;
for (Object& obj : sceneObjects) {
obj.mvpPrevious = obj.mvp;
for (Object& obj : sceneObjects) {
obj.mvpPrevious = obj.mvp;
}
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment