pytorch3d.renderer.mesh.shading
shading
- pytorch3d.renderer.mesh.shading.phong_shading(meshes, fragments, lights, cameras, materials, texels) Tensor[source]
Apply per pixel shading. First interpolate the vertex normals and vertex coordinates using the barycentric coordinates to get the position and normal at each pixel. Then compute the illumination for each pixel. The pixel color is obtained by multiplying the pixel textures by the ambient and diffuse illumination and adding the specular component.
- Parameters:
meshes – Batch of meshes
fragments – Fragments named tuple with the outputs of rasterization
lights – Lights class containing a batch of lights
cameras – Cameras class containing a batch of cameras
materials – Materials class containing a batch of material properties
texels – texture per pixel of shape (N, H, W, K, 3)
- Returns:
colors – (N, H, W, K, 3)
- pytorch3d.renderer.mesh.shading.gouraud_shading(meshes, fragments, lights, cameras, materials) Tensor[source]
Apply per vertex shading. First compute the vertex illumination by applying ambient, diffuse and specular lighting. If vertex color is available, combine the ambient and diffuse vertex illumination with the vertex color and add the specular component to determine the vertex shaded color. Then interpolate the vertex shaded colors using the barycentric coordinates to get a color per pixel.
Gouraud shading is only supported for meshes with texture type TexturesVertex. This is because the illumination is applied to the vertex colors.
- Parameters:
meshes – Batch of meshes
fragments – Fragments named tuple with the outputs of rasterization
lights – Lights class containing a batch of lights parameters
cameras – Cameras class containing a batch of cameras parameters
materials – Materials class containing a batch of material properties
- Returns:
colors – (N, H, W, K, 3)
- pytorch3d.renderer.mesh.shading.flat_shading(meshes, fragments, lights, cameras, materials, texels) Tensor[source]
Apply per face shading. Use the average face position and the face normals to compute the ambient, diffuse and specular lighting. Apply the ambient and diffuse color to the pixel color and add the specular component to determine the final pixel color.
- Parameters:
meshes – Batch of meshes
fragments – Fragments named tuple with the outputs of rasterization
lights – Lights class containing a batch of lights parameters
cameras – Cameras class containing a batch of cameras parameters
materials – Materials class containing a batch of material properties
texels – texture per pixel of shape (N, H, W, K, 3)
- Returns:
colors – (N, H, W, K, 3)