mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2026-02-06 14:02:19 +08:00
Shader API more consistent naming
Summary: Renamed shaders to be prefixed with Hard/Soft depending on if they use a probabalistic blending (Soft) or use the closest face (Hard). There is some code duplication but I thought it would be cleaner to have separate shaders for each task rather than: - inheritance (which we discussed previously that we want to avoid) - boolean (hard/soft) or a string (hard/soft) - new blending functions other than the ones provided would need if statements in the current shaders which might get messy. Also added a `flat_shading` function and a `FlatShader` - I could make this into a tutorial as it was really easy to add a new shader and it might be a nice showcase. NOTE: There are a few more places where the naming will need to change (e.g the tutorials) but I wanted to reach a consensus on this before changing it everywhere. Reviewed By: jcjohnson Differential Revision: D19761036 fbshipit-source-id: f972f6530c7f66dc5550b0284c191abc4a7f6fc4
This commit is contained in:
committed by
Facebook Github Bot
parent
60f3c4e7d2
commit
f0dc65110a
@@ -25,10 +25,10 @@ from pytorch3d.renderer.mesh.rasterizer import (
|
||||
from pytorch3d.renderer.mesh.renderer import MeshRenderer
|
||||
from pytorch3d.renderer.mesh.shader import (
|
||||
BlendParams,
|
||||
GouradShader,
|
||||
PhongShader,
|
||||
SilhouetteShader,
|
||||
TexturedPhongShader,
|
||||
HardGouradShader,
|
||||
HardPhongShader,
|
||||
SoftSilhouetteShader,
|
||||
TexturedSoftPhongShader,
|
||||
)
|
||||
from pytorch3d.renderer.mesh.texturing import Textures
|
||||
from pytorch3d.structures.meshes import Meshes
|
||||
@@ -92,7 +92,7 @@ class TestRenderingMeshes(unittest.TestCase):
|
||||
)
|
||||
renderer = MeshRenderer(
|
||||
rasterizer=rasterizer,
|
||||
shader=PhongShader(
|
||||
shader=HardPhongShader(
|
||||
lights=lights, cameras=cameras, materials=materials
|
||||
),
|
||||
)
|
||||
@@ -133,7 +133,7 @@ class TestRenderingMeshes(unittest.TestCase):
|
||||
lights.location = torch.tensor([0.0, 0.0, -2.0], device=device)[None]
|
||||
renderer = MeshRenderer(
|
||||
rasterizer=rasterizer,
|
||||
shader=GouradShader(
|
||||
shader=HardGouradShader(
|
||||
lights=lights, cameras=cameras, materials=materials
|
||||
),
|
||||
)
|
||||
@@ -197,7 +197,7 @@ class TestRenderingMeshes(unittest.TestCase):
|
||||
rasterizer=MeshRasterizer(
|
||||
cameras=cameras, raster_settings=raster_settings
|
||||
),
|
||||
shader=PhongShader(
|
||||
shader=HardPhongShader(
|
||||
lights=lights, cameras=cameras, materials=materials
|
||||
),
|
||||
)
|
||||
@@ -242,7 +242,7 @@ class TestRenderingMeshes(unittest.TestCase):
|
||||
rasterizer=MeshRasterizer(
|
||||
cameras=cameras, raster_settings=raster_settings
|
||||
),
|
||||
shader=SilhouetteShader(blend_params=blend_params),
|
||||
shader=SoftSilhouetteShader(blend_params=blend_params),
|
||||
)
|
||||
images = renderer(sphere_mesh)
|
||||
alpha = images[0, ..., 3].squeeze().cpu()
|
||||
@@ -296,7 +296,7 @@ class TestRenderingMeshes(unittest.TestCase):
|
||||
rasterizer=MeshRasterizer(
|
||||
cameras=cameras, raster_settings=raster_settings
|
||||
),
|
||||
shader=TexturedPhongShader(
|
||||
shader=TexturedSoftPhongShader(
|
||||
lights=lights, cameras=cameras, materials=materials
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user