Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update camera_ray_tracing.py: fix small bugs #726

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

YuQiao0303
Copy link

Fix the following 2 bugs:

  1. 'CameraFOV' cannot be imported from kaolin.render.camera, but should be from kaolin.render.camera.intrinstics instead.
  2. 'width' and 'height' of the generated pixel grid and camera should be consistent, otherwise the average of generated ray_dir does not equal to the desired look_at direction.

Fix the following 2 bugs:
1. 'CameraFOV' cannot be imported from kaolin.render.camera, but should be from kaolin.render.camera.intrinstics instead.
2. 'width' and 'height' of the generated pixel grid and camera should be consistent, otherwise the average of generated ray_dir does not equal to the desired look_at direction
@@ -6,7 +6,8 @@
import torch
import numpy as np
from typing import Tuple
from kaolin.render.camera import Camera, CameraFOV
from kaolin.render.camera import Camera
from kaolin.render.camera.intrinsics import CameraFOV
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one isn't actually needed as __init__.py has:

from .intrinsics import *

@@ -45,20 +46,21 @@ def generate_perspective_rays(camera: Camera, pixel_grid: Tuple[torch.Tensor, to

return ray_orig, ray_dir, camera.near, camera.far


img_width = 200
img_height =200
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: Please fix the space here

near=1e-2, far=1e2,
dtype=torch.float64,
device='cuda'
)

pixel_grid = generate_pixel_grid(200, 200)
pixel_grid = generate_pixel_grid(img_width, img_height)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this snippet should be a simple recipe, I agree with your suggestion of having the raygen grid and image plane with the same resolution.
To complete the picture however - the raygen grid resolution and image plane resolution can actually differ, and this can also be exploited to, i.e., trace a lower-resolution image.

For reference, kaolin-wisp implements exactly that for its interactive mode:

  1. https://github.com/NVIDIAGameWorks/kaolin-wisp/blob/main/wisp/renderer/core/render_core.py#L167C9-L167C9
  2. https://github.com/NVIDIAGameWorks/kaolin-wisp/blob/main/wisp/renderer/core/render_core.py#L290

Picking an arbitrary resolution (which is not a power of 2 downscale factor) can indeed cause alignment issues, which I think it what you're worried about?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants