Pytorch3d: How can I render without any light?

Created on 17 Jul 2020  路  2Comments  路  Source: facebookresearch/pytorch3d

How can I render without any light?

I want to generate uv map with pytorch3d. But it seems that renderer must set up lighting (shader), which interferes uv map? So I want to ask about how can I render without any light?

Thank you in advance!

how to

Most helpful comment

The simplest solution is to set all the intensity values to (0, 0, 0) when initializing the Lights class. A cleaner approach would be to define your own shader which does not apply lighting e.g.

class HardShader(nn.Module):
    def __init__(
        self, device="cpu", cameras=None, blend_params=None
    ):
        super().__init__()
        self.cameras = cameras
        self.blend_params = blend_params if blend_params is not None else BlendParams()

    def forward(self, fragments, meshes, **kwargs) -> torch.Tensor:
        cameras = kwargs.get("cameras", self.cameras)
        if cameras is None:
            msg = "Cameras must be specified either at initialization \
                or in the forward pass of HardPhongShader"
            raise ValueError(msg)
        texels = interpolate_vertex_colors(fragments, meshes)
        blend_params = kwargs.get("blend_params", self.blend_params)
        images = hard_rgb_blend(texels, fragments, blend_params)
        return images

The Shaders that we provide are only examples and are designed to be easily customized based on your use case!

All 2 comments

The simplest solution is to set all the intensity values to (0, 0, 0) when initializing the Lights class. A cleaner approach would be to define your own shader which does not apply lighting e.g.

class HardShader(nn.Module):
    def __init__(
        self, device="cpu", cameras=None, blend_params=None
    ):
        super().__init__()
        self.cameras = cameras
        self.blend_params = blend_params if blend_params is not None else BlendParams()

    def forward(self, fragments, meshes, **kwargs) -> torch.Tensor:
        cameras = kwargs.get("cameras", self.cameras)
        if cameras is None:
            msg = "Cameras must be specified either at initialization \
                or in the forward pass of HardPhongShader"
            raise ValueError(msg)
        texels = interpolate_vertex_colors(fragments, meshes)
        blend_params = kwargs.get("blend_params", self.blend_params)
        images = hard_rgb_blend(texels, fragments, blend_params)
        return images

The Shaders that we provide are only examples and are designed to be easily customized based on your use case!

@TheshowN do you still need help with this issue?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AndreiBarsan picture AndreiBarsan  路  3Comments

elcronos picture elcronos  路  3Comments

shersoni610 picture shersoni610  路  3Comments

aluo-x picture aluo-x  路  3Comments

abhi1kumar picture abhi1kumar  路  3Comments