pass vertex attribute matrix through jit.gl.sketch?

Jul 24, 2012 at 3:07pm

pass vertex attribute matrix through jit.gl.sketch?

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. –
#23887
Jul 25, 2012 at 2:14pm

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);
}

]]>

#68174
Jul 25, 2012 at 3:04pm

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?

#68175
Jul 25, 2012 at 3:42pm

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?

#68176
Jul 25, 2012 at 4:22pm

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

#68177
Jul 25, 2012 at 6:06pm

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. –
#68178

You must be logged in to reply to this topic.