Closed tayloraswift closed 3 years ago
Checkout the eval_D2C1 and eval_D3C1 functions from SuperSimplexNoise.java, those provide what appears to be dx, dy, dxdy, and all the other various derivatives.
Edit: I just realized that gives you the numerical derivatives, not the analytical ones. I have the analytical equations, but the derivatives aren't super helpful unfortunately.
// Calculation of maximum value:
// x => real_rel_coords[0], y => real_rel_coords[1]
// a-h, components of gradient vectors for 4 closest points
// One contribution: (a*x + b*y) * (2/3 - x^2 - y^2)^4
// Limit per contribution: 0 <= x^2 + y^2 < 2/3
// skew = ((1 / sqrt(2 + 1) - 1) / 2)
// (a*x + b*y) * (2/3 - x^2 - y^2)^4 + (c*(x - 1 - 2 * skew) + d*(y - 1 - 2 * skew)) * (2/3 - (x - 1 - 2 * skew)^2 - (y - 1 - 2 * skew)^2)^4 + (e*(x - skew) + f*(y - 1 - skew)) * (2/3 - (x - skew)^2 - (y - 1 - skew)^2)^4 + (g*(x - 1 - skew) + h*(y - skew)) * (2/3 - (x - 1 - skew)^2 - (y - skew)^2)^4
// 0 <= x^2 + y^2 < 2/3 && 0 <= (x - 1 - 2 * skew)^2 + (y - 1 - 2 * skew)^2 < 2/3 && 0 <= (x - skew)^2 + (y - 1 - skew)^2 < 2/3 && 0 <= (x - 1 - skew)^2 + (y - skew)^2 < 2/3
// a^2 + b^2 == 1 && c^2 + d^2 == 1 && e^2 + f^2 == 1 && g^2 + h^2 == 1
If you plug that into Mathematica you can take derivatives Dx and Dy, which end up as
yikes
The derivatives for only one contribution (so you can just add them together after accounting for the different x and y positions, as in the eval_D2C1 and eval_D3C1 functions) are:
are x
and y
relative to the gradient point
Yes
Does anyone know how to compute the analytic derivative of SuperSimplex noise? The algorithm is so poorly documented I couldn’t find any information anywhere.