Cramer's Rule for the calculation of alpha and beta in the 2nd book, chapter 6.5 #1648
Bowen951209
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to propose another way to calculate$\alpha$ and $\beta$ in quad intersection in chapter 6.5 in the 2nd book.$\alpha$ and $\beta$ using this formula:
In the book, we calculate
where$\vec{w} = \frac{\vec{n}}{\vec{n}\cdot\vec{n}}$ .
However, I've never seen the trick described in the book to calculate this. Instead, I would use Cramer's Rule. For a quick reminder, if we want to solve:
The solutions for$x$ and $y$ are:
If we assume that$\vec{p}$ can be the linear combination of $\vec{u}$ and $\vec{v}$ , then there must be solutions for $\alpha$ and $\beta$ .$\vec{p} = (p_{x}, p_{y}, p_{z})$ , $\vec{u} = (u_{x}, u_{y}, u_{z})$ , $\vec{v} = (v_{x}, v_{y}, v_{z})$ . And we want to solve the below equation for $\alpha$ and $\beta$ :
Set
In a clearer form:
To solve$\alpha$ and $\beta$ , you might think only two of the above equations are needed to get $\Delta$ , $\Delta \alpha$ , and $\Delta \beta$ in Cramer's Rule, but it's actually not the case. We can only use the components that ensures $\Delta$ is not $0$ , and this how I check it in
GLSL
:We simply find a non-zero$\Delta$ (and there must be at least one) and calculate the respective $\Delta \alpha, \Delta \beta$ , and solve $\alpha = \frac{\Delta \alpha}{\Delta}$ , $\beta = \frac{\Delta \beta}{\Delta}$ .
In my implementation in OpenGL, I get a 10% boost in the 5 quads scene at max ray depth of 50 and 200 samples.
Book's approach:
My approach:
Beta Was this translation helpful? Give feedback.
All reactions