shader

class pytorch3d.renderer.mesh.shader.HardPhongShader(device='cpu', cameras=None, lights=None, materials=None, blend_params=None)[source]

Per pixel lighting - the lighting model is applied using the interpolated coordinates and normals for each pixel. The blending function hard assigns the color of the closest face for each pixel.

To use the default values, simply initialize the shader with the desired device e.g.

to(device)[source]
forward(fragments, meshes, **kwargs) → torch.Tensor[source]
class pytorch3d.renderer.mesh.shader.SoftPhongShader(device='cpu', cameras=None, lights=None, materials=None, blend_params=None)[source]

Per pixel lighting - the lighting model is applied using the interpolated coordinates and normals for each pixel. The blending function returns the soft aggregated color using all the faces per pixel.

To use the default values, simply initialize the shader with the desired device e.g.

to(device)[source]
forward(fragments, meshes, **kwargs) → torch.Tensor[source]
class pytorch3d.renderer.mesh.shader.HardGouraudShader(device='cpu', cameras=None, lights=None, materials=None, blend_params=None)[source]

Per vertex lighting - the lighting model is applied to the vertex colors and the colors are then interpolated using the barycentric coordinates to obtain the colors for each pixel. The blending function hard assigns the color of the closest face for each pixel.

To use the default values, simply initialize the shader with the desired device e.g.

to(device)[source]
forward(fragments, meshes, **kwargs) → torch.Tensor[source]
class pytorch3d.renderer.mesh.shader.SoftGouraudShader(device='cpu', cameras=None, lights=None, materials=None, blend_params=None)[source]

Per vertex lighting - the lighting model is applied to the vertex colors and the colors are then interpolated using the barycentric coordinates to obtain the colors for each pixel. The blending function returns the soft aggregated color using all the faces per pixel.

To use the default values, simply initialize the shader with the desired device e.g.

to(device)[source]
forward(fragments, meshes, **kwargs) → torch.Tensor[source]
pytorch3d.renderer.mesh.shader.TexturedSoftPhongShader(device='cpu', cameras=None, lights=None, materials=None, blend_params=None)[source]

TexturedSoftPhongShader class has been DEPRECATED. Use SoftPhongShader instead. Preserving TexturedSoftPhongShader as a function for backwards compatibility.

class pytorch3d.renderer.mesh.shader.HardFlatShader(device='cpu', cameras=None, lights=None, materials=None, blend_params=None)[source]

Per face lighting - the lighting model is applied using the average face position and the face normal. The blending function hard assigns the color of the closest face for each pixel.

To use the default values, simply initialize the shader with the desired device e.g.

to(device)[source]
forward(fragments, meshes, **kwargs) → torch.Tensor[source]
class pytorch3d.renderer.mesh.shader.SoftSilhouetteShader(blend_params=None)[source]

Calculate the silhouette by blending the top K faces for each pixel based on the 2d euclidean distance of the center of the pixel to the mesh face.

Use this shader for generating silhouettes similar to SoftRasterizer [0].

Note

To be consistent with SoftRasterizer, initialize the RasterizationSettings for the rasterizer with blur_radius = np.log(1. / 1e-4 - 1.) * blend_params.sigma

[0] Liu et al, ‘Soft Rasterizer: A Differentiable Renderer for Image-based
3D Reasoning’, ICCV 2019
forward(fragments, meshes, **kwargs) → torch.Tensor[source]

Only want to render the silhouette so RGB values can be ones. There is no need for lighting or texturing