Author Topic: Render the Z-Buffer in a linear way  (Read 1827 times)

2018-03-19, 14:28:46

Bamboocha

  • Users
  • *
  • Posts: 3
    • View Profile
Hello,

I am fairly new to rendering in general and even newer to Corona.

I want to render a Z-Buffer image, where the distance to an Object is represented in Pixel Values.


For my experiments I have simply put a plane at a distance of 500 mm, 1000 mm, 1500 mm and 2000 mm distance to the camera. And added the Render-Element CGeometry_ZDepth and adjusted the Min and Max to my desires (Max Z: 0,0 mm, Min Z: 91750,0 mm, and clipped the ouptut to 0-1 range).

While the Z-Buffer images were created I noticed that the distances are not linear.


Here is a comparison of a the middle point values;

at 500 mm: 6130
at 1000 mm: 8400
at 1500 mm: 10100
at 2000 mm:   11511

The pixel values are not representing the distance, which could be calculated later, however is there a possibilty to get a linearity in the Z-Buffer to the distances? (Meaning that an object which was at distance x has the pixel value y, and if the same object has the distance 2*x , the pixel becomes 2*y ?


Thank you really much in advance

2018-03-19, 14:54:40
Reply #1

sevecek

  • Former Corona Team Member
  • Active Users
  • **
  • Posts: 197
    • View Profile
Hi,
it's probably due to gamma correction. If you apply x^2.2 to your values, the corrected values are approximately linear.

2018-03-19, 15:01:10
Reply #2

Bamboocha

  • Users
  • *
  • Posts: 3
    • View Profile
Thank you for your reply.

How can I turn off or adjust the gamma correction in the render setting?

And secondly, you mean by the power of 2.2 with the "^" sign, just to check?

2018-03-19, 15:26:25
Reply #3

sevecek

  • Former Corona Team Member
  • Active Users
  • **
  • Posts: 197
    • View Profile
You can specify gamma in save dialog when saving the rendered image.
And yes, '^' means power.

2018-03-19, 15:36:08
Reply #4

Bamboocha

  • Users
  • *
  • Posts: 3
    • View Profile
Thank you really much - I am using Maxscript for rendering, that's why I have not seen it.