[jitter] plane-to-sphere in a single jit.expr?
(())_n
kinomatic at gmail.com
Sat Dec 8 17:34:16 MST 2007
- Previous message: [jitter] Re: shifting row > jit.expr <
- Next message: [jitter] plane-to-sphere in a single jit.expr?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
HI Joshua, Randy, Here is the formula as shader vertex code. Thanks Wes and Marius (but it isn't quite round!) Get the patch, etc. here: http://home.earthlink.net/~posit/shader/ cheers (())_n // shader es.planesphere.vp.glsl code (())_n varying vec4 V; varying vec3 N; varying vec3 P; varying vec2 texcoord0; varying vec2 texdim0; #define PI 3.141519 uniform float shape; uniform float delta; vec3 surface(vec2 point) { vec2 p; // plane p.x = (point.x - 0.5) * 2.; p.y = (point.y - 0.5) * -2.; vec3 s_point; s_point.x = p.x * 1.33; s_point.y = p.y; s_point.z = 0.; vec2 pp; // sphere pp.x = (point.x-1.) * -2. * PI; pp.y = point.y * PI; float acc = sin(pp.y); vec3 t_point; t_point.x = cos(pp.x-1.57074)*acc; t_point.z = sin(pp.x-1.57074)*acc; t_point.y = cos(pp.y); s_point = mix(s_point,t_point,shape); return s_point; } void main (void) { vec4 W = vec4( surface(gl_Vertex.xy), 1.); vec3 neighbour1 = surface(vec2(gl_Vertex.x + delta, gl_Vertex.y)); vec3 neighbour2 = surface(vec2(gl_Vertex.x, gl_Vertex.y + delta)); vec3 tangent = normalize(neighbour1 - W.xyz); vec3 bitangent = normalize(neighbour2 - W.xyz); //get the normals into eye space N = normalize( cross(tangent, bitangent) ); N = mat3( gl_ModelViewMatrixInverseTranspose[0].xyz, gl_ModelViewMatrixInverseTranspose[1].xyz, gl_ModelViewMatrixInverseTranspose[2].xyz)*N; V = vec4(gl_Vertex.xy, 1., 1.); texdim0 = vec2 (abs(gl_TextureMatrix[0][0][0]),abs(gl_TextureMatrix [0][1][1])); texcoord0 = vec2(gl_TextureMatrix[0] * gl_MultiTexCoord0); gl_Position = gl_ModelViewProjectionMatrix*W; } On Nov 16, 2007, at 2:59 PM, Randy Jones wrote: > > Hi Joshua, > > the JavaScript from the audiovis_blob example, copied below, should > do the trick. The basic expr is in there if you need it. > > best, > Randy > > > On Nov 16, 2007, at 11:30 AM, joshua goldberg wrote: > >> i've been trying to figure out jit.expr's ways, and i'm still >> smacking my head against the wall a bit. >> >> is there a single object jit.expr method of duplicating the plane- >> to-sphere method in the jit.gl.render.sphere example patch, >> duplicated below? > > > > > // viz_poltocar > // > // small wrapper for a jit.expr which converts a 1d matrix > representing > // a height field into a 3 plane matrix giving the coordinate of > the field > // wrapped around a sphere. > // > // author: rej at 2uptech.com > > post ("---plane_to_sphere\n"); > autowatch = 1; > > var inputmatrix = new JitterMatrix(); > var outputmatrix = new JitterMatrix(); > var rest_size = 1.; > > var myexpr = new JitterObject("jit.expr"); > myexpr.planecount = 3; > myexpr.type = "float32"; > myexpr.adapt = 1; > myexpr.interp = 0; > > myexpr.expr = ["in[0] * cos((norm[1]-0.5)*PI) * cos((norm[0]-0.5) > *TWOPI)", > "in[0] * cos((norm[1]-0.5)*PI) * sin((norm[0]-0.5)*TWOPI)", > "in[0] * sin((norm[1]-0.5)*PI)"]; > > function jit_matrix(inname) > { > inputmatrix.setinfo(inname); > inputmatrix.frommatrix(inname); > > outputmatrix.setinfo(inname); > outputmatrix.planecount = 3; > > inputmatrix.op("+", "val", rest_size); > > myexpr.matrixcalc(inputmatrix, outputmatrix); > > outlet(0,"jit_matrix",outputmatrix.name); > } > > > > _______________________________________________ > jitter mailing list > jitter at cycling74.com > http://www.cycling74.com/mailman/listinfo/jitter
- Previous message: [jitter] Re: shifting row > jit.expr <
- Next message: [jitter] plane-to-sphere in a single jit.expr?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
