Archived
1
Fork 0

Add configurable camera near/far

This commit is contained in:
Joshua Goins 2018-11-05 21:07:48 -05:00
parent 6d2fd5caaa
commit d8d58588c6
3 changed files with 3 additions and 2 deletions

View file

@ -7,4 +7,5 @@ public:
glm::vec3 position = glm::vec3(0), target = glm::vec3(0);
float focusDistance = 0.0f;
float aperture = 0.0f;
float near = 0.1f, far = 100.0f;
};

View file

@ -58,7 +58,7 @@ void DoFPass::render(VkCommandBuffer commandBuffer, Camera& camera, RenderTarget
glm::vec4 dpack;
dpack[0] = camera.aperture;
dpack[1] = (100 - camera.focusDistance) / 100.0f;
dpack[1] = (camera.far - camera.focusDistance) / camera.far;
dpack[2] = target->extent.width / 2;
dpack[3] = target->extent.height / 2;

View file

@ -65,7 +65,7 @@ void WorldPass::render(VkCommandBuffer commandBuffer, World& world, Camera& came
for(const auto& mesh : world.meshes) {
glm::mat4 mvp;
mvp = glm::perspective(glm::radians(75.0f), (float)target->extent.width / target->extent.height, 0.1f, 100.0f);
mvp = glm::perspective(glm::radians(75.0f), (float)target->extent.width / target->extent.height, camera.near, camera.far);
mvp *= glm::lookAt(camera.position, camera.target, glm::vec3(0, -1, 0));
mvp = glm::translate(mvp, mesh->position);