<?xml version="1.0" encoding="UTF-8"?>
	<rss version="2.0"
		xmlns:content="http://purl.org/rss/1.0/modules/content/"
		xmlns:wfw="http://wellformedweb.org/CommentAPI/"
		xmlns:dc="http://purl.org/dc/elements/1.1/"
		xmlns:atom="http://www.w3.org/2005/Atom"

			>

	<channel>
		<title>Cycling 74  &#187;  Topic: sharing is fun &#8211; Math Surface Shader</title>
		<atom:link href="http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/feed" rel="self" type="application/rss+xml" />
		<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/feed</link>
		<description></description>
		<pubDate>Wed, 19 Jun 2013 21:26:47 +0000</pubDate>
		<generator>http://bbpress.org/?v=2.2.4</generator>
		<language></language>

		
														
					
				<item>
					<guid>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-33668</guid>
					<title><![CDATA[sharing is fun &#8211; Math Surface Shader]]></title>
					<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-33668</link>
					<pubDate>Fri, 14 Sep 2007 01:39:52 +0000</pubDate>
					<dc:creator>Wesley Smith</dc:creator>

					<description>
						<![CDATA[
						<p>Hi folks,<br />
Here&#8217;s a shader and patch I made following the &#8220;Calculate Normals In<br />
Shader&#8221; blog entry on <a href="http://tonfilm.blogspot.com/" rel="nofollow">http://tonfilm.blogspot.com/</a> .  It should be<br />
quite easy to plug in other equations from<br />
<a href="http://local.wasp.uwa.edu.au/%7Epbourke/surfaces_curves/" rel="nofollow">http://local.wasp.uwa.edu.au/%7Epbourke/surfaces_curves/</a> .</p>
<p>This one implements the Tranguloid Trefoil equation:</p>
<p><a href="http://www.mat.ucsb.edu/~whsmith/ShaderSurface.zip" rel="nofollow">http://www.mat.ucsb.edu/~whsmith/ShaderSurface.zip</a></p>
<p>
wes</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112448</guid>
					<title><![CDATA[Re: sharing is fun &#8211; Math Surface Shader]]></title>
					<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112448</link>
					<pubDate>Fri, 14 Sep 2007 02:22:06 +0000</pubDate>
					<dc:creator>vade</dc:creator>

					<description>
						<![CDATA[
						<p>Nice one :)</p>
<p>I just picked up the Orange Book today, its been super helpful  <br />
already. Ive been able to properly antialias some of the procedural  <br />
texture generators ive made.</p>
<p>Might be interesting to put in two formulas and add mix() to morph  <br />
between vertex targets. Hmmm :)</p>
<p>On Sep 13, 2007, at 9:39 PM, Wesley Smith wrote:</p>
<p>> Hi folks,<br />
> Here&#8217;s a shader and patch I made following the &#8220;Calculate Normals In<br />
> Shader&#8221; blog entry on <a href="http://tonfilm.blogspot.com/" rel="nofollow">http://tonfilm.blogspot.com/</a> .  It should be<br />
> quite easy to plug in other equations from<br />
> <a href="http://local.wasp.uwa.edu.au/%7Epbourke/surfaces_curves/" rel="nofollow">http://local.wasp.uwa.edu.au/%7Epbourke/surfaces_curves/</a> .<br />
><br />
> This one implements the Tranguloid Trefoil equation:<br />
> <a href="http://www.mat.ucsb.edu/~whsmith/ShaderSurface.zip" rel="nofollow">http://www.mat.ucsb.edu/~whsmith/ShaderSurface.zip</a><br />
><br />
><br />
> wes</p>
<p>v a d e //</p>
<p><a href="http://www.vade.info" rel="nofollow">http://www.vade.info</a><br />
abstrakt.vade.info</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112449</guid>
					<title><![CDATA[Re: sharing is fun &#8211; Math Surface Shader]]></title>
					<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112449</link>
					<pubDate>Fri, 14 Sep 2007 02:30:35 +0000</pubDate>
					<dc:creator>Wesley Smith</dc:creator>

					<description>
						<![CDATA[
						<p>That&#8217;s kind of what electric sheep is doing with iterated function<br />
systems.  That system works by having 14 equations each with its own<br />
weight where they all add up to 1.  It morphs between functions by<br />
changing relative weights.  The only trouble with doing that in a<br />
vertex shader is how many equations th shader can take before it<br />
becomes slow.  I bet it could handle 3 on a good card, maybe more if<br />
they&#8217;re not very complicated.</p>
<p>wes</p>
<p>On 9/13/07, vade <doktorp @mac.com> wrote:<br />
>  Nice one :)<br />
><br />
> I just picked up the Orange Book today, its been super helpful already. Ive<br />
> been able to properly antialias some of the procedural texture generators<br />
> ive made.<br />
><br />
> Might be interesting to put in two formulas and add mix() to morph between<br />
> vertex targets. Hmmm :)<br />
><br />
><br />
> On Sep 13, 2007, at 9:39 PM, Wesley Smith wrote:<br />
><br />
> Hi folks,<br />
> Here&#8217;s a shader and patch I made following the &#8220;Calculate Normals In<br />
> Shader&#8221; blog entry on <a href="http://tonfilm.blogspot.com/" rel="nofollow">http://tonfilm.blogspot.com/</a> .  It should be<br />
> quite easy to plug in other equations from<br />
> <a href="http://local.wasp.uwa.edu.au/%7Epbourke/surfaces_curves/" rel="nofollow">http://local.wasp.uwa.edu.au/%7Epbourke/surfaces_curves/</a> .<br />
><br />
> This one implements the Tranguloid Trefoil equation:<br />
> <a href="http://www.mat.ucsb.edu/~whsmith/ShaderSurface.zip" rel="nofollow">http://www.mat.ucsb.edu/~whsmith/ShaderSurface.zip</a><br />
><br />
><br />
> wes<br />
><br />
> v a d e //<br />
><br />
> <a href="http://www.vade.info" rel="nofollow">http://www.vade.info</a><br />
> abstrakt.vade.info<br />
><br />
><br />
><br />
><br />
><br />
></doktorp></p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112450</guid>
					<title><![CDATA[Re: sharing is fun &#8211; Math Surface Shader]]></title>
					<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112450</link>
					<pubDate>Fri, 14 Sep 2007 02:42:46 +0000</pubDate>
					<dc:creator>vade</dc:creator>

					<description>
						<![CDATA[
						<p>I was actually thinking of staggering it, so each shader has 2  <br />
forumals in it, weighted between 0 and 1,</p>
<p>so you have shader &#8220;A&#8221; which has  1,2, shader b has  2 and 3, shader  <br />
c forumals 3 and 4</p>
<p>when you go from 1 to 2, you can then switch to shader b, go form 2  <br />
to 3, then to shader c which has 3 to 4 ?</p>
<p>I dunno, does having the shader uploaded but not bound waste GPU  <br />
cycles? I dont think so right?</p>
<p>Might be a solution :)</p>
<p>Either way, very cool.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112451</guid>
					<title><![CDATA[Re: sharing is fun &#8211; Math Surface Shader]]></title>
					<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112451</link>
					<pubDate>Fri, 14 Sep 2007 02:53:19 +0000</pubDate>
					<dc:creator>vade</dc:creator>

					<description>
						<![CDATA[
						<p>erm, formulas. Has someone been spending too many hours on forum- <br />
las ? *sigh* :)</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112452</guid>
					<title><![CDATA[Re: sharing is fun &#8211; Math Surface Shader]]></title>
					<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112452</link>
					<pubDate>Fri, 14 Sep 2007 02:59:10 +0000</pubDate>
					<dc:creator>Andrew Benson</dc:creator>

					<description>
						<![CDATA[
						<p>That&#8217;s cool, Wes.  I&#8217;m gonna definitely play around with this. And <br />
thanks for sharing that blog.  Some cool stuff there. </p>
<p>AB</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112453</guid>
					<title><![CDATA[Re: sharing is fun &#8211; Math Surface Shader]]></title>
					<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112453</link>
					<pubDate>Fri, 14 Sep 2007 03:00:36 +0000</pubDate>
					<dc:creator>Wesley Smith</dc:creator>

					<description>
						<![CDATA[
						<p>I was thinking something similar as well but with 3 instead of 2 but 2<br />
might be just as good with careful mixing.  Doing it this way<br />
shouldn&#8217;t be a problem at all GPU cycle-wise.</p>
<p>wes</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112454</guid>
					<title><![CDATA[Re: sharing is fun &#8211; Math Surface Shader]]></title>
					<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112454</link>
					<pubDate>Fri, 14 Sep 2007 03:46:31 +0000</pubDate>
					<dc:creator>joshua goldberg</dc:creator>

					<description>
						<![CDATA[
						<p>this looks cool, but i&#8217;m shocked and saddened about how slow it is on  <br />
my 1.67g4 albook.  is that a surprise?  it feels like 5fps.</p>
<p>
On Sep 13, 2007, at 9:39 PM, Wesley Smith wrote:</p>
<p>> Hi folks,<br />
> Here&#8217;s a shader and patch I made following the &#8220;Calculate Normals In<br />
> Shader&#8221; blog entry on <a href="http://tonfilm.blogspot.com/" rel="nofollow">http://tonfilm.blogspot.com/</a> .  It should be<br />
> quite easy to plug in other equations from<br />
> <a href="http://local.wasp.uwa.edu.au/%7Epbourke/surfaces_curves/" rel="nofollow">http://local.wasp.uwa.edu.au/%7Epbourke/surfaces_curves/</a> .<br />
><br />
> This one implements the Tranguloid Trefoil equation:<br />
> <a href="http://www.mat.ucsb.edu/~whsmith/ShaderSurface.zip" rel="nofollow">http://www.mat.ucsb.edu/~whsmith/ShaderSurface.zip</a><br />
><br />
><br />
> wes<br />
></p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112455</guid>
					<title><![CDATA[Re: sharing is fun &#8211; Math Surface Shader]]></title>
					<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112455</link>
					<pubDate>Fri, 14 Sep 2007 03:54:51 +0000</pubDate>
					<dc:creator>Wesley Smith</dc:creator>

					<description>
						<![CDATA[
						<p>Try reducing the dimensions of the input matrix.  I set it quite high.<br />
 BTW, what graphics card do you have?  Radeon 9700?  If so all of the<br />
trigonometric stuff might kill it and if the shape takes up large<br />
portion of the screen, the per-pixel lighting won&#8217;t help either.</p>
<p>wes</p>
<p>On 9/13/07, joshua goldberg <wugmump @speakeasy.org> wrote:<br />
> this looks cool, but i&#8217;m shocked and saddened about how slow it is on<br />
> my 1.67g4 albook.  is that a surprise?  it feels like 5fps.<br />
><br />
><br />
> On Sep 13, 2007, at 9:39 PM, Wesley Smith wrote:<br />
><br />
> > Hi folks,<br />
> > Here&#8217;s a shader and patch I made following the &#8220;Calculate Normals In<br />
> > Shader&#8221; blog entry on <a href="http://tonfilm.blogspot.com/" rel="nofollow">http://tonfilm.blogspot.com/</a> .  It should be<br />
> > quite easy to plug in other equations from<br />
> > <a href="http://local.wasp.uwa.edu.au/%7Epbourke/surfaces_curves/" rel="nofollow">http://local.wasp.uwa.edu.au/%7Epbourke/surfaces_curves/</a> .<br />
> ><br />
> > This one implements the Tranguloid Trefoil equation:<br />
> > <a href="http://www.mat.ucsb.edu/~whsmith/ShaderSurface.zip" rel="nofollow">http://www.mat.ucsb.edu/~whsmith/ShaderSurface.zip</a><br />
> ><br />
> ><br />
> > wes<br />
> ><br />
><br />
></wugmump></p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112456</guid>
					<title><![CDATA[Re: sharing is fun &#8211; Math Surface Shader]]></title>
					<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112456</link>
					<pubDate>Fri, 14 Sep 2007 03:56:58 +0000</pubDate>
					<dc:creator>vade</dc:creator>

					<description>
						<![CDATA[
						<p>lower the vert count. its currently at 100 ?<br />
On Sep 13, 2007, at 11:46 PM, joshua goldberg wrote:</p>
<p>> this looks cool, but i&#8217;m shocked and saddened about how slow it is  <br />
> on my 1.67g4 albook.  is that a surprise?  it feels like 5fps.</p>
<p>v a d e //</p>
<p><a href="http://www.vade.info" rel="nofollow">http://www.vade.info</a><br />
abstrakt.vade.info</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112457</guid>
					<title><![CDATA[Re: sharing is fun &#8211; Math Surface Shader]]></title>
					<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112457</link>
					<pubDate>Fri, 14 Sep 2007 10:37:23 +0000</pubDate>
					<dc:creator>didi bruckmayr</dc:creator>

					<description>
						<![CDATA[
						<p>hi wes!</p>
<p>that</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112458</guid>
					<title><![CDATA[Re: sharing is fun &#8211; Math Surface Shader]]></title>
					<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112458</link>
					<pubDate>Fri, 14 Sep 2007 15:02:35 +0000</pubDate>
					<dc:creator>Wesley Smith</dc:creator>

					<description>
						<![CDATA[
						<p>Hi Didi,<br />
Here&#8217;s your patch as a shader.  Not quite as smooth as nurbs but still nice.</p>
<p>wes</p>
<p>#P window setfont &#8220;Sans Serif&#8221; 9.;<br />
#P flonum 720 227 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;<br />
#P window linecount 1;<br />
#P message 720 247 59 196617 param6 $1;<br />
#P flonum 658 227 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;<br />
#P message 658 247 59 196617 param5 $1;<br />
#P flonum 596 227 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;<br />
#P message 596 247 59 196617 param4 $1;<br />
#P flonum 534 227 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;<br />
#P message 534 247 59 196617 param3 $1;<br />
#P flonum 472 227 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;<br />
#P message 472 247 59 196617 param2 $1;<br />
#P flonum 410 227 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;<br />
#P message 410 247 59 196617 param1 $1;<br />
#P flonum 348 228 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;<br />
#P message 348 248 59 196617 param0 $1;<br />
#P newex 416 304 76 196617 prepend param;<br />
#P flonum 329 284 70 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;<br />
#P message 329 303 78 196617 param delta $1;<br />
#P message 223 303 82 196617 file vd.math.jxs;<br />
#P newex 223 333 240 196617 jit.gl.shader test @file vd.math.jxs @name surface;<br />
#P button 107 196 15 0;<br />
#P newex 107 268 157 196617 jit.gl.mesh test @shader surface;<br />
#P newex 107 218 142 196617 jit.matrix 3 float32 100 100;<br />
#P newex 107 240 196 196617 jit.expr @expr &#8220;norm[0]&#8221; &#8220;norm[1]&#8221; &#8220;0&#8243;;<br />
#P message 158 81 34 196617 reset;<br />
#P newex 158 101 186 196617 jit.gl.handle test @inherit_transform 1;<br />
#P newex 23 101 48 196617 r render;<br />
#P toggle 138 72 15 0;<br />
#N vpatcher 53 128 279 297;<br />
#P inlet 106 30 15 0;<br />
#P window setfont &#8220;Sans Serif&#8221; 9.;<br />
#P window linecount 0;<br />
#P newex 43 95 47 196617 gate 1 1;<br />
#P newex 42 116 41 196617 s draw;<br />
#P window linecount 1;<br />
#P newex 17 52 58 196617 t b b erase;<br />
#P inlet 17 32 15 0;<br />
#P outlet 17 83 15 0;<br />
#P connect 1 0 2 0;<br />
#P fasten 2 2 0 0 70 75 22 75;<br />
#P connect 2 0 0 0;<br />
#P connect 4 0 3 0;<br />
#P fasten 5 0 4 0 111 88 48 88;<br />
#P fasten 2 1 4 1 46 83 85 83;<br />
#P lcolor 15;<br />
#P pop;<br />
#P newobj 76 101 42 196617 p Draw;<br />
#P toggle 214 40 15 0;<br />
#P message 214 60 68 196617 fullscreen $1;<br />
#N vpatcher 30 89 166 253;<br />
#P window setfont &#8220;Sans Serif&#8221; 9.;<br />
#P newex 50 71 35 196617 sel 27;<br />
#P newex 50 50 40 196617 key;<br />
#P outlet 50 93 15 0;<br />
#P connect 1 0 2 0;<br />
#P connect 2 0 0 0;<br />
#P pop;<br />
#P newobj 231 40 33 196617 p Esc;<br />
#P newex 214 78 151 196617 jit.window test @depthbuffer 1;<br />
#P toggle 76 53 15 0;<br />
#P newex 76 72 57 196617 qmetro 30;<br />
#P newex 76 128 187 196617 jit.gl.render test @erase_color 0 0 0 1;<br />
#P connect 33 0 20 0;<br />
#P connect 31 0 20 0;<br />
#P connect 29 0 20 0;<br />
#P connect 27 0 20 0;<br />
#P connect 25 0 20 0;<br />
#P connect 23 0 20 0;<br />
#P connect 21 0 20 0;<br />
#P connect 34 0 33 0;<br />
#P connect 32 0 31 0;<br />
#P connect 30 0 29 0;<br />
#P connect 28 0 27 0;<br />
#P connect 26 0 25 0;<br />
#P connect 24 0 23 0;<br />
#P connect 22 0 21 0;<br />
#P fasten 20 0 16 0 421 325 228 325;<br />
#P connect 13 0 12 0;<br />
#P connect 12 0 14 0;<br />
#P connect 19 0 18 0;<br />
#P connect 17 0 16 0;<br />
#P fasten 18 0 16 0 334 321 228 321;<br />
#P connect 5 0 3 0;<br />
#P connect 6 0 5 0;<br />
#P connect 4 0 6 0;<br />
#P connect 11 0 10 0;<br />
#P fasten 8 0 7 1 143 94 113 94;<br />
#P connect 15 0 13 0;<br />
#P fasten 10 0 0 0 163 123 81 123;<br />
#P connect 7 0 0 0;<br />
#P fasten 9 0 0 0 28 123 81 123;<br />
#P connect 1 0 7 0;<br />
#P connect 2 0 1 0;<br />
#P window clipboard copycount 35;</p>
<p>
////////////////////////////////////////////////////////////////Shader<br />
<jittershader name="phong-glsl"><br />
	<description>Shader Phong per-pixel lighting in GLSL</description></jittershader></p>
<param name="delta" type="float" default="0.01" />
<param name="param0" type="float" default="1." />
<param name="param1" type="float" default="0.1" />
<param name="param2" type="float" default="2." />
<param name="param3" type="float" default="0.3" />
<param name="param4" type="float" default="3." />
<param name="param5" type="float" default="1." />
<param name="param6" type="float" default="1." />
<p>
<param name="Ia" type="vec4" default="0. 0. 0. 0.0" /></p>
<param name="Ii" type="vec4" default="1. 1. 1. 1.0" />
<param name="eyePosition" type="vec3" default="0. 0. 4."/>
<param name="Ke" type="vec4" default="0.0 0.0 0.0 0.0" />
<param name="Ka" type="vec4" default="1.0 1.0 1.0 1.0" />
<param name="Kd" type="vec4" default="0.3 0.3 0.3 1.0" />
<param name="Ks" type="vec4" default="1.0 1.0 1.0 1.0" />
<param name="Ns" type="float" default="10." />
	<language name="glsl" version="1.0"><br />
		<bind param="delta" program="vp"></bind><br />
		<bind param="param0" program="vp"></bind><br />
		<bind param="param1" program="vp"></bind><br />
		<bind param="param2" program="vp"></bind><br />
		<bind param="param3" program="vp"></bind><br />
		<bind param="param4" program="vp"></bind><br />
		<bind param="param5" program="vp"></bind><br />
		<bind param="param6" program="vp"></bind>
<p>		<bind param="Ia" program="fp"></bind><br />
		<bind param="Ii" program="fp"></bind><br />
		<bind param="eyePosition" program="fp"></bind><br />
		<bind param="Ka" program="fp"></bind><br />
		<bind param="Kd" program="fp"></bind><br />
		<bind param="Ks" program="fp"></bind><br />
		<bind param="Ns" program="fp"></bind></p>
<program name="vp" type="vertex">
< ![CDATA[</p>
<p>varying vec3 N;<br />
varying vec3 P;</p>
<p>
#define PI 3.141519<br />
#define TWOPI 6.28</p>
<p>uniform float delta;<br />
uniform float param0;<br />
uniform float param1;<br />
uniform float param2;<br />
uniform float param3;<br />
uniform float param4;<br />
uniform float param5;<br />
uniform float param6;</p>
<p>vec3 surface(vec2 point)<br />
{</p>
<p>	vec3 s_point;</p>
<p>	/*<br />
	s_point.x = 2.*sin(3.*point.x) / (2. + cos(point.y));<br />
	s_point.y = 2.*(sin(point.x) + 2.*sin(2.*point.x)) / (2. +<br />
cos(point.y + 2.*PI / 3.));<br />
	s_point.z = (cos(point.x) &#8211; 2.*cos(2.*point.x))*(2. +<br />
cos(point.y))*(2. + cos(point.y + 2.*PI / 3.)) / 4.;<br />
	*/</p>
<p>	s_point.x = param1*(1.-((param0*param5*point.x*TWOPI)/TWOPI))*cos(param0*param4*param5*point.x*TWOPI)*(1.+cos(param0*param6*point.y*PI))+param3*cos(param0*param4*param5*point.x*TWOPI);<br />
	s_point.y = param1*(1.-((param0*param5*point.x*TWOPI)/TWOPI))*sin(param0*param4*param5*point.x*TWOPI)*(1.+cos(param0*param6*point.y*PI))+param3*sin(param0*param4*param5*point.x*TWOPI);<br />
	s_point.z = param2*((param0*param5*point.x*TWOPI)/TWOPI)+param1*(1.-((param0*param5*point.x*TWOPI)/TWOPI))*sin(param0*param6*point.y*PI);</p>
<p>	return s_point;<br />
}</p>
<p>
void main (void)<br />
{<br />
	vec4 V = vec4( surface(gl_Vertex.xy), 1.);</p>
<p>	//get the vertices into eye space<br />
	P = (gl_ModelViewMatrix*V).xyz;</p>
<p>	vec3 neighbour1 = surface(vec2(gl_Vertex.x + delta, gl_Vertex.y));<br />
	vec3 neighbour2 = surface(vec2(gl_Vertex.x, gl_Vertex.y + delta));</p>
<p>	vec3 tangent = normalize(neighbour1 &#8211; V.xyz);<br />
	vec3 bitangent = normalize(neighbour2 &#8211; V.xyz);</p>
<p>	//get the normals into eye space<br />
	N = normalize( cross(tangent, bitangent) );<br />
	N = mat3(	gl_ModelViewMatrixInverseTranspose[0].xyz,<br />
				gl_ModelViewMatrixInverseTranspose[1].xyz,<br />
				gl_ModelViewMatrixInverseTranspose[2].xyz)*N;</p>
<p>	gl_Position = gl_ModelViewProjectionMatrix*V;<br />
}<br />
]]>		
		</p></program>
<program name="fp" type="fragment">
< ![CDATA[</p>
<p>uniform vec4 Ia;<br />
uniform vec4 Ii;<br />
uniform vec3 eyePosition;<br />
uniform vec4 Ke;<br />
uniform vec4 Ka;<br />
uniform vec4 Kd;<br />
uniform vec4 Ks;<br />
uniform float Ns;</p>
<p>varying vec3 N;<br />
varying vec3 P;</p>
<p>void main (void)<br />
{<br />
	vec3 Nn = normalize(N);</p>
<p>	//ambient contribution<br />
	vec4 ambient = Ia*Ka;</p>
<p>	vec3 lightPosition = vec3(gl_LightSource[0].position);</p>
<p>	//diffuse contribution<br />
	vec3 L = normalize(lightPosition &#8211; P);<br />
	vec4 diffuse = Kd*Ii*max(dot(Nn, L), 0.);</p>
<p>	//calculate specular contribution<br />
	vec3 V = normalize(eyePosition &#8211; P);<br />
	vec3 H = normalize(L + V); //average of lighting and view vector)<br />
not true reflection vector<br />
	vec4 specular = Ks*Ii * pow(max(dot(Nn,H), 0.), Ns);</p>
<p>	gl_FragColor = Ke + ambient + diffuse + specular;<br />
}<br />
]]>		
		</p></program>
	</language><br />

						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112459</guid>
					<title><![CDATA[Re: sharing is fun &#8211; Math Surface Shader]]></title>
					<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112459</link>
					<pubDate>Fri, 14 Sep 2007 15:44:09 +0000</pubDate>
					<dc:creator>Andrew Benson</dc:creator>

					<description>
						<![CDATA[
						<p>I couldn&#8217;t let Wes have all the fun, so here is a version that does <br />
Spherical Harmonics.  I also threw in my special normal-dependent <br />
pixel-disposal sauce to make it that much more interesting.  Try <br />
animating the delta value and changing the fig/thresh params.  Also, the <br />
sphere param mixes between a sphere and the distorted shape, and of <br />
course you can extrapolate.  For those of you not running the latest and <br />
greatest hardware, I recommend lowering the jit.matrix dims. It does <br />
look really nice at 500&#215;500 though</p>
<p>I&#8217;m not usually a big supporter of mathematical surfaces, but I guess <br />
I&#8217;m beginning to see the light.</p>
<p>Happy Patching!</p>
<p>Andrew B.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112460</guid>
					<title><![CDATA[Re: sharing is fun &#8211; Math Surface Shader]]></title>
					<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112460</link>
					<pubDate>Fri, 14 Sep 2007 15:52:43 +0000</pubDate>
					<dc:creator>Andrew Benson</dc:creator>

					<description>
						<![CDATA[
						<p>oops, that patch had a minor issue.  This one will work better.</p>
<p>AB</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112461</guid>
					<title><![CDATA[Re: sharing is fun &#8211; Math Surface Shader]]></title>
					<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112461</link>
					<pubDate>Fri, 14 Sep 2007 16:28:35 +0000</pubDate>
					<dc:creator>keithmanlove</dc:creator>

					<description>
						<![CDATA[
						<p>All it did on my computer was completely kill the framerate for a black screen.</p>
<p>Max 4.6.3 Jitter 1.6.3<br />
1.67 Ghz Powerbook G4<br />
OS 10.4.10</p>
<p>May just be my problem,<br />
Keith</p>
<p>On 9/14/07, Andrew Benson <andrewb @cycling74.com> wrote:<br />
> oops, that patch had a minor issue.  This one will work better.<br />
><br />
> AB<br />
><br />
><br />
><br />
></andrewb></p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112462</guid>
					<title><![CDATA[Re: sharing is fun &#8211; Math Surface Shader]]></title>
					<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112462</link>
					<pubDate>Fri, 14 Sep 2007 16:44:58 +0000</pubDate>
					<dc:creator>Andrew Benson</dc:creator>

					<description>
						<![CDATA[
						<p>Hi Kieth,<br />
Try lowering the dimensions of the shape matrix to something reasonable <br />
(say 50&#215;50) or something and see if that helps.  It could just be that <br />
the shader pushes the limits of your graphics card.  I&#8217;ll have a look at <br />
it later and see if I can streamline the code a little.</p>
<p>AB</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112463</guid>
					<title><![CDATA[Re: sharing is fun &#8211; Math Surface Shader]]></title>
					<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112463</link>
					<pubDate>Fri, 14 Sep 2007 17:07:48 +0000</pubDate>
					<dc:creator>keithmanlove</dc:creator>

					<description>
						<![CDATA[
						<p>> Try lowering the dimensions of the shape matrix to something reasonable<br />
> (say 50&#215;50) or something and see if that helps.</p>
<p>That helped with the framerate.  I was confused by the complete black<br />
jit.window.  A little jit.gl.handle and parameter tweaking did the<br />
trick too.</p>
<p>Thanks,<br />
Keith</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112464</guid>
					<title><![CDATA[Re: sharing is fun &#8211; Math Surface Shader]]></title>
					<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112464</link>
					<pubDate>Fri, 14 Sep 2007 17:37:27 +0000</pubDate>
					<dc:creator>Wetterberg</dc:creator>

					<description>
						<![CDATA[
						<p>Andrew Benson skrev:<br />
> oops, that patch had a minor issue.  This one will work better.<br />
Looks fantastic!</p>
<p>I have just one issue with it, and that is that the texture params &#8220;fig&#8221; <br />
and &#8220;thresh&#8221; control an effect that seems quite jagged &#8211; is there a way <br />
to antialias there? That would make it even more awesome.</p>
<p>Andreas.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112465</guid>
					<title><![CDATA[Re: sharing is fun &#8211; Math Surface Shader]]></title>
					<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112465</link>
					<pubDate>Fri, 14 Sep 2007 17:52:52 +0000</pubDate>
					<dc:creator>Rob Ramirez</dc:creator>

					<description>
						<![CDATA[
						<p>andrew.<br />
can you show the web forum some love?</p>
<p>many thanks to all</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112466</guid>
					<title><![CDATA[Re: sharing is fun &#8211; Math Surface Shader]]></title>
					<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112466</link>
					<pubDate>Fri, 14 Sep 2007 18:04:53 +0000</pubDate>
					<dc:creator>Andrew Benson</dc:creator>

					<description>
						<![CDATA[
						<p>Unfortunately, this effect makes use of the &#8220;discard&#8221; method, which is <br />
either on or off.  Basically, it&#8217;s just throwing out pixels if the <br />
output of a formula falls below a threshold.  If you don&#8217;t care about <br />
depthbuffering, you can use a <br />
smoothstep(thresh,thresh+fwidth(goop)*fade,goop); and apply that to the <br />
glFragColor alpha.</p>
<p>If you do want to keep the depthbuffering and need antialiasing, you <br />
could always render to a double-size texture and do averaging <br />
downsamples, as has been discussed previously.</p>
<p>Best,<br />
Andrew B.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112467</guid>
					<title><![CDATA[Re: sharing is fun &#8211; Math Surface Shader]]></title>
					<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112467</link>
					<pubDate>Fri, 14 Sep 2007 18:50:32 +0000</pubDate>
					<dc:creator>Andrew Benson</dc:creator>

					<description>
						<![CDATA[
						<p>Oh, sorry.  Here you go.</p>
<p>AB</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112468</guid>
					<title><![CDATA[Re: sharing is fun &#8211; Math Surface Shader]]></title>
					<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112468</link>
					<pubDate>Mon, 17 Sep 2007 13:16:44 +0000</pubDate>
					<dc:creator>lists@lowfrequency.or</dc:creator>

					<description>
						<![CDATA[
						<p>Here&#8217;s a random question about this&#8230; not to provoke an argument,  <br />
but simply because I&#8217;m always curious about the &#8220;best&#8221; way of doing  <br />
anything.</p>
<p>Why do all this in a shader, why not use jit.expr to calculate  <br />
geometry for surfaces and then the normals?  Is there a benefit to  <br />
first calculating a normal-distribution-based coordinate spread for a  <br />
plane, and then using that as input into a shader?</p>
<p>I have a friend who does a lot of OpenGL programming, and he swears  <br />
by using only vertex arrays (especially cached) and standard opengl  <br />
blend modes.  But he doesn&#8217;t know shaders well, I feel like there  <br />
could be something he&#8217;s missing.</p>
<p>
Cheers<br />
Evan</p>
<p>
On Sep 14, 2007, at 2:39 AM, Wesley Smith wrote:</p>
<p>> Hi folks,<br />
> Here&#8217;s a shader and patch I made following the &#8220;Calculate Normals In<br />
> Shader&#8221; blog entry on <a href="http://tonfilm.blogspot.com/" rel="nofollow">http://tonfilm.blogspot.com/</a> .  It should be<br />
> quite easy to plug in other equations from<br />
> <a href="http://local.wasp.uwa.edu.au/%7Epbourke/surfaces_curves/" rel="nofollow">http://local.wasp.uwa.edu.au/%7Epbourke/surfaces_curves/</a> .<br />
><br />
> This one implements the Tranguloid Trefoil equation:<br />
> <a href="http://www.mat.ucsb.edu/~whsmith/ShaderSurface.zip" rel="nofollow">http://www.mat.ucsb.edu/~whsmith/ShaderSurface.zip</a><br />
><br />
><br />
> wes</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112469</guid>
					<title><![CDATA[Re: sharing is fun &#8211; Math Surface Shader]]></title>
					<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112469</link>
					<pubDate>Mon, 17 Sep 2007 14:51:59 +0000</pubDate>
					<dc:creator>nesa</dc:creator>

					<description>
						<![CDATA[
						<p>On Sep 17, 2007, at 3:16 PM, evan.raskob [lists] wrote:</p>
<p>> Here&#8217;s a random question about this&#8230; not to provoke an argument,  <br />
> but simply because I&#8217;m always curious about the &#8220;best&#8221; way of doing  <br />
> anything.</p>
<p>I guess my general practice is to let the system breathe&#8230; So stuff  <br />
as much as you can on a GPU, until it strats to choke.</p>
<p>> Why do all this in a shader, why not use jit.expr to calculate  <br />
> geometry for surfaces and then the normals?  Is there a benefit to  <br />
> first calculating a normal-distribution-based coordinate spread for  <br />
> a plane, and then using that as input into a shader?</p>
<p>It is simple, and since the vertices are sent only once &#8211; there&#8217;s  <br />
almost no performance hit.<br />
Also, as far as I know, shaders are incapable of creating new vertices.</p>
<p>
> I have a friend who does a lot of OpenGL programming, and he swears  <br />
> by using only vertex arrays (especially cached) and standard opengl  <br />
> blend modes.  But he doesn&#8217;t know shaders well, I feel like there  <br />
> could be something he&#8217;s missing.</p>
<p>he&#8217;s missing a lot! Many of the patches posted lately on the list  <br />
would be very hard, if not impossible, to recreate while using only  <br />
GPU without the shaders.</p>
<p>just my 0.2RSD</p>
<p>nesa</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112470</guid>
					<title><![CDATA[Re: sharing is fun &#8211; Math Surface Shader]]></title>
					<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112470</link>
					<pubDate>Mon, 17 Sep 2007 15:30:19 +0000</pubDate>
					<dc:creator>Wesley Smith</dc:creator>

					<description>
						<![CDATA[
						<p>> > Why do all this in a shader, why not use jit.expr to calculate<br />
> > geometry for surfaces and then the normals?  Is there a benefit to<br />
> > first calculating a normal-distribution-based coordinate spread for<br />
> > a plane, and then using that as input into a shader?<br />
></p>
<p>Imagine doing this:</p>
<p>x = 2 sin(3 u) / (2 + cos(v))<br />
y = 2 (sin(u) + 2 sin(2 u)) / (2 + cos(v + 2 pi / 3))<br />
z = (cos(u) &#8211; 2 cos(2 u)) (2 + cos(v)) (2 + cos(v + 2 pi / 3)) / 4</p>
<p>with jit.expr at 30fps on a 50&#215;50 grid.  You&#8217;re framerate will crawl<br />
if not die if you do it on the CPU.  On the GPU you can warp the<br />
coordinate range and other fun stuff dynamically for smooth<br />
animations.  jit.gl.mesh does use VBOs under the hood for sending the<br />
planar data so that is also fast.</p>
<p>> It is simple, and since the vertices are sent only once &#8211; there&#8217;s<br />
> almost no performance hit.<br />
> Also, as far as I know, shaders are incapable of creating new vertices.<br />
></p>
<p>
Not entirely true.  With Geometry shaders, you can generate quite a<br />
large number of vertices on the GPU.</p>
<p>><br />
> > I have a friend who does a lot of OpenGL programming, and he swears<br />
> > by using only vertex arrays (especially cached) and standard opengl<br />
> > blend modes.  But he doesn&#8217;t know shaders well, I feel like there<br />
> > could be something he&#8217;s missing.</p>
<p>VBOs are definnitely best practice for dispatching data to the GPU but<br />
shaders are required for complex rendering effects.  Blend modes are<br />
nice but limited.  For example, you can&#8217;t do per-pixel lighting with<br />
just VBOs and blend modes.</p>
<p>
wes</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112471</guid>
					<title><![CDATA[Re: sharing is fun &#8211; Math Surface Shader]]></title>
					<link>http://cycling74.com/forums/topic/sharing-is-fun-math-surface-shader/#post-112471</link>
					<pubDate>Mon, 17 Sep 2007 17:10:34 +0000</pubDate>
					<dc:creator>nesa</dc:creator>

					<description>
						<![CDATA[
						<p>> Not entirely true.  With Geometry shaders, you can generate quite a<br />
> large number of vertices on the GPU.</p>
<p>ah yes!(that is too new for my hardware:)</p>
<p>also, how would one do that with jitter?</p>
						]]>
					</description>

					
					
				</item>

					
		
	</channel>
	</rss>

