facebookresearch / pytorch3d

PyTorch3D is FAIR's library of reusable components for deep learning with 3D data
https://pytorch3d.org/
Other
8.7k stars 1.3k forks source link

How to change background color of the pytorch3d rendering results? #1841

Open yejr0229 opened 2 months ago

yejr0229 commented 2 months ago

I want to change the background color of the rendering image form image1 to image2: image image

and I try to modify th parameters here: image

But the results looks wrong: image How to do it correctly?

bottler commented 2 months ago

You need to find in the code where you construct a BlendParams instance, and set the value you want there. It may be explicit, or it may be defaulted somewhere. Can you paste the code where you call the renderer?

yejr0229 commented 2 months ago

image and the BlendParams: image

bottler commented 2 months ago

To avoid modifying pytorch3d but change the background color, you can change the blend_params=BlendParams() in your code to blend_params=BlendParams(background_color=(0.4,0.5,0.6)) or whatever.

EDIT: This isn't the real question.

bottler commented 2 months ago

The image that looks "wrong" seems to have the background color applied to the foreground. I wonder if there's a problem with the znear or zfar values: you want the object to be between them. You can add znear and zfar as float inputs to the shader, or use ones in the camera.