#Depth testing between rasterized meshes and traced voxels

21 messages · Page 1 of 1 (latest)

bold cloud
#

I've been trying to figure this out for a while now, but still have been unable to figure out how to get the depth from my raytraced voxels (via dda) to match up with the depth of rasterized objects so i can accurately determine which one is closer to the camera for rendering.
The image shows the issue, the depth of the rasterized grey cube doesnt line up with the depth of the wood / leaves, causing it to render the cube behind those voxels when it really should be rendered infront of them.
The process to create the ray directions uses the same projection matrix that the models are rendered with, so im not sure why this accuracy issue exists. Its also worth mentioning that the accuray gets better and worse depending on how close to a certain edge of the screen it is; that edge changes based on the direction you look at the mesh from.

real delta
#

Sounds like you're not taking perspective divide into account somewhere

bold cloud
#

ive been multiplying it

#

and as for the traced depth it has to use the perspective properly because i mean thats how the ray directions are made

#

although i did just notice that for the tracing i invert the proj and view matrixes

#

but not for the rasterization

#

if i do invert both though then the rasterized stuff doesnt render

#

and if i dont invert the tracing stuff then it looks like this

#

so i think that maybe what i had is right for the perspective stuff

bold cloud
#

here i have two planes rendered in the same spot, with a checkerboard to render either the raster depth or traced depth

#

the brighter pixels are the rasterized ones

bold cloud
#

maybe it is just an issue with the view or projection matrixes overall actually

#

at this angle the depth does line up perfectly on that cube on the left

#

note how at the bottom right the "hand" is barely on screen

#

if i face the opposite direction this is also true except the hand moved way more up onto the screen (the hand is at a static position relative to the camera so it should never move)

#

and if i look at an in-between but still axis-aligned angle the depths mismatch on surfaces facing me, but not on ones not facing me

#

so def. something weird going on

#

wait i think i found the issue

#

the normal of the raytraced surfaces is impacting depth (note the sudden change at the edge there)