Closed wang1528186571 closed 3 months ago
What functions are you using? Can you share code? If it's the mesh renderer, can you try setting bin_size=0 in the RasterizationSettings?
bin_size=0
texture = torch.tensor(image, dtype=torch.float32).permute(2, 0, 1).unsqueeze(0) # (1, 4, 64, 64)
# Define the mesh vertices and faces with a circular arc curvature
x = np.linspace(-1, 1, 64)
y = np.linspace(-1, 1, 64)
x, y = np.meshgrid(x, y)
radius = 1.5 # Radius of the circular arc
z = np.sqrt(radius**2 - y**2) - radius # Calculate z to create a circular arc
vertices = np.stack([x, y, z], axis=-1).reshape(-1, 3)
vertices = torch.tensor(vertices, dtype=torch.float32)
faces = []
for i in range(63):
for j in range(63):
faces.append([i * 64 + j, i * 64 + j + 1, (i + 1) * 64 + j])
faces.append([i * 64 + j + 1, (i + 1) * 64 + j + 1, (i + 1) * 64 + j])
faces = torch.tensor(faces, dtype=torch.int64)
# Create the texture
verts_rgb = texture.permute(0, 2, 3, 1).reshape(-1, 4)[:, :3] # (V, 3)
textures = Textures(verts_rgb=[verts_rgb]) # (1, V, 3)
# Create the mesh with textures
mesh = Meshes(verts=[vertices], faces=[faces], textures=textures)
# Initialize a camera to face the plane directly
R, T = look_at_view_transform(dist=2, elev=0, azim=0) # Adjust distance, elevation and azimuth as needed
cameras = FoVPerspectiveCameras(device='cpu', R=R, T=T)
# Define the settings for rasterization and shading
raster_settings = RasterizationSettings(
image_size=1024,
blur_radius=0.0,
faces_per_pixel=1,
bin_size=0,
)
# Place a point light in front of the object
lights = PointLights(device='cpu', location=[[0.0, 0.0, 2.0]]) # Adjusted light location
# Create a Phong renderer by composing a rasterizer and a shader
renderer = MeshRenderer(
rasterizer=MeshRasterizer(
cameras=cameras,
raster_settings=raster_settings,
),
shader=SoftPhongShader(
device='cpu',
cameras=cameras,
lights=lights
)
)
# Render the image
images = renderer(mesh)
I tried adding what you said, but it didn't work.
I suspect there might be a small numerical difference which means no triangles are picked up by those pixels. Can you try setting blur_radius to a small number instead of 0.0?
I suspect there might be a small numerical difference which means no triangles are picked up by those pixels. Can you try setting blur_radius to a small number instead of 0.0? Thank you very much, you are really great, I solved this problem. There is another small problem, which is the light source. I don't know why I can't measure it globally. There will be a light source at a small point and it will reflect light.
You can change aspects of them lights by initialising the PointLights
differently. If you don't want any particular light location, use lights=AmbientLights()
.
You can change aspects of them lights by initialising the
PointLights
differently. If you don't want any particular light location, uselights=AmbientLights()
.
Thank you very much for your reply. This is similar to global illumination, right? After reading the official documentation about the function you mentioned, I want to increase the global brightness (this brightness is adjustable). What should I do? Which value should I change to change the brightness and darkness? Can you give a brief example?
Look at the parameters of a PointLights here and try giving different values for ambient_color, diffuse_color and specular_color. They should add up to at most 1 in each channel.
Look at the parameters of a PointLights here and try giving different values for ambient_color, diffuse_color and specular_color. They should add up to at most 1 in each channel.
Thank you very much for your help, thank you for your reply
The picture I generated using pytorch3d has a slash in the middle of the picture, and I don't know why?