Forums > Jitter

pass vertex attribute matrix through jit.gl.sketch?

July 24, 2012 | 3:07 pm

Hi all,

I am rendering a geometry twice in the screen using a named jit.gl.mesh and a jit.gl.sketch.
The mesh geometry is being processed by a shader, which is bound and unbound through OpenGL commands in the jit.gl.sketch command list.

The shader is taken from Pelado’s morph shader example, and it is intended to deform geometry vertices by means of a noise matrix, which is passed to the shader through as vertex attribute matrix.

My question is: how can I pass this vertex attribute matrix to jit.gl.sketch? when I pass it through jit.gl.mesh, as in Pelado’s example, it doesn’t work.

here is my code, thanks in advance

– Pasted Max Patch, click to expand. –

July 25, 2012 | 2:14 pm

I forgot to include the shader:

/////dShader.txt /////////////////////////////////////////////////////////////




< ![CDATA[

attribute vec4 ATTR_vertex;
uniform float morph;

void main()
{

vec4 pos = mix(gl_Vertex, ATTR_vertex , morph);
pos = normalize(pos);
gl_Position = gl_ModelViewProjectionMatrix * pos;
gl_TexCoord[0] = (gl_TextureMatrix[0] * gl_MultiTexCoord0);

}
]]>

< ![CDATA[

uniform sampler2DRect noiseTex;

void main()
{
gl_FragColor = texture2DRect(noiseTex, gl_TexCoord[0].st);
}

]]>


July 25, 2012 | 3:04 pm

i’m not sure if it’s possible to pass vertex attributes to a gl.mesh that is drawn by a gl.sketch.
is there any particular reason you need to use sketch to do your drawing?


July 25, 2012 | 3:42 pm

Thanks for your answer Robert! I am using jit.gl.sketch to draw the geometry because I thought that this method would spare a lot of resources when rendering the same vertices (jit.gl.mesh) twice… but maybe there are other options?


July 25, 2012 | 4:22 pm

should be no more efficient than setting @automatic 0 on your gl.mesh and banging it twice each frame.


July 25, 2012 | 6:06 pm

SOLVED – Thank you Robert, you gave me the right clue!!

I finally made it work with jit.gl.sketch. In my earlier patch, I was giving unnecessary openGL commands, but it was as simple as treating the jit.gl.mesh as any other object, independently of its having a shader or not.
The binding and unbinding of texture and shader programs is already handled automatically by Jitter in the [jit.gl.mesh] object, so why outhink the smart Cycling74 programmers? :p.

Below the corrected, working patch, the shader is the same I posted earlier.
For anyone interested, the 2 bang method Robert was talking about is in this post: http://cycling74.com/forums/topic.php?id=273

– Pasted Max Patch, click to expand. –

Viewing 6 posts - 1 through 6 (of 6 total)