Krzysztof Chalupka cb49550486 Add MeshRasterizerOpenGL
Summary:
Adding MeshRasterizerOpenGL, a faster alternative to MeshRasterizer. The new rasterizer follows the ideas from "Differentiable Surface Rendering via non-Differentiable Sampling".

The new rasterizer 20x faster on a 2M face mesh (try pose optimization on Nefertiti from https://www.cs.cmu.edu/~kmcrane/Projects/ModelRepository/!). The larger the mesh, the larger the speedup.

There are two main disadvantages:
* The new rasterizer works with an OpenGL backend, so requires pycuda.gl and pyopengl installed (though we avoided writing any C++ code, everything is in Python!)
* The new rasterizer is non-differentiable. However, you can still differentiate the rendering function if you use if with the new SplatterPhongShader which we recently added to PyTorch3D (see the original paper cited above).

Reviewed By: patricklabatut, jcjohnson

Differential Revision: D37698816

fbshipit-source-id: 54d120639d3cb001f096237807e54aced0acda25
2022-07-22 15:52:50 -07:00

92 lines
2.3 KiB
Python

# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from .blending import (
BlendParams,
hard_rgb_blend,
sigmoid_alpha_blend,
softmax_rgb_blend,
)
from .camera_utils import join_cameras_as_batch, rotate_on_spot
from .cameras import ( # deprecated # deprecated # deprecated # deprecated
camera_position_from_spherical_angles,
CamerasBase,
FoVOrthographicCameras,
FoVPerspectiveCameras,
get_world_to_view_transform,
look_at_rotation,
look_at_view_transform,
OpenGLOrthographicCameras,
OpenGLPerspectiveCameras,
OrthographicCameras,
PerspectiveCameras,
SfMOrthographicCameras,
SfMPerspectiveCameras,
)
from .implicit import (
AbsorptionOnlyRaymarcher,
EmissionAbsorptionRaymarcher,
GridRaysampler,
HarmonicEmbedding,
ImplicitRenderer,
MonteCarloRaysampler,
MultinomialRaysampler,
NDCGridRaysampler,
NDCMultinomialRaysampler,
ray_bundle_to_ray_points,
ray_bundle_variables_to_ray_points,
RayBundle,
VolumeRenderer,
VolumeSampler,
)
from .lighting import AmbientLights, diffuse, DirectionalLights, PointLights, specular
from .materials import Materials
from .mesh import (
gouraud_shading,
HardFlatShader,
HardGouraudShader,
HardPhongShader,
MeshRasterizer,
MeshRenderer,
MeshRendererWithFragments,
phong_shading,
RasterizationSettings,
rasterize_meshes,
SoftGouraudShader,
SoftPhongShader,
SoftSilhouetteShader,
SplatterPhongShader,
Textures,
TexturesAtlas,
TexturesUV,
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,
PointsRasterizationSettings,
PointsRasterizer,
PointsRenderer,
PulsarPointsRenderer,
rasterize_points,
)
from .splatter_blend import SplatterBlender
from .utils import (
convert_to_tensors_and_broadcast,
ndc_grid_sample,
ndc_to_grid_sample_coords,
TensorProperties,
)
__all__ = [k for k in globals().keys() if not k.startswith("_")]