To sample a triangle with vertices $A$, $B$, and $C$ uniformly, I can use the following formula:
$P = (1 - \sqrt{r_1}) A + (\sqrt{r_1} (1 - r_2)) B + (r_2 \sqrt{r_1}) C$
where $r_1$ and $r_2$ are random numbers between 0 and 1. The more samples you take, the better. But what if I want to reduce the number of samples?
For a square grid, I can implicitly divide it into an $N x N$ grid and generate a random sample inside the smaller grid squares. Like this:
float u = (x + rnd(seed)) / width; float v = (y + rnd(seed)) / height;
The point is I force the sampling to cover the entire grid at a lower sample resolution.
How can I achieve this with a triangle? The only way I can think of is to explicitly subdivide it into a number of triangles using a library like Triangle. But is there a way to do this implicitly with a formula like the above, without having to actually divide the triangle?
Aucun commentaire:
Enregistrer un commentaire