Some screenshots of an alternative version of the superformula vertex shader. Where the previous version was based on a applying the superformula equation to a parametric sphere, this version applies the formula to a base torus (doughnut shape).
Again, no normal calculation.
Here’s a code-snippet, from the vertex shader:
// Superformula equation applied to a sphere or torus
vec3 sf3D(in float m, in float n1, in float n2, in float n3,
in float mb, in float n1b, in float n2b, in float n3b,
in float theta, in float phi)
{
float rt = superFormula(m, n1, n2, n3, theta);
float rp = superFormula(mb, n1b, n2b, n3b, phi);
float st = sin(theta);
float ct = cos(theta);
float sp = sin(phi);
float cp = cos(phi);
vec3 sSphere;
sSphere.x = rt * ct * rp * cp;
sSphere.y = rt * st * rp * cp;
sSphere.z = rp * sp;
vec3 sTorus;
sTorus.x = cp * (rp + rt * ct);
sTorus.y = sp * (rp + rt * ct);
sTorus.z = rt * st;
sTorus *= 0.55;
return (SphereTorus == 0.0) ? sSphere : sTorus;
}







Do you know “quick graph” on iphone/ipod touch…
and “graphly” and/or “GraphCalc” ?
regards,
Hi yanomano,
a very late response…
I’ve not tried any of those, to be honest. I may well go and look for them now though.
Thanks for the pointers,
a|x