Comments (4)
@Jiayi-Wang-MPI The phong_renderer
only uses 1 face for each pixel and applies hard blending i.e uses the only the color of the closest face for each pixel. If you look at the raster_settings
you can see the option faces_per_pixel
is set to 1. You'll need to make the following changes.
- Set the rasterization settings to the same values as for the
SilhouetteShader
raster_settings = RasterizationSettings(
image_size=256,
blur_radius=np.log(1. / 1e-4 - 1.) * blend_params.sigma,
faces_per_pixel=100,
bin_size=0
)
- Define a new Phong shader which uses the
softmax_rgb_blend
function:
class SoftPhongShader(nn.Module):
def __init__(
self,
device="cpu",
cameras=None,
lights=None,
materials=None,
blend_params=None,
):
super().__init__()
self.lights = (
lights if lights is not None else PointLights(device=device)
)
self.materials = (
materials if materials is not None else Materials(device=device)
)
self.cameras = (
cameras
if cameras is not None
else OpenGLPerspectiveCameras(device=device)
)
self.blend_params = (
blend_params if blend_params is not None else BlendParams()
)
def forward(self, fragments, meshes, **kwargs) -> torch.Tensor:
texels = interpolate_vertex_colors(fragments, meshes)
cameras = kwargs.get("cameras", self.cameras)
lights = kwargs.get("lights", self.lights)
materials = kwargs.get("materials", self.materials)
colors = phong_shading(
meshes=meshes,
fragments=fragments,
texels=texels,
lights=lights,
cameras=cameras,
materials=materials,
)
images = softmax_rgb_blend(colors, fragments, self.blend_params)
return images
- Initialize the
phong_renderer
as follows:
phong_renderer = MeshRenderer(
rasterizer=MeshRasterizer(
cameras=cameras,
raster_settings=raster_settings
),
shader= SoftPhongShader(device=device, lights=lights, blend_params=blend_params)
)
We are making some updates to the Shading API so the above renderer will be available soon to import directly.
from pytorch3d.
@nikhilaravi the new SoftPhongShader works for me. Thanks!
from pytorch3d.
@Jiayi-Wang-MPI the SoftPhongShader
is now available to import directly from pytorch3d so you don't need to define it yourself.
from pytorch3d.
@Jiayi-Wang-MPI were you able to get this working with the new SoftPhongShader
or the code above? Can I close this issue?
from pytorch3d.
Related Issues (20)
- can't install pytorch3d HOT 2
- Marching Cubes CUDA implementation generates face indices out of bounds HOT 2
- Rendering depth map with Pytorch3D vs Open3D HOT 2
- No module named 'pytorch3d.structures' HOT 1
- get error: IndexError: tensors used as indices must be long, byte or bool tensors HOT 3
- Joining a Batch of Scenes HOT 1
- Size Mismatch between tensors when rendering SMPL model HOT 3
- Very slow rendering for large mesh HOT 8
- ImportError: libc10_cuda.so: cannot open shared object file: No such file or directory HOT 7
- the use of the normals_packed() HOT 1
- pointcould render issue
- Trouble updating all pixels from texture that contribute to render HOT 1
- load_obj save_obj seems to modify the original obj (has anyone else seen this) HOT 3
- Could not build wheels for pytorch3d HOT 3
- ERROR: Could not build wheels for pytorch3d, which is required to install pyproject.toml-based projects | Suggested methods in Issue #1734 did not help HOT 5
- Potential IOU compute Bug in box3d_overlap HOT 9
- How to create a uniform TexturesUV by giving verts and faces? HOT 1
- torch3d consumes a lot of memory when loading obj's
- It looks like my camera's spatial Camera position has moved backwards, but plot_scene doesn't have the xyz parameter entered, am I parsing the camera parameters wrong? HOT 3
- Possibly insufficient preallocation in IoU3D algorithm implementation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytorch3d.