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

[#106] Add options for object rotation to stress test motion blur under complex movement

parent 3d19a3cd
No related branches found
No related tags found
1 merge request!89Resolve "Indirect Dispatch"
Pipeline #26820 passed
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
#extension GL_ARB_separate_shader_objects : enable #extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec3 passNormal; layout(location = 0) in vec3 passNormal;
layout(location = 1) in vec3 passPos; layout(location = 1) in vec3 passPosObject;
layout(location = 0) out vec3 outColor; layout(location = 0) out vec3 outColor;
void main() { void main() {
vec3 albedo = vec3(sin(passPos.y * 100) * 0.5 + 0.5); vec3 albedo = vec3(sin(passPosObject.y * 100) * 0.5 + 0.5);
vec3 N = normalize(passNormal); vec3 N = normalize(passNormal);
float light = max(N.y * 0.5 + 0.5, 0); float light = max(N.y * 0.5 + 0.5, 0);
outColor = light * albedo; outColor = light * albedo;
} }
\ No newline at end of file
...@@ -5,14 +5,15 @@ layout(location = 0) in vec3 inPosition; ...@@ -5,14 +5,15 @@ layout(location = 0) in vec3 inPosition;
layout(location = 1) in vec3 inNormal; layout(location = 1) in vec3 inNormal;
layout(location = 0) out vec3 passNormal; layout(location = 0) out vec3 passNormal;
layout(location = 1) out vec3 passPos; layout(location = 1) out vec3 passPosObject;
layout( push_constant ) uniform constants{ layout( push_constant ) uniform constants{
mat4 mvp; mat4 mvp;
mat4 model;
}; };
void main() { void main() {
gl_Position = mvp * vec4(inPosition, 1.0); gl_Position = mvp * vec4(inPosition, 1.0);
passNormal = inNormal; passNormal = (model * vec4(inNormal, 0)).xyz;
passPos = inPosition; passPosObject = inPosition;
} }
\ No newline at end of file
...@@ -92,8 +92,10 @@ void App::run() { ...@@ -92,8 +92,10 @@ void App::run() {
eMotionVectorMode motionBlurMotionMode = eMotionVectorMode::MaxTileNeighbourhood; eMotionVectorMode motionBlurMotionMode = eMotionVectorMode::MaxTileNeighbourhood;
float objectVerticalSpeed = 5; float objectVerticalSpeed = 5;
float objectAmplitude = 1; float objectAmplitude = 0;
float objectMeanHeight = 1; float objectMeanHeight = 1;
float objectRotationSpeedX = 5;
float objectRotationSpeedY = 5;
int cameraShutterSpeedInverse = 24; int cameraShutterSpeedInverse = 24;
float motionVectorVisualisationRange = 0.008; float motionVectorVisualisationRange = 0.008;
...@@ -116,7 +118,10 @@ void App::run() { ...@@ -116,7 +118,10 @@ void App::run() {
sphere.meshResources = m_cubeMesh; sphere.meshResources = m_cubeMesh;
sphere.modelMatrixUpdate = [&](float time, Object& obj) { sphere.modelMatrixUpdate = [&](float time, Object& obj) {
const float currentHeight = objectMeanHeight + objectAmplitude * glm::sin(time * objectVerticalSpeed); const float currentHeight = objectMeanHeight + objectAmplitude * glm::sin(time * objectVerticalSpeed);
obj.modelMatrix = glm::translate(glm::mat4(1), glm::vec3(0, currentHeight, 0)); const glm::mat4 translation = glm::translate(glm::mat4(1), glm::vec3(0, currentHeight, 0));
const glm::mat4 rotationX = glm::rotate(glm::mat4(1), objectRotationSpeedX * time, glm::vec3(1, 0, 0));
const glm::mat4 rotationY = glm::rotate(glm::mat4(1), objectRotationSpeedY * time, glm::vec3(0, 1, 0));
obj.modelMatrix = translation * rotationX * rotationY;
}; };
sceneObjects.push_back(sphere); sceneObjects.push_back(sphere);
...@@ -203,9 +208,10 @@ void App::run() { ...@@ -203,9 +208,10 @@ void App::run() {
m_renderTargets.colorBuffer, m_renderTargets.colorBuffer,
m_renderTargets.depthBuffer }; m_renderTargets.depthBuffer };
vkcv::PushConstants meshPushConstants(sizeof(glm::mat4)); vkcv::PushConstants meshPushConstants(2 * sizeof(glm::mat4));
for (const Object& obj : sceneObjects) { for (const Object& obj : sceneObjects) {
meshPushConstants.appendDrawcall(obj.mvp); glm::mat4 matrices[2] = { obj.mvp, obj.modelMatrix };
meshPushConstants.appendDrawcall(matrices);
} }
m_core.recordDrawcallsToCmdStream( m_core.recordDrawcallsToCmdStream(
...@@ -322,6 +328,8 @@ void App::run() { ...@@ -322,6 +328,8 @@ void App::run() {
ImGui::InputFloat("Object movement speed", &objectVerticalSpeed); ImGui::InputFloat("Object movement speed", &objectVerticalSpeed);
ImGui::InputFloat("Object movement amplitude", &objectAmplitude); ImGui::InputFloat("Object movement amplitude", &objectAmplitude);
ImGui::InputFloat("Object mean height", &objectMeanHeight); ImGui::InputFloat("Object mean height", &objectMeanHeight);
ImGui::InputFloat("Object rotation speed X", &objectRotationSpeedX);
ImGui::InputFloat("Object rotation speed Y", &objectRotationSpeedY);
ImGui::End(); ImGui::End();
gui.endGUI(); gui.endGUI();
......
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