Forums > Jitter

Having OpenGL Text Dissolve Into Particles?

January 2, 2013 | 12:26 pm

Hi, I am interested in having text generated using jit.gl.text2d or text3d turn into particles upon command. I have looked at jit.p.vishnu/shiva, but am uncertain as to how to connect text2d or 3d to such a patch. I also assume that Max 6 has similar particle systems as those two patches built-in, but am not yet familiar with Max 6.

This user was trying for the same effect: http://cycling74.com/forums/topic.php?id=1926
People referred him to Jitter Recipe #19 Tannenbaum (http://cycling74.com/2006/02/14/jitter-recipes-book-2/), but I truly do not see the connection between his aim and the Tannenbaum patch. In Tannenbaum, the text is rendered using jit.gl.text2d, but it doesn’t seem like any matrix operations are applied to the text after being rendered in text2d.

Another possibility I considered was deleting the text and putting in a particle system in its place, but the effect I feel would be far less convincing. So I would prefer to have the text itself as a matrix which could then "dissolve".

If anyone could provide a simple patch or reference to help me manipulate text in such a way it would be greatly appreciated!

Much thanks :)


January 2, 2013 | 7:01 pm

jit.gl.text3d supports matrixoutput, so you can send this matrix to your particle system and draw the result with jit.gl.mesh.

show us what you’ve got so far, and we can offer more help.


January 3, 2013 | 1:39 am

Hi Rob, thx for the reply. Using jit.gl.mesh was my original idea, but the connection between jit.gl.text3d and jit.gl.mesh seems more involved than with an object such as gridshape. Here is an example patch to show the discrepancy between how an object such as gridshape being used with jit.gl.mesh differs from an object like text3d being used with jit.gl.mesh:

– Pasted Max Patch, click to expand. –

As you can see, jit.gl.gridshape will render with a very simple, direct connection. I am unsure of the necessary matrix manipulations needed to turn jit.gl.text3d into jit.gl.mesh. Here is my attempt at imitating what’s in the helpfile for jit.gl.text3d, but still to no avail :/

– Pasted Max Patch, click to expand. –

If someone could post a simple patch connecting jit.gl.text3d to jit.gl.mesh, and perhaps explain the logic of what’s going on as well, that would be immensely helpful!


January 3, 2013 | 1:49 am

On a related, though different note, attached is my patch in full. The folder "falling_text" is just the patch with letters. The letters fall at random rates and random positions. This portion of the patch is completely functional and I am quite pleased with.

From that patch, I would like to be able to issue a bang and have the letters "dissolve". The other folder "falling_text+Particles" is my patch with an attempt at integrating the jit.p.shiva+jit.p.vishnu patches to create this effect. jit.p.vishnu+jit.p.shiva have given me quite some trouble in creating this effect. My problems: 1. The position doesn’t seem to work, as anytime I click the bang, the "dissolution" occurs in the middle of the screen. 2. I am unsure how to make the particles completely disappear. Setting the speed to -1 is the closest I have gotten, but still then there’s a little particle puddle at the bottom of the screen.

I think ultimately it would be much better and less cumbersome to use jit.gl.mesh, but again it’s just the translation problem of getting jit.gl.text3d into jit.gl.mesh.

Thanks again for any help :)


January 3, 2013 | 1:50 am

sorry double post!


January 3, 2013 | 5:31 pm

couple of issues with your patch.
first, jit.gl.text3d outputs matrices of triangle vertices, but the default drawing mode of jit.gl.mesh is tri_grid.
you can learn which drawing mode should to draw with matrixoutput by hooking a print object up to the matirxoutput.

to draw jit.gl.text3d with jit.gl.mesh, set @draw_mode triangles.

second, jit.gl.text3d is going to output a matrix for each letter every draw call.
so you need to turn off automatic drawing on your jit.gl.mesh, and draw explicitly with a bang, each time a letter matrix is received.

patch below demonstrates this.

– Pasted Max Patch, click to expand. –

January 3, 2013 | 5:37 pm

i made a text explosion patch a while back.
what i ended up doing was, at the moment of explosion, changing the drawmode of the jit.gl.mesh to points, and then applying a vertex shader to explode the points out.

the noise shader i used is below:


	
	
	
	
		
		
		
		
< ![CDATA[
//uniform vec3 Offset;
uniform float ScaleIn;
uniform float ScaleOut;

void main()
{
	//vec3 vertex = gl_Vertex.xyz + noise3(Offset + gl_Vertex.xyz * ScaleIn) * ScaleOut;
	vec3 vertex = gl_Vertex.xyz + noise3(gl_Vertex.xyz * ScaleIn) * ScaleOut;
    vec3 normal = normalize(gl_NormalMatrix * gl_Normal);
    //vec3 position = vec3(gl_ModelViewMatrix * vec4(vertex,1.0));

    float nDotVP;         // normal . light direction
    //float nDotHV;         // normal . light half vector
    //float pf;             // power factor
	vec4 amb;
	vec4 diff;
	//vec4 spec;

	nDotVP = max(0.0, dot(normal, normalize(vec3(gl_LightSource[0].position))));
	//nDotHV = max(0.0, dot(normal, vec3(gl_LightSource[0].halfVector)));

	//if (nDotVP == 0.0) pf = 0.0;
	//else pf = pow(nDotHV, gl_FrontMaterial.shininess);

	amb += gl_LightSource[0].ambient;
	diff += gl_LightSource[0].diffuse * nDotVP;
	//specular += gl_LightSource[i].specular * pf;
	gl_FrontColor = gl_FrontLightModelProduct.sceneColor + amb * gl_FrontMaterial.ambient + diff * gl_FrontMaterial.diffuse;

    //gl_TexCoord[0] = gl_MultiTexCoord0;
    gl_Position = gl_ModelViewProjectionMatrix * vec4(vertex,1.0);
}
]]>
		
		
< ![CDATA[
void main()
{
	gl_FragColor = gl_Color;
}
]]>
		
	

January 4, 2013 | 12:28 pm

rob, your jit.gl.mesh is working perfectly, and i’ve integrated it into my patch. many thanks. i haven’t used shaders as of yet, but will read up on the tutorials and look at the help file and try to figure it out. thanks so much for your thorough replies and being so generous with your knowledge. cheers!


January 4, 2013 | 2:11 pm

thanks so much rob! this does the trick :) shader looks really cool, and the programming looks somewhat straight forward, will definitely have to explore the power of this object in the future. thanks again!


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