08
Nov
08

Superformula Toroidal Mapping

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;
}
About these ads

2 Responses to “Superformula Toroidal Mapping”


  1. 1 yanomano
    November 24, 2008 at 10:30 pm

    Do you know “quick graph” on iphone/ipod touch…
    and “graphly” and/or “GraphCalc” ?

    regards,

  2. 2 toneburst
    December 19, 2008 at 1:08 am

    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


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Twitter

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

November 2008
M T W T F S S
« Oct   Dec »
 12
3456789
10111213141516
17181920212223
24252627282930

Links

Blog Stats

  • 395,102 hits

Follow

Get every new post delivered to your Inbox.

Join 35 other followers

%d bloggers like this: