NVlabs / nvdiffrast

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

formula for screen-space derivatives #68

Closed minxuanjun closed 2 years ago

minxuanjun commented 2 years ago

@s-laine Hello, I have difficulties understanding the following code about the barycentric differential interpolation,
" 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); " could you help me out? Thank you!

_Originally posted by @minxuanjun in

s-laine commented 2 years ago

As a code comment states, du/dX = [d(u/w)/dX - u*d(1/w)/dX] * w, and here we set up the relevant constants, but I cannot recall the exact derivation. The formulas have been optimized quite a bit by grouping common subexpressions together, so there might not even be a simple geometrical meaning for the intermediate values in the code.

minxuanjun commented 2 years ago

Thank you very much!

At 2022-02-23 21:13:34, "Samuli Laine" @.***> wrote:

As a code comment states, du/dX = [d(u/w)/dX - ud(1/w)/dX] w, and here we set up the relevant constants, but I cannot recall the exact derivation. The formulas have been optimized quite a bit by grouping common subexpressions together, so there might not even be a simple geometrical meaning for the intermediate values in the code.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.Message ID: @.***>