Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect depth buffer check in depth buffer test #48

Closed
icoderaven opened this issue Jan 18, 2019 · 2 comments
Closed

Incorrect depth buffer check in depth buffer test #48

icoderaven opened this issue Jan 18, 2019 · 2 comments

Comments

@icoderaven
Copy link
Contributor

icoderaven commented Jan 18, 2019

The current depth buffer test compares the linear depth for a particular pixel with the raybox intersection distance along the ray.

This is incorrect, and should be comparing the linear depth against the distance along the ray projected to the camera z axis (assuming that scene depth buffer is equivalent to a depth image transformed by the projection matrix to normalized 0..1 values)

i.e., instead of

if (t.x > getLinearDepth(SCN_DBUF) )

it should be something along the lines of

if (t.x * dot(scn.dir_vec, dir) > getLinearDepth(SCN_DBUF) )

where for convenience I have exposed the camera z in world frame as scn.dir_vec
Of possible relevance to @drmateo and #44

@icoderaven
Copy link
Contributor Author

Also, the ray direction should be normalized within the rayCast() method.

NBickford-NV added a commit that referenced this issue Jul 10, 2020
…rint!

Previously, ray directions were normalized, and then multiplied by the
application-to-voxel matrix. This meant that SetSteps specified how far the ray
should march at each step in the application's coordinate space, instead of
in terms of voxels!

As a result, `SetSteps` now specifies how far the ray should march at each step
in terms of voxels. This commit updates all of the samples to fix this (which
fixes an artifact visible on g3DPrint when using a high voxel resolution plus
the surface visualization mode would result in undersampling), which improves
rendering performance.

Also:

- Fixes ray-depth buffer intersection (#48, #95) without adding a new variable
to the GVDB scene or info struct, by adding a new function, `getRayDepthBufferMax`.

- Hopefully correct ray transformation in volume shaders (#89).

- Fixes a bug where RotateTZYXS was multiplying on the left instead of on the
right by the scaling matrix.

- Renames `SCN_PSTEP`, `SCN_SSTEP`, and `SCN_FSTEP` to use more descriptive
names.

- Adds an `m_draw_topology` flag to `gInteractiveOptix` to choose whether to
draw topology at compile-time

- Adjusted volume translation in `gInteractiveOptix` and extinction to
account for scale change

- Includes minor formatting changes
@NBickford-NV
Copy link
Collaborator

Hi icoderaven,

I've just pushed commit 9ffc6b7, which should fix this by adding a new function, getRayDepthBufferMax, to cuda_gvdb_raycast.cuh. Essentially, this function computes getLinearDepth(SCN_DBUF)/dot(scn.dir_vec, dir), except it turns out we can use the transformation matrix to avoid having to store dir_vec. However, I might add something like dir_vec in the future to avoid the matrix-vector multiplication in getRayDepthBufferMax as an optimization.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants