Get the z buffer in 16 bit resolution

Get the z buffer in 16 bit resolution

Anonymous
Not applicable
972 Views
2 Replies
Message 1 of 3

Get the z buffer in 16 bit resolution

Anonymous
Not applicable

Hello,

I am fairly new to 3Ds max and are experimenting with the tool. 
I want to get a Z-Buffer image within a 16 bit resolution, from a camera view. I also used a clipping of the plane. The following maxscript is used:

 

 

 

--Set to 16Bit writing out
pngio.setType #gray16
--Place the z camera
z_cam = freecamera name: "depth" position:[0.0,0.0,25] rotation: (eulertoquat (eulerAngles 0 0 0)) --Horizontal FOV z_cam.fovType = 1 z_cam.fov = 70.6 --Vertical FOV z_cam.fovType = 2 z_cam.fov =60 z_cam.clipManually true z_cam.nearclip 500 z_cam.fearclip 5000
z_name = "C:\\\Zimage.png"

/*
... some looping of loading the .obj file and rotating it
*/

--get z buffer
rbmp = render outputsize:[512,424] channels:#(#zdepth) vfb:off camera: z_cam
z_d = getchannelasmask rbmp #zdepth outputfile:z_name
z_d.fileName = z_name
save z_d
close z_d


 
However when I look at the image it is in 16Bit - but the lower 8Bits are not used, thus the values are stepping in 256 values. I guess that the z bitmap (rbmp) is from 0 to 255 from the beginning. 

So is there any possibility to get the image in "real" 16 bit resolution?


I read about using Fog and turning the object white, however I have no experience with that and also do not know how to script it in Maxscirpt, so I would prefer to be working with the code snippet above, since this a snippet from larger script, which rotates the object, and I do not want to rewrite it completly.

I am using Maxscript 2018 student version

Thank you really much for help 

0 Likes
973 Views
2 Replies
Replies (2)
Message 2 of 3

Swordslayer
Advisor
Advisor

Once again, render to exr. Since the getChannelAsMask will only give you 8-bit image, rendering to exr with with the zdepth channel enabled is much better option.

0 Likes
Message 3 of 3

Anonymous
Not applicable

I see where you come from.... I looked at the thread you linked (http://forums.cgsociety.org/showthread.php?p=7627883#post7627883) however, I could not really understand how to perform the task. 

The main questions I have is:


1. How can I render it exr? What is the maxscript command for accessing the z-depth channel?

I have read in the documentation FopenEXR that "Class instances not creatable by MAXscript" - what are the consequences to MAXScript for this?
I can call 

fopenexr.setDefaults ()

 without problems, so I proceed to do the following:

reMgr = maxOps.GetCurRenderElementMgr ()

To get the current RenderElement

 

2. If I read correctly I need to add a GBufferChannel Layer which is capable of reading out the z-Buffer - I am not quite sure about this, so maybe I have to use another Buffer ? 

If I continue from here on I did the folloing, specify the G-Buffer, with:


fopenexr.addGBufferChannelLayer 0 "depth" 2 2


3. I am not quite sure about the last two arguments, what is difference between the argument type, and the argument format?

 

 

4. How can I tell the renderer now that he should write it out in .exr ? How can make the connection between the camera and the .exr Buffer channel, so that it will render it correctly? 


I am really new to the whole setup and a little bit overwhelmed by the whole possibilites. 
Thank you really much for your help

 

0 Likes