In https://github.com/mitsuba-renderer/mitsuba-tutorials/blob/master/inverse_rendering/gradient_based_opt.ipynb ``` # Post-process the optimized parameters to ensure legal color values. opt[key] = dr.clip(opt[key], 0.0, 1.0) ``` The clipping of the optimized parameters prevents convergence to correct colour: ``` original_color_r 0.5700680017471313 original_color_g 0.043013498187065125 original_color_b 0.04437059909105301 ``` <img width="256" height="256" alt="Image" src="https://github.com/user-attachments/assets/593c69f0-f37d-4f3e-92d7-800fcedc6516" /> ## With clipping: ``` color/optimisation/r 0.5676486492156982 color/optimisation/g 0 color/optimisation/b 0 ``` <img width="3765" height="690" alt="Image" src="https://github.com/user-attachments/assets/ca0c42f7-292c-4ed4-93cc-de106502d7d0" /> <img width="256" height="256" alt="Image" src="https://github.com/user-attachments/assets/b5ff51eb-be66-4f6a-8bec-55f5b53a8c65" /> ## Without clipping ``` color/optimisation/r 0.5676485896110535 color/optimisation/g 0.04339996352791786 color/optimisation/b 0.041679296642541885 ``` <img width="3781" height="684" alt="Image" src="https://github.com/user-attachments/assets/b6c15e25-4cfa-4ed6-9023-ae9bdaf71f68" /> <img width="256" height="256" alt="Image" src="https://github.com/user-attachments/assets/0e830018-3943-4ddb-bdf9-73018ec5eefd" /> Even though the optimiser makes negative excursions, it recovers nicely and converges to the expected result.