Fix voxel rendering with orthographic camera #12629
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR corrects the calculation of the starting view ray in
VoxelFS.glsl
to account for orthographic cameras.In the usual perspective camera, the view rays all originate from the camera position and emanate in a direction that depends on the screen pixel. The camera in this case is perhaps best understood as an eye, with the screen pixels corresponding to different angular directions from a focal point.
In an orthographic camera, all view rays are exactly parallel, with the different pixels corresponding to different ray origins.
Along with the new logic in VoxelFS, code changes include:
cameraDirectionUv
inVoxelPrimitive
.viewDirWorld
property from thefsInput.voxel
struct, to facilitate pulling the ray calculation out into a helper function.Issue number and link
Resolves #11013
Testing plan
Load the "Voxels" Sandcastle, and use the projection picker to switch between perspective and orthographic cameras. The voxel should render correctly in both projections, with the globe partially visible through the semi-transparent voxels. The orthographic effect may be most obvious with the "Box" examples.
Author checklist
CONTRIBUTORS.md
CHANGES.md
with a short summary of my change