<p>Lets assume, we have two depth maps with us and their corresponding color maps. Now, our task is to populate a final image that will be displayed.</p>
<p>Each pixel in the final image needs to be calculated from the given 4 maps - two color and corresponding depth. I am simply aiming to create a final image considering the occlusion of one depth map over the other.</p>
<p>My idea is to just compare the depth values and then take the color value from the map whichever is closer to the camera.</p>
<p>Is this a right way to approach the problem?</p>
<p>PS: This problem popped up as part of a hybrid rendering solution am working on - combining ray marching and rasterization to get triangles as well as metaballs working. So, one of the pair of maps above comes from rasterization and the other comes from ray marching.</p>

CC BY-SA 4.0
2021-04-06T14:39:24.117Z
BTW this is basically how your depth buffer works in your graphics card.  It's basically right, but you may want to also consider adding sub-pixel interpolation/filtering/sampling.  So that a diagonal line of near-white pixels over a far-black background can produce gray pixels to "antialias".
Wyck
CC BY-SA 4.0
2021-04-07T06:17:56.567Z
Interesting. I will try to integrate that.
Rohan Asokan
<raytracing><rendering><rasterizer><raymarching>
Combining two images based on their depth maps
Rohan Asokan
# Combining two images based on their depth maps

(Asked by: username_0 on 2021-04-06)

Lets assume, we have two depth maps with us and their corresponding color maps. Now, our task is to populate a final image that will be displayed.

Each pixel in the final image needs to be calculated from the given 4 maps - two color and corresponding depth. I am simply aiming to create a final image considering the occlusion of one depth map over the other.

My idea is to just compare the depth values and then take the color value from the map whichever is closer to the camera.

Is this a right way to approach the problem?

PS: This problem popped up as part of a hybrid rendering solution am working on - combining ray marching and rasterization to get triangles as well as metaballs working. So, one of the pair of maps above comes from rasterization and the other comes from ray marching.

**Tags:** raytracing, rendering, rasterizer, raymarching

> **Comments:**
> **username_1**: BTW this is basically how your depth buffer works in your graphics card.  It's basically right, but you may want to also consider adding sub-pixel interpolation/filtering/sampling.  So that a diagonal line of near-white pixels over a far-black background can produce gray pixels to "antialias".  
> **username_0**: Interesting. I will try to integrate that.  

---

## 0 answers

