Skip to content

Commit

Permalink
finish ppm_diff pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
jkxing committed May 3, 2024
1 parent 27ec951 commit f16a55f
Show file tree
Hide file tree
Showing 8 changed files with 281 additions and 346 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "scikit_build_core.build"

[project]
name = "luisarender-python"
version = "0.0.5"
version = "0.0.6"
description = "A High-Performance Rendering Framework with Layered and Unified Interfaces on Stream Architectures"
readme = "README.md"
authors = [
Expand Down
4 changes: 1 addition & 3 deletions src/base/pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,8 @@ luisa::unique_ptr<Pipeline> Pipeline::create(Device &device, Stream &stream, con
}
update_bindless_if_dirty();


LUISA_INFO_WITH_LOCATION("start integrator build.");
pipeline->_integrator = scene.integrator()->build(*pipeline, command_buffer);


LUISA_INFO_WITH_LOCATION("start _differentiation build.");
if (auto &&diff = pipeline->_differentiation) {
diff->register_optimizer(dynamic_cast<DifferentiableIntegrator::Instance *>(pipeline->_integrator.get())->optimizer());
Expand Down
615 changes: 277 additions & 338 deletions src/integrators/megappm_diff.cpp

Large diffs are not rendered by default.

Binary file added src/tests/gt_0.05.exr
Binary file not shown.
Binary file added src/tests/init.exr
Binary file not shown.
Binary file added src/tests/outputs/backwarde_render_0.exr
Binary file not shown.
Binary file added src/tests/outputs/render0.exr
Binary file not shown.
6 changes: 2 additions & 4 deletions src/tests/test_ad_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,8 @@ def compute_vertex_normals(vertex_pos, face_ids):
#loss = loss_func(render_img,target_img)
loss = torch.sum((render_img[400:,...]-target_img[400:,...])**2)
loss.backward()
grad = render_img.grad[...,:3]
#print("debug pixel", render_img[458, 210,:3], grad[458, 210,:3])
#exit()
grad = torch.cat([render_img.grad[...,:3],torch.zeros_like(render_img.grad[...,:2])],dim=-1)
print(grad.shape)
aux_buffer = luisarender.render_backward([grad.contiguous().data_ptr()],[np.prod(grad.shape)])
aux_buffer_torch = cu_device_ptr_to_torch_tensor(aux_buffer[0], (512, 512, 4), dtype=cupy.float32)
aux_buffer_numpy = aux_buffer_torch.cpu().numpy()
Expand All @@ -137,7 +136,6 @@ def compute_vertex_normals(vertex_pos, face_ids):
print(mx, np.max(graddis_avg), np.min(graddis_avg))
grad_reldis_vis = cm(graddis_avg/mx)
imageio.imwrite(f"outputs/grad_vis_{i}.png",grad_reldis_vis)

exit()

tex_grad, geom_grad = luisarender.get_gradients()
Expand Down

0 comments on commit f16a55f

Please sign in to comment.