Skip to content

Commit

Permalink
fix focal plane edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
fbxiang committed May 20, 2024
1 parent 1e3233d commit 6b6d61d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions vulkan_shader/rt/camera.rgen
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ void main() {
vec3 csFocusOrigin = csNear.xyz + vec3(ax, ay, 0.0);
vec3 csFocusDir = csFocusPoint - csFocusOrigin;

// avoid shooting rays backwards
if (csFocusDir.z != 0) {
csFocusDir /= -csFocusDir.z;
}

vec4 origin = cameraBuffer.viewMatrixInverse * vec4(csFocusOrigin, 1.0);
vec4 direction = cameraBuffer.viewMatrixInverse * vec4(csFocusDir, 0.0);

Expand Down

0 comments on commit 6b6d61d

Please sign in to comment.