Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vertex positions can't be differentiated #77

Closed
PidgeyBE opened this issue Apr 10, 2020 · 2 comments
Closed

Vertex positions can't be differentiated #77

PidgeyBE opened this issue Apr 10, 2020 · 2 comments

Comments

@PidgeyBE
Copy link
Contributor

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

@PidgeyBE
Copy link
Contributor Author

I found out that when I make e.g. one of the boxes an emitter, then I can '"optimize" its vertex coordinates...

@merlinND
Copy link
Member

Hello @PidgeyBE,

Please see #26 and PR #44.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants