GGX importance sampling formula derivation I'm reading this paper and I'm struggling to work out a formula.
Maybe you can help me spot what I'm doing wrong.
In particular, I need to know how to get from equation (33) to equation (35).


Let me explain a little what this is all about.
So we have an infinite flat surface with normal $\vec{n}$. That surface, at the microscopic level, has some roughness $\alpha_g$ that makes the surface normal uneven.
$D(\vec{m})$ is a probability density function that tells us the probability to find a spot with micro-normal $\vec{m}$.
$\theta_m$ is the angle between the macro-normal and the micro-normal (i.e, $\theta_m = acos(\vec{m} \cdot \vec{n})$)
$\chi^+(x)$ is 1 if $x > 0$ and 0 otherwise.
The equation (35) is used for importance sampling for $D(\vec{m}) |\vec{m} \cdot \vec{m}|$. It gives the sampling direction given a random variable uniformly distributed between [0, 1], $\xi_1$.
This is how I attempt to solve the problem
First I'm going to compute the cumulative distribution function for $D(\vec{m}) |\vec{m} \cdot \vec{m}|$.
$$
D(\vec{m}) |\vec{m} \cdot \vec{m}| =
\frac{\alpha \chi^+(\vec{m} \cdot \vec{n})|\vec{m} \cdot \vec{m}|}
{\pi cos^4{\theta_m}(\alpha² + \tan(\theta_m))^2} =
\frac{\alpha cos^2{\theta_m}}
{\pi cos^4{\theta_m}(\alpha² + \tan(\theta_m))^2} =
\frac{\alpha}
{\pi cos^2{\theta_m}(\alpha² + \tan(\theta_m))^2}
$$
Now we compute de cumulative distribution function:
$$
C(\theta_m) = 
\int_0^{\theta_m}
\frac{\alpha}
{\pi cos^2{\theta_m}(\alpha^2 + \tan(\theta_m))^2}
dx =
\frac{\alpha^2}{\pi}
\int_0^{\theta_m}
\frac{1}
{cos^2{\theta_m}(\alpha^2 + \tan(\theta_m))^2}
dx
$$
I have tried to solve this integral with Maxima, but it seems to be stuck forever.
integrate(a^2/(%pi * cos(x)^2 * (a^2+tan(x)^2)^2), x, 0, x)

The same happens with Wolfram Alpha.
Am I missing something?
 A: Over the years, you may already know the answer. At that time, your missing is the wrong simplified spherical integral.
$$ 
C(X,Y) = \int_{0}^{Y}\int_{0}^{X}PDF(x,y) * sin(y)*dx*dy
$$

$$
C(X,Y) = \int_{0}^{Y}\int_{0}^{X}D(\vec N \cdot \vec {Nm})*(\vec N \cdot \vec {Nm}) * sin(y)*dx*dy \\
\vec {Nm} = sph2cart(x,y,1) 
$$

Because the integrand associated only elevation'y', so eliminate azimuth'x'[0,pi*2].
$$
C(Y) = 2\pi * \int_{0}^{Y}PDF(y) * sin(y)*dy \\
C(Y) = 2\pi * \int_{0}^{Y}D(cos(y))*cos(y) * sin(y)*dy \\
$$
Then input "2r^2sin(y)/(cos(y)^3 * (r^2 + tan(y)^2)^2)" into Integral Calculator
$$
Problem:\\
\int \frac{2*r^2*sin(y)}{cos(y)^3*(tan(y)^2 + r^2)^2} * dy \\
Apply\ linearity:\\
= 2*r^2 * \int \frac{sin(y)}{cos(y)^3*(tan(y)^2 + r^2)^2} * dy \\
 \\
Now\ solving:\\
\int \frac{sin(y)}{cos(y)^3*(tan(y)^2 + r^2)^2} * dy \\
Rewrite/simplify\ using\ trigonometric/hyperbolic\ identities:\\
= \frac{1}{2} * \int \frac{2*sec(y)^2 * tan(y)}{(tan(y)^2 + r^2)^2} * dy \\
Substitute\ u = tan(y)^2 + r^2,\ du = 2*sec(y)^2*tan(y)*dy:\\
= \frac{1}{2} \int \frac{1}{u^2}*du \\
... \\
... \\
... \\
2*r^2 * \int \frac{sin(y)}{cos(y)^3*(tan(y)^2 + r^2)^2} * dy \\
= - \frac{r^2}{tan(y)^2 + r^2}
$$
Final input "solve y = - Divide[Power[r,2],Power[tan(40)x(41),2 ]+Power[r,2]] + Divide[Power[r,2],Power[tan(40)0(41),2]+Power[r,2]] for x" into WolframAlpha
$$
Input \quad interpretation \\
solve \quad y = - \frac{r^2}{tan(x)^2 + r^2} + \frac{r^2}{tan(0)^2 + r^2} \quad for \quad x \\
Results \\
x = \pi*n - atan(\frac{r*\sqrt y}{\sqrt{1 - y}}) \quad and \quad r^3*y+r != r*y and ... \\
x = \pi*n + atan(\frac{r*\sqrt y}{\sqrt{1 - y}}) \quad and \quad r^3*y+r != r*y and ... \\
$$
Your idea is correct "Inverse CDF".
