Skip to content

Commit

Permalink
Fix spelling of "Gouraud"
Browse files Browse the repository at this point in the history
Summary: Fix spelling of *Gouraud* in [Gouraud shading](https://en.wikipedia.org/wiki/Gouraud_shading).

Reviewed By: nikhilaravi

Differential Revision: D19943547

fbshipit-source-id: 5c016b7b051a7b33a7b68ed5303b642d9e834bbd
  • Loading branch information
patricklabatut authored and facebook-github-bot committed Feb 20, 2020
1 parent f0dc651 commit 9ca5489
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 27 deletions.
8 changes: 4 additions & 4 deletions docs/notes/renderer_getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,18 @@ Shaders are the most flexible part of the PyTorch3D rendering API. We have creat

A shader can incorporate several steps:
- **texturing** (e.g interpolation of vertex RGB colors or interpolation of vertex UV coordinates followed by sampling from a texture map (interpolation uses barycentric coordinates output from rasterization))
- **lighting/shading** (e.g. ambient, diffuse, specular lighting, Phong, Gourad, Flat)
- **lighting/shading** (e.g. ambient, diffuse, specular lighting, Phong, Gouraud, Flat)
- **blending** (e.g. hard blending using only the closest face for each pixel, or soft blending using a weighted sum of the top K faces per pixel)

We have examples of several combinations of these functions based on the texturing/shading/blending support we have currently. These are summarised in this table below. Many other combinations are possible and we plan to expand the options available for texturing, shading and blending.


|Example Shaders | Vertex Textures| Texture Map| Flat Shading| Gourad Shading| Phong Shading | Hard blending | Soft Blending |
|Example Shaders | Vertex Textures| Texture Map| Flat Shading| Gouraud Shading| Phong Shading | Hard blending | Soft Blending |
| ------------- |:-------------: | :--------------:| :--------------:| :--------------:| :--------------:|:--------------:|:--------------:|
| HardPhongShader | :heavy_check_mark: |||| :heavy_check_mark: | :heavy_check_mark:||
| SoftPhongShader | :heavy_check_mark: |||| :heavy_check_mark: | | :heavy_check_mark:|
| HardGouradShader | :heavy_check_mark: ||| :heavy_check_mark: || :heavy_check_mark:||
| SoftGouradShader | :heavy_check_mark: ||| :heavy_check_mark: ||| :heavy_check_mark:|
| HardGouraudShader | :heavy_check_mark: ||| :heavy_check_mark: || :heavy_check_mark:||
| SoftGouraudShader | :heavy_check_mark: ||| :heavy_check_mark: ||| :heavy_check_mark:|
| TexturedSoftPhongShader || :heavy_check_mark: ||| :heavy_check_mark: || :heavy_check_mark:|
| HardFlatShader | :heavy_check_mark: || :heavy_check_mark: ||| :heavy_check_mark:||
| SoftSilhouetteShader ||||||| :heavy_check_mark:|
6 changes: 3 additions & 3 deletions pytorch3d/renderer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
from .materials import Materials
from .mesh import (
HardFlatShader,
HardGouradShader,
HardGouraudShader,
HardPhongShader,
MeshRasterizer,
MeshRenderer,
RasterizationSettings,
SoftGouradShader,
SoftGouraudShader,
SoftPhongShader,
SoftSilhouetteShader,
TexturedSoftPhongShader,
gourad_shading,
gouraud_shading,
interpolate_face_attributes,
interpolate_texture_map,
interpolate_vertex_colors,
Expand Down
6 changes: 3 additions & 3 deletions pytorch3d/renderer/mesh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
from .renderer import MeshRenderer
from .shader import (
HardFlatShader,
HardGouradShader,
HardGouraudShader,
HardPhongShader,
SoftGouradShader,
SoftGouraudShader,
SoftPhongShader,
SoftSilhouetteShader,
TexturedSoftPhongShader,
)
from .shading import gourad_shading, phong_shading
from .shading import gouraud_shading, phong_shading
from .texturing import ( # isort: skip
interpolate_face_attributes,
interpolate_texture_map,
Expand Down
14 changes: 7 additions & 7 deletions pytorch3d/renderer/mesh/shader.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ..cameras import OpenGLPerspectiveCameras
from ..lighting import PointLights
from ..materials import Materials
from .shading import flat_shading, gourad_shading, phong_shading
from .shading import flat_shading, gouraud_shading, phong_shading
from .texturing import interpolate_texture_map, interpolate_vertex_colors

# A Shader should take as input fragments from the output of rasterization
Expand Down Expand Up @@ -126,7 +126,7 @@ def forward(self, fragments, meshes, **kwargs) -> torch.Tensor:
return images


class HardGouradShader(nn.Module):
class HardGouraudShader(nn.Module):
"""
Per vertex lighting - the lighting model is applied to the vertex colors and
the colors are then interpolated using the barycentric coordinates to
Expand All @@ -138,7 +138,7 @@ class HardGouradShader(nn.Module):
.. code-block::
shader = HardGouradShader(device=torch.device("cuda:0"))
shader = HardGouraudShader(device=torch.device("cuda:0"))
"""

def __init__(self, device="cpu", cameras=None, lights=None, materials=None):
Expand All @@ -159,7 +159,7 @@ def forward(self, fragments, meshes, **kwargs) -> torch.Tensor:
cameras = kwargs.get("cameras", self.cameras)
lights = kwargs.get("lights", self.lights)
materials = kwargs.get("materials", self.materials)
pixel_colors = gourad_shading(
pixel_colors = gouraud_shading(
meshes=meshes,
fragments=fragments,
lights=lights,
Expand All @@ -170,7 +170,7 @@ def forward(self, fragments, meshes, **kwargs) -> torch.Tensor:
return images


class SoftGouradShader(nn.Module):
class SoftGouraudShader(nn.Module):
"""
Per vertex lighting - the lighting model is applied to the vertex colors and
the colors are then interpolated using the barycentric coordinates to
Expand All @@ -182,7 +182,7 @@ class SoftGouradShader(nn.Module):
.. code-block::
shader = SoftGouradShader(device=torch.device("cuda:0"))
shader = SoftGouraudShader(device=torch.device("cuda:0"))
"""

def __init__(
Expand Down Expand Up @@ -213,7 +213,7 @@ def forward(self, fragments, meshes, **kwargs) -> torch.Tensor:
cameras = kwargs.get("cameras", self.cameras)
lights = kwargs.get("lights", self.lights)
materials = kwargs.get("materials", self.materials)
pixel_colors = gourad_shading(
pixel_colors = gouraud_shading(
meshes=meshes,
fragments=fragments,
lights=lights,
Expand Down
2 changes: 1 addition & 1 deletion pytorch3d/renderer/mesh/shading.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def phong_shading(
return colors


def gourad_shading(
def gouraud_shading(
meshes, fragments, lights, cameras, materials
) -> torch.Tensor:
"""
Expand Down
18 changes: 9 additions & 9 deletions tests/test_rendering_meshes.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from pytorch3d.renderer.mesh.renderer import MeshRenderer
from pytorch3d.renderer.mesh.shader import (
BlendParams,
HardGouradShader,
HardGouraudShader,
HardPhongShader,
SoftSilhouetteShader,
TexturedSoftPhongShader,
Expand All @@ -51,7 +51,7 @@ def load_rgb_image(filename, data_dir=DATA_DIR):
class TestRenderingMeshes(unittest.TestCase):
def test_simple_sphere(self, elevated_camera=False):
"""
Test output of phong and gourad shading matches a reference image using
Test output of phong and gouraud shading matches a reference image using
the default values for the light sources.
Args:
Expand Down Expand Up @@ -128,32 +128,32 @@ def test_simple_sphere(self, elevated_camera=False):
self.assertTrue(torch.allclose(rgb, image_ref_phong_dark, atol=0.05))

######################################
# Change the shader to a GouradShader
# Change the shader to a GouraudShader
######################################
lights.location = torch.tensor([0.0, 0.0, -2.0], device=device)[None]
renderer = MeshRenderer(
rasterizer=rasterizer,
shader=HardGouradShader(
shader=HardGouraudShader(
lights=lights, cameras=cameras, materials=materials
),
)
images = renderer(sphere_mesh)
rgb = images[0, ..., :3].squeeze().cpu()
if DEBUG:
Image.fromarray((rgb.numpy() * 255).astype(np.uint8)).save(
DATA_DIR / "DEBUG_simple_sphere_light_gourad%s.png" % postfix
DATA_DIR / "DEBUG_simple_sphere_light_gouraud%s.png" % postfix
)

# Load reference image
image_ref_gourad = load_rgb_image(
"test_simple_sphere_light_gourad%s.png" % postfix
image_ref_gouraud = load_rgb_image(
"test_simple_sphere_light_gouraud%s.png" % postfix
)
self.assertTrue(torch.allclose(rgb, image_ref_gourad, atol=0.005))
self.assertTrue(torch.allclose(rgb, image_ref_gouraud, atol=0.005))
self.assertFalse(torch.allclose(rgb, image_ref_phong, atol=0.005))

def test_simple_sphere_elevated_camera(self):
"""
Test output of phong and gourad shading matches a reference image using
Test output of phong and gouraud shading matches a reference image using
the default values for the light sources.
The rendering is performed with a camera that has non-zero elevation.
Expand Down

0 comments on commit 9ca5489

Please sign in to comment.