NVlabs / nvdiffrast

Nvdiffrast - Modular Primitives for High-Performance Differentiable Rendering
Other
1.29k stars 139 forks source link

some doubts about geometry shader code #125

Closed zouxiaohang closed 1 year ago

zouxiaohang commented 1 year ago
float duwdx = dudx / w0;
float dvwdx = dvdx / w1;
float duvdx = (dudx + dvdx) / w2;
float duwdy = dudy / w0;
float dvwdy = dvdy / w1;
float duvdy = (dudy + dvdy) / w2;

vec4 db0 = vec4(duvdx - dvwdx, duvdy - dvwdy, dvwdx, dvwdy);
vec4 db1 = vec4(duwdx, duwdy, duvdx - duwdx, duvdy - duwdy);
vec4 db2 = vec4(duwdx, duwdy, dvwdx, dvwdy);

Hi, thank you first for your great framework. I have some doubts about the code and would like to consult you.

  1. why is dudx divided by w0, etc

  2. why duvdx - dvwdx, duvdy - dvwdy in db0

Can you provide the formula derivation or related papers at that time? Thanks !!!

s-laine commented 1 year ago

This has been addressed before in issue #49 and to some extent in #68. I hope those answers help you forward.

Also, if it's not too much trouble, I'd appreciate knowing why you are interested in the inner workings of this piece of code. I'm asking because there have been a surprising number of people asking about the exact same thing.

zouxiaohang commented 1 year ago

I have read issue 49 and 68 and I understand what these issues talk about, but i wonder why dudx divided by w0 instead of w1 or w2.

And because your work is very meaningful and at the same time I want to learn the algorithms involved in this work :)

zouxiaohang commented 1 year ago

and also why duvdx - dvwdx, duvdy - dvwdy in db0

s-laine commented 1 year ago

First see if you can understand the code in this reply in #49. If so, then the rest is just optimization.

zouxiaohang commented 1 year ago

Thanks for your reply, I continue to study your code