ViLab-UCSD / OpenRooms

This is the dataset and code release of the OpenRooms Dataset. For more information, please refer to our webpage below. Thanks a lot for your interest in our research!
https://vilab-ucsd.github.io/ucsd-openrooms/
MIT License
134 stars 9 forks source link

Negative Z axis in normals image #12

Closed lefreud closed 5 months ago

lefreud commented 6 months ago

Hi,

I am trying to understand why, after loading images like this:

raw_normals = cv2.imread(normals_path)[:, :, ::-1]
normals = raw_normals.astype(np.float32) / 127.5 - 1
normals = normals / np.maximum(
    np.sqrt(np.sum(normals * normals, axis=2, keepdims=True)),
    1e-6
)

The normals' z coordinate (in camera view) is sometimes positive, which shouldn't happen. Here's an example, the orange part of the couch has RGB value of around (249, 148, 97). The blue channel of 97 means a z value of -0.239 (negative doesn't make sense).

image (mainxml/scene0002_00/imnormal_28.png) Is the calculation for the z axis correctly done? I'm wondering if it might be due to a different calaculation at render time (e.g. different z scale or rotated normal map).

For context, here's the slide I found explaining the normals part of the dataset: image

Thank you!

Jerrypiglet commented 5 months ago

Hi there, reply from Zhengqin:

That's an interesting observation. Instead of checking if z value is smaller than 0, we should see if the cosine angle between the ray of that pixel and normal direction is smaller than 0. Please take a look at the rendering code here: https://github.com/lzqsd/OptixRenderer/blob/3eafda5b4f47c7e44be7fc58cde215a8c1c2bc1a/src/optixRenderer/src/material/normal.cu#L66

negative z value does not necessarily mean the normal direction is not correct.

lefreud commented 5 months ago

Perfect, I understand, thank you!