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

How to optimize SVBRDF(Texture) #10

Closed
tim37021 opened this issue Dec 20, 2018 · 4 comments
Closed

How to optimize SVBRDF(Texture) #10

tim37021 opened this issue Dec 20, 2018 · 4 comments

Comments

@tim37021
Copy link

tim37021 commented Dec 20, 2018

it generates mipmap automatically in pyredner module. I am not quite sure how I can optimize texture texels

text = torch.tensor(np.ones()*0.5, requires_grad=True, device=pyredner.device()))
material.diffuse_reflectance = pyredner.Texture(text)
...
optimizer = torch.optim.Adam([text])

for ...:
  // I have to add retain_graph=True here to get it work.
  render()
  loss.backward(retain_graph=True)
  // text update correctly, but rendered image does not change..
  // then text will be gradually broken...
  optimizer.step()
@tim37021
Copy link
Author

should I re-assign text to diffuse_reflectance??
it seems the texels is not updated even if text is change.

scene.materials[-2].diffuse_reflectance = pyredner.Texture(text)

@tim37021
Copy link
Author

If I try to rebuild the graph by reassign texture to diffuse reflectance.
Cuda memory access error will occur

@BachiLi
Copy link
Owner

BachiLi commented Feb 2, 2019

Hi,
The key is to do the re-assignment also in the gradient descent loop, so that PyTorch will propagate the derivatives for you. I added an example (and fixed a bug related to roughness texture derivatives) in https://github.com/BachiLi/redner/blob/master/tests/test_svbrdf.py
Let me know if there's other issues.

@BachiLi
Copy link
Owner

BachiLi commented Feb 10, 2019

Closing this issue. Feel free to reopen if there are other questions.

@BachiLi BachiLi closed this as completed Feb 10, 2019
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