z-depth element not rendering when antialiasing disabled

z-depth element not rendering when antialiasing disabled

futengda
Enthusiast Enthusiast
682 Views
5 Replies
Message 1 of 6

z-depth element not rendering when antialiasing disabled

futengda
Enthusiast
Enthusiast

I need to use the texture obtained from the z-depth renderElement for depth testing to perform some occlusion culling. For extreme cases, such as when the model is particularly small and occupies only a few pixels in the z-depth map, if anti-aliasing is enabled, its grayscale value will be "polluted," making it hard to make correct judgments. However, the problem is, when I try to turn off anti-aliasing, the z-depth simply does not render at all? 

 

I'm using Max 2023.3.4

 

20240722-162738.gif

 

 

0 Likes
Accepted solutions (1)
683 Views
5 Replies
Replies (5)
Message 2 of 6

Diffus3d
Advisor
Advisor
Accepted solution

I messed around for a while trying to find a way to trick it, but failed. I'm assuming you need to use scanline specifically. 

 

  • The filtering checkbox seems to have no effect, which isn't helpful.
  • The behavior seems to be different by renderer, so it must be a quirk with scanline specifically. 
  • Tried to find an AA method that let me set the value to 0 to try to trick it, but no. 
  • Tried to find a command that might let me do it but also failed.  
  • Tried disable all samplers checkbox, no dice.

You might have some luck with this if you are comfortable scripting, otherwise maybe the trick is to put the zdepth channel info in an output map and tweak the min / max value or possibly adjust the gamma.  If you could clip out the very top and bottom it might help. Otherwise, the answer is probably a programmatical version of compositing methods, perhaps this documentation can help, specifically GetPixels().


Best Regards,

0 Likes
Message 3 of 6

futengda
Enthusiast
Enthusiast

Thanks for the reply!

 

In fact, this is the problem I encountered while using MaxScript. Since I need to use a 16-bit depth map for high-precision judgments, the `getChannelAsMask` method mentioned in this link is not sufficient. Therefore, my approach is to use the Render API, along with `maxOps.GetCurRenderElementMgr.AddRenderElement zDepthElement`. In this process, I use the Render API's `renderElements:true` and `renderElementBitmaps:&reb` properties. Everything works perfectly until I encounter the antialiasing issue mentioned above. So, I tried adding the `antiAliasing:false` property in the Render API, but the resulting depth map turned out completely black. Then, I tried to replicate the Render API usage through the GUI, and found that the result was the same, as shown above.

 

the complete code is:

 

 

render camera:MyCam outputsize:[512,512] channels:#(#zDepth) \
    renderElements:true renderElementBitmaps:&reb renderhiddenobjects:false vfb:off  \
    antiAliasing:false -- !!!NOTE: this will make the depthmap completely black

 

 

So, I believe this issue is common and unrelated to whether it's through the GUI or a script.

 

Finally, based on the current situation, the only solution for me at the moment is to increase the resolution of the output size.
0 Likes
Message 4 of 6

Diffus3d
Advisor
Advisor

It's a bit beyond me I'm afraid.  Problem turned out to be much trickier than anticipated.  You might have more luck in the programming subforum.  Best of luck, sorry things didn't pan out yet.  

 

Best Regards,

0 Likes
Message 5 of 6

futengda
Enthusiast
Enthusiast
Thank you, but how can I move this issue to another board?
0 Likes
Message 6 of 6

Diffus3d
Advisor
Advisor

You can maybe report your own thread and ask the moderators.  Not sure if that's the proper way, but I don't have the user level to move a thread.  

 

Best Regards,

0 Likes