mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-20 06:10:34 +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:
committed by
Facebook GitHub Bot
parent
5bf6d532f7
commit
3b7ab22d10
@@ -65,11 +65,6 @@ from .mesh import (
|
||||
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 (
|
||||
AlphaCompositor,
|
||||
NormWeightedCompositor,
|
||||
|
||||
@@ -10,8 +10,6 @@ import torch
|
||||
import torch.nn as nn
|
||||
|
||||
from ...structures.meshes import Meshes
|
||||
from .rasterizer import MeshRasterizer
|
||||
|
||||
|
||||
# A renderer class should be initialized with a
|
||||
# function for rasterization and a function for shading.
|
||||
@@ -32,11 +30,11 @@ from .rasterizer import MeshRasterizer
|
||||
class MeshRenderer(nn.Module):
|
||||
"""
|
||||
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
|
||||
function.
|
||||
be initialized with a rasterizer (a MeshRasterizer or a MeshRasterizerOpenGL)
|
||||
and shader class which each have a forward function.
|
||||
"""
|
||||
|
||||
def __init__(self, rasterizer: MeshRasterizer, shader) -> None:
|
||||
def __init__(self, rasterizer, shader) -> None:
|
||||
super().__init__()
|
||||
self.rasterizer = rasterizer
|
||||
self.shader = shader
|
||||
@@ -69,8 +67,8 @@ class MeshRenderer(nn.Module):
|
||||
class MeshRendererWithFragments(nn.Module):
|
||||
"""
|
||||
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
|
||||
function.
|
||||
be initialized with a rasterizer (a MeshRasterizer or a MeshRasterizerOpenGL)
|
||||
and shader class which each have a forward function.
|
||||
|
||||
In the forward pass this class returns the `fragments` from which intermediate
|
||||
values such as the depth map can be easily extracted e.g.
|
||||
@@ -80,7 +78,7 @@ class MeshRendererWithFragments(nn.Module):
|
||||
depth = fragments.zbuf
|
||||
"""
|
||||
|
||||
def __init__(self, rasterizer: MeshRasterizer, shader) -> None:
|
||||
def __init__(self, rasterizer, shader) -> None:
|
||||
super().__init__()
|
||||
self.rasterizer = rasterizer
|
||||
self.shader = shader
|
||||
|
||||
@@ -130,8 +130,9 @@ class MeshRasterizerOpenGL(nn.Module):
|
||||
|
||||
Fragments output by MeshRasterizerOpenGL and MeshRasterizer should have near
|
||||
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
|
||||
with MeshRasterizerOpenGL (because it is not differentiable).
|
||||
return Fragments.dists which is only relevant to SoftPhongShader and
|
||||
SoftSilhouetteShader. These do not work with MeshRasterizerOpenGL (because it is
|
||||
not differentiable).
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
|
||||
Reference in New Issue
Block a user