Skip to content

Vertex positions can't be differentiated #77

@PidgeyBE

Description

@PidgeyBE

Hey all

I'm trying to reproduce and play with the differentiable rendering example with the Cornell box described here: https://mitsuba2.readthedocs.io/en/latest/src/inverse_rendering/diff_render.html
All the steps described work, but if I e.g. want to try to differentiate/optimize OBJMesh_1.vertex_positions instead of red.reflectance.value, I get the following error when running the optimization:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-17-437578f9b545> in <module>
     10 
     11     # Back-propagate errors to input parameters
---> 12     ek.backward(ob_val)
     13 
     14     # Optimizer: take a gradient step
RuntimeError: set_gradient(): no gradients are associated with this variable (a prior call to requires_gradient() is required.) 

I tried all the Objects in the scene, but for none of them it is possible to optimize/differentiate with vertex_positions.
I find the error strange because the docs say the requires_gradient() call is automatically performed when initializing the Adam optimizer. Also if I do it manually before, it doesn't help...

So are there additional steps I should take to be able to optimize e.g. vertex_positions?

Thanks for helping! Pidgey

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions