mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-08-02 20:02:49 +08:00
MeshRasterizerOpenGL import fixes
Summary: Only import it if you ask for it. Reviewed By: kjchalup Differential Revision: D38327167 fbshipit-source-id: 3f05231f26eda582a63afc71b669996342b0c6f9
This commit is contained in:
parent
5bf6d532f7
commit
3b7ab22d10
@ -7,7 +7,6 @@
|
|||||||
import contextlib
|
import contextlib
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
from typing import List
|
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
|
@ -65,11 +65,6 @@ from .mesh import (
|
|||||||
TexturesVertex,
|
TexturesVertex,
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
|
||||||
from .opengl import EGLContext, global_device_context_store, MeshRasterizerOpenGL
|
|
||||||
except (ImportError, ModuleNotFoundError):
|
|
||||||
pass # opengl or pycuda.gl not available, or pytorch3_opengl not in TARGETS.
|
|
||||||
|
|
||||||
from .points import (
|
from .points import (
|
||||||
AlphaCompositor,
|
AlphaCompositor,
|
||||||
NormWeightedCompositor,
|
NormWeightedCompositor,
|
||||||
|
@ -10,8 +10,6 @@ import torch
|
|||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
|
|
||||||
from ...structures.meshes import Meshes
|
from ...structures.meshes import Meshes
|
||||||
from .rasterizer import MeshRasterizer
|
|
||||||
|
|
||||||
|
|
||||||
# A renderer class should be initialized with a
|
# A renderer class should be initialized with a
|
||||||
# function for rasterization and a function for shading.
|
# function for rasterization and a function for shading.
|
||||||
@ -32,11 +30,11 @@ from .rasterizer import MeshRasterizer
|
|||||||
class MeshRenderer(nn.Module):
|
class MeshRenderer(nn.Module):
|
||||||
"""
|
"""
|
||||||
A class for rendering a batch of heterogeneous meshes. The class should
|
A class for rendering a batch of heterogeneous meshes. The class should
|
||||||
be initialized with a rasterizer and shader class which each have a forward
|
be initialized with a rasterizer (a MeshRasterizer or a MeshRasterizerOpenGL)
|
||||||
function.
|
and shader class which each have a forward function.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, rasterizer: MeshRasterizer, shader) -> None:
|
def __init__(self, rasterizer, shader) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.rasterizer = rasterizer
|
self.rasterizer = rasterizer
|
||||||
self.shader = shader
|
self.shader = shader
|
||||||
@ -69,8 +67,8 @@ class MeshRenderer(nn.Module):
|
|||||||
class MeshRendererWithFragments(nn.Module):
|
class MeshRendererWithFragments(nn.Module):
|
||||||
"""
|
"""
|
||||||
A class for rendering a batch of heterogeneous meshes. The class should
|
A class for rendering a batch of heterogeneous meshes. The class should
|
||||||
be initialized with a rasterizer and shader class which each have a forward
|
be initialized with a rasterizer (a MeshRasterizer or a MeshRasterizerOpenGL)
|
||||||
function.
|
and shader class which each have a forward function.
|
||||||
|
|
||||||
In the forward pass this class returns the `fragments` from which intermediate
|
In the forward pass this class returns the `fragments` from which intermediate
|
||||||
values such as the depth map can be easily extracted e.g.
|
values such as the depth map can be easily extracted e.g.
|
||||||
@ -80,7 +78,7 @@ class MeshRendererWithFragments(nn.Module):
|
|||||||
depth = fragments.zbuf
|
depth = fragments.zbuf
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, rasterizer: MeshRasterizer, shader) -> None:
|
def __init__(self, rasterizer, shader) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.rasterizer = rasterizer
|
self.rasterizer = rasterizer
|
||||||
self.shader = shader
|
self.shader = shader
|
||||||
|
@ -130,8 +130,9 @@ class MeshRasterizerOpenGL(nn.Module):
|
|||||||
|
|
||||||
Fragments output by MeshRasterizerOpenGL and MeshRasterizer should have near
|
Fragments output by MeshRasterizerOpenGL and MeshRasterizer should have near
|
||||||
identical pix_to_face, bary_coords and zbuf. However, MeshRasterizerOpenGL does not
|
identical pix_to_face, bary_coords and zbuf. However, MeshRasterizerOpenGL does not
|
||||||
return Fragments.dists which is only relevant to SoftPhongShader which doesn't work
|
return Fragments.dists which is only relevant to SoftPhongShader and
|
||||||
with MeshRasterizerOpenGL (because it is not differentiable).
|
SoftSilhouetteShader. These do not work with MeshRasterizerOpenGL (because it is
|
||||||
|
not differentiable).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
@ -17,7 +17,6 @@ from pytorch3d.renderer import (
|
|||||||
look_at_view_transform,
|
look_at_view_transform,
|
||||||
Materials,
|
Materials,
|
||||||
MeshRasterizer,
|
MeshRasterizer,
|
||||||
MeshRasterizerOpenGL,
|
|
||||||
MeshRenderer,
|
MeshRenderer,
|
||||||
PointLights,
|
PointLights,
|
||||||
RasterizationSettings,
|
RasterizationSettings,
|
||||||
@ -30,6 +29,7 @@ from pytorch3d.renderer.mesh.rasterize_meshes import (
|
|||||||
rasterize_meshes_python,
|
rasterize_meshes_python,
|
||||||
)
|
)
|
||||||
from pytorch3d.renderer.mesh.rasterizer import Fragments
|
from pytorch3d.renderer.mesh.rasterizer import Fragments
|
||||||
|
from pytorch3d.renderer.opengl import MeshRasterizerOpenGL
|
||||||
from pytorch3d.renderer.points import (
|
from pytorch3d.renderer.points import (
|
||||||
AlphaCompositor,
|
AlphaCompositor,
|
||||||
PointsRasterizationSettings,
|
PointsRasterizationSettings,
|
||||||
|
@ -15,7 +15,6 @@ from pytorch3d.renderer import (
|
|||||||
FoVPerspectiveCameras,
|
FoVPerspectiveCameras,
|
||||||
look_at_view_transform,
|
look_at_view_transform,
|
||||||
MeshRasterizer,
|
MeshRasterizer,
|
||||||
MeshRasterizerOpenGL,
|
|
||||||
OrthographicCameras,
|
OrthographicCameras,
|
||||||
PerspectiveCameras,
|
PerspectiveCameras,
|
||||||
PointsRasterizationSettings,
|
PointsRasterizationSettings,
|
||||||
@ -27,6 +26,7 @@ from pytorch3d.renderer.opengl.rasterizer_opengl import (
|
|||||||
_check_raster_settings,
|
_check_raster_settings,
|
||||||
_convert_meshes_to_gl_ndc,
|
_convert_meshes_to_gl_ndc,
|
||||||
_parse_and_verify_image_size,
|
_parse_and_verify_image_size,
|
||||||
|
MeshRasterizerOpenGL,
|
||||||
)
|
)
|
||||||
from pytorch3d.structures import Pointclouds
|
from pytorch3d.structures import Pointclouds
|
||||||
from pytorch3d.structures.meshes import Meshes
|
from pytorch3d.structures.meshes import Meshes
|
||||||
|
@ -23,7 +23,6 @@ from pytorch3d.renderer import (
|
|||||||
look_at_view_transform,
|
look_at_view_transform,
|
||||||
Materials,
|
Materials,
|
||||||
MeshRasterizer,
|
MeshRasterizer,
|
||||||
MeshRasterizerOpenGL,
|
|
||||||
MeshRenderer,
|
MeshRenderer,
|
||||||
MeshRendererWithFragments,
|
MeshRendererWithFragments,
|
||||||
OrthographicCameras,
|
OrthographicCameras,
|
||||||
@ -44,6 +43,7 @@ from pytorch3d.renderer.mesh.shader import (
|
|||||||
SplatterPhongShader,
|
SplatterPhongShader,
|
||||||
TexturedSoftPhongShader,
|
TexturedSoftPhongShader,
|
||||||
)
|
)
|
||||||
|
from pytorch3d.renderer.opengl import MeshRasterizerOpenGL
|
||||||
from pytorch3d.structures.meshes import (
|
from pytorch3d.structures.meshes import (
|
||||||
join_meshes_as_batch,
|
join_meshes_as_batch,
|
||||||
join_meshes_as_scene,
|
join_meshes_as_scene,
|
||||||
|
@ -14,7 +14,6 @@ from pytorch3d.renderer import (
|
|||||||
HardGouraudShader,
|
HardGouraudShader,
|
||||||
Materials,
|
Materials,
|
||||||
MeshRasterizer,
|
MeshRasterizer,
|
||||||
MeshRasterizerOpenGL,
|
|
||||||
MeshRenderer,
|
MeshRenderer,
|
||||||
PointLights,
|
PointLights,
|
||||||
PointsRasterizationSettings,
|
PointsRasterizationSettings,
|
||||||
@ -26,6 +25,7 @@ from pytorch3d.renderer import (
|
|||||||
TexturesVertex,
|
TexturesVertex,
|
||||||
)
|
)
|
||||||
from pytorch3d.renderer.cameras import FoVPerspectiveCameras, look_at_view_transform
|
from pytorch3d.renderer.cameras import FoVPerspectiveCameras, look_at_view_transform
|
||||||
|
from pytorch3d.renderer.opengl import MeshRasterizerOpenGL
|
||||||
from pytorch3d.structures import Meshes, Pointclouds
|
from pytorch3d.structures import Meshes, Pointclouds
|
||||||
from pytorch3d.utils.ico_sphere import ico_sphere
|
from pytorch3d.utils.ico_sphere import ico_sphere
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user