Compute raytracing basic camera movement

This commit is contained in:
saschawillems 2016-09-02 20:13:12 +02:00
parent 26c39e9c67
commit 5e3b0f4b75
2 changed files with 9 additions and 2 deletions

View file

@ -206,7 +206,7 @@ vec3 renderScene(inout vec3 rayO, inout vec3 rayD, inout int id)
normal = sphereNormal(pos, spheres[i]); normal = sphereNormal(pos, spheres[i]);
float diffuse = lightDiffuse(normal, lightVec); float diffuse = lightDiffuse(normal, lightVec);
float specular = lightSpecular(normal, lightVec, spheres[i].specular); float specular = lightSpecular(normal, lightVec, spheres[i].specular);
color = diffuse * spheres[i].diffuse.rgb + specular; color = diffuse * spheres[i].diffuse + specular;
} }
} }

View file

@ -97,6 +97,13 @@ public:
compute.ubo.aspectRatio = (float)width / (float)height; compute.ubo.aspectRatio = (float)width / (float)height;
paused = true; paused = true;
timerSpeed *= 0.5f; timerSpeed *= 0.5f;
camera.type = Camera::CameraType::lookat;
camera.setPerspective(60.0f, (float)width / (float)height, 0.1f, 512.0f);
camera.setRotation(glm::vec3(0.0f, 0.0f, 0.0f));
camera.setTranslation(glm::vec3(0.0f, 0.0f, -4.0f));
camera.rotationSpeed = 0.0f;
camera.movementSpeed = 2.5f;
} }
~VulkanExample() ~VulkanExample()
@ -670,7 +677,7 @@ public:
compute.ubo.lightPos.y = 0.0f + sin(glm::radians(timer * 360.0f)) * 2.0f; compute.ubo.lightPos.y = 0.0f + sin(glm::radians(timer * 360.0f)) * 2.0f;
compute.ubo.lightPos.z = 0.0f + cos(glm::radians(timer * 360.0f)) * 2.0f; compute.ubo.lightPos.z = 0.0f + cos(glm::radians(timer * 360.0f)) * 2.0f;
compute.ubo.lightPos.y = 2.0f; compute.ubo.camera.pos = camera.position * -1.0f;
VK_CHECK_RESULT(compute.uniformBuffer.map()); VK_CHECK_RESULT(compute.uniformBuffer.map());
memcpy(compute.uniformBuffer.mapped, &compute.ubo, sizeof(compute.ubo)); memcpy(compute.uniformBuffer.mapped, &compute.ubo, sizeof(compute.ubo));