Skip to content
Discussion options

You must be logged in to vote

I use a ray starting from the screen, which is at Z=1 in screen space, pointing towards the infinite far plane at Z=0.

To do this, with Vec2 normalized device coordinates ndc, calculate the starting point with ndc.extend(1.) towards another point at ndc.extend(0.5) (halfway to infinity, hah), and use projection_matrix.inverse().project_point3(...) to take them from NDC space to camera space, and apply the camera transform to take them to world space.

You could also just compute a ray from the camera's origin through the point on the screen for perspective projections, but that won't work for orthographic projections.

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@HackerFoo
Comment options

@ghost
Comment options

@zwazel
Comment options

@tim-blackbird
Comment options

@zwazel
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants