I always wanted to render this cool surface that apparently has a very simple ready to use equation.
(from Wikipedia)
Scherk's second surface looks globally like two orthogonal planes whose intersection consists of a sequence of tunnels in alternating directions. Its intersections with horizontal planes consists of alternating hyperbolas.
It has implicit equation:
Too bad for me, sinh() is a function that grows exponentially but raytracers need linear distance fields to render correctly. Also it's sign is not constantly positive.
But we can always do some math tricks. Let's see.
Sinh(a) = (exp(2*a)-1)/(2*exp(a))
If we replace, and bring the denominator to the left of the previous expression;

4*exp(x+y)*sin(z) = exp(2*(x+y)) - exp(2*x) - exp(2*y) +1;
If we call 4*exp(x+y)*sin(z) = J, and eliminate negative signs, we have;
J + exp(2*x) + exp(2*y) = exp(2*(x+y)) +1;Now it is a nice expression. Exp is always >= 0, so both terms have an expression that's always >= 0
except J. Log() can linearize an exponential field only if both equation terms are strictly > 0.
But nobody forbids to make a little cheat later on it. Supposing J>0, if we take logarithm on both terms we have log(N) = log(D), that equals to
log(N)-log(D)=0, or log(N/D)=0 (implicit surface expression), that always gives us real values if both N and D are >= 0.
Using this routine we can get a linear field that plots a Scherk;
float ScherkDe(float x, float y, float z)
{
float Ex=exp(x); float Ey=exp(y); float zz=Ex*Ey;
float N = Ex*Ex+Ey*Ey;
float D = 1+zz*zz;
zz = 4.*sin(z)*zz; // can be + or - or change 4 to get elliptic holes
if (zz>0) N += zz else D -= zz; // we bring it to the correct eq side :)
return abs(log(N/D))-.05; // give it a little thickness so it renders better
}
The surface as is it's boring but you can do variations
A cool one is
ScherkDe(k*sin(x), k*sin(y), z)/k;
Or try to do complex transform on x and y to create effects.
This gallery shows a lot of those lovely surfaces: (not much is clear though)
https://wewanttolearn.wordpress.com/2015/11/11/scherks-minimal-surface/