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

Black output when rendering top down image #845

Open
Kurokabe opened this issue Nov 20, 2024 · 0 comments
Open

Black output when rendering top down image #845

Kurokabe opened this issue Nov 20, 2024 · 0 comments

Comments

@Kurokabe
Copy link

With kaolin==0.16.0, when I use easy_render with the camera above the center of my mesh, and the camera looking straight down, I get a black image.

from kaolin.render.easy_render import render_mesh, default_lighting
from kaolin.io.usd import import_mesh
from kaolin.render.camera import Camera
import torch
from torchvision.transforms import ToPILImage

mesh = import_mesh("my_mesh.usd", triangulate=True, with_materials=True).to("cuda")

mesh.vertices.min(axis=0), mesh.vertices.max(axis=0)
center = (mesh.vertices.min(axis=0)[0] + mesh.vertices.max(axis=0)[0]) / 2

offset = 0.0

camera_y_position = 3.0

eye = torch.tensor([center[0], camera_y_position , center[2]], dtype=torch.float32)
at = torch.tensor([center[0] + offset, 0, center[2]], dtype=torch.float32)

lighting = default_lighting().to("cuda")
camera = Camera.from_args(
                eye=eye,
                at=at,
                up=torch.tensor([0.0, 1.0, 0.0]),
                fov=45,  
                width=512, height=512,
                device='cuda'
            )

with torch.jit.optimized_execution(False):
    with torch.no_grad():
        render = render_mesh(
                camera,
                mesh,
                lighting,
            )
        

ToPILImage()(render["render"][0].transpose(0, 2))

But if I add a slight offset, e.g. offset = 0.01 to either the X or Z coordinate, then I get a proper rendering.

@Kurokabe Kurokabe changed the title Black image when rendering top down image Black output when rendering top down image Nov 20, 2024
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

No branches or pull requests

1 participant