uci-rendering / psdr-cuda

Path-space differentiable renderer
BSD 3-Clause "New" or "Revised" License
155 stars 11 forks source link

[Question] How to determine which way the normal of the discontinuity curve points to? #32

Open uguuuuuu opened 1 year ago

uguuuuuu commented 1 year ago

There are two possible directions opposite to each other, and the choice affects the sign of $\Delta G$ in the multi-directional form of the boundary integral.

change-of-var

Vector3fC   e       = cross(bss.edge, _dir);

Vector3fC   proj    = normalize(cross(e, _its2.n));

Vector3fC n = normalize(cross(_its2.n, proj));
value0 *= sign(dot(e, bss.edge2))*sign(dot(e, n));

$x{0}^{D}$ and $x{0}^{S}$ are reversed in the code. But following the convention of the picture, I believe e is the normal of the orange plane, bss.edge the edge direction, _dir $\omega^{B}$, proj the tangent of the discontinuity curve at $x_{0}^{D}$, _its2.n the surface normal at $x_{0}^{D}$, n the normal of the discontinuity curve $\Delta\mathcal{M}(\pi)$, value0 $\Delta G$. It seems that it reduces to how you choose the normal direction e of the orange plane. Why did you choose to orient the orange plane by cross(bss.edge, _dir) but not cross(_dir, bss.edge)? And why the tangent vector proj of the discontinuity curve goes in the direction cross(e, _its2.n) but not the opposite? Finally, why the curve normal n to point in the direction of cross(_its2.n, proj) but not the opposite?

uguuuuuu commented 1 year ago

Is it because you guys follow an orientation such that for a point on a curve in a plane, the tangent, curve normal, and plane normal form a right-handed coordinate system?

LiuLinyun commented 1 year ago

Boundary normal direction of $x_0^D$ is same as geometry-term $G^{+}$. In eq[40], $\Delta G = G^{-} - G^{+}$

When your normal direction is right, $G^{+}$ equals 0 and $G^{}$ equals G computed normally between $x_0^D$ and $x_0^S$; and when your normal direction is left, $G^{+}$ equals G computed normally between $x_0^D$ and $x_0^S$ and $G^{-}$ equals 0.