Forums > Jitter

Real-time drawing of incomplete planes.

Aug 16 2010 | 3:17 am


I’m looking for a way to draw incomplete plane shapes with gl.sketch (or other object, if it suits). Specifically, I’m working with a grid (be it jit.matrix or matrixctrl) in order to have control of which parts can be added or removed, depending on coordinates.

It works fine, except that I can’t figure the way to draw the result as a single shape, that can receive a texture in its entirety. What I mean with this is that regardless of the final plane’s shape, it should receive the texture as if it was a normal plane, or rectangle (as if it had a mask). Instead, every grid space is rendered its unique texture.

I’m also sure my method is very resource-wasteful. Please, if you could provide me any pointers in order to achieve my goal, I know this must be a complex thing…

-- Pasted Max Patch, click to expand. --

Aug 20 2010 | 9:34 pm

I’m bumping this thread because as of yet I haven’t found any solution on my own. Sketch drawing functions are too low-level for me to understand completely without some free time. Of course, I’m just asking for some pointers or some exemplary messages.

I devised another solution that involves slabs and videoplane masking. It works alright, but it demands much maintenance and power. I’m thinking sketch might be more economical to me.

Thanks in advance,

Aug 21 2010 | 1:51 am

Try the tex_map and tex_plane messages. I was able to get it closer to what you wanted, but not quite. There’s four variables and two planes to mess with, the third in the list never did anything. But with tex_map set to 3 you can stretch and offset the texture, and it’ll be one big texture over the whole image… couldn’t get it to stretch/position itself correctly though.

I like the mouse cell-draw function you have in there, for adding and removing the tiles in the 9×9 matrix. If you wanted, you could just merge that matrix with the main one, treat them both as movies/images rather than using sketch, which would give you what you were looking for… though with sketch you could get away from rectangles too.

This one just has a mini-module added to mess with the tex_map and tex_planes, and an All Off/All On for the tiles:

-- Pasted Max Patch, click to expand. --

Aug 23 2010 | 2:52 am


Thanks for your dedicated patch. I tweaked and tweaked but couldn’t get to properly set my textures. Now I’m not so sure this may be the way to go forward; I say this because I expect to have 9 tile-planes of that sort and that means +300 independent planes.

Maybe a very dedicated drawing routine for one single shape? That is out of my league, however.

I have been investigating and perhaps gl.mesh might be IT (or maybe gl.multiple). Is it possible to feed it a matrix with vertex coordinates to produce the tile/grid effect I’m looking for? If it is, could you please provide me with the basic stuff for translating my 9×9 char matrix into a float32 matrix with vertex coordinates? (I did went through the jit.expr tutorial but this seems quite a specific need)

Thanks for your time, again,

Aug 23 2010 | 4:31 am


With working with jit.expr I’m meaning a way to procedurally position only those pixels that are at 255 in the original char matrix: some tiles on and some off, but using the texture coordinates of a complete plane.

Aug 23 2010 | 4:28 pm

maybe instead of working with the tex_plane attributes directly, use this handy abstraction:

-- Pasted Max Patch, click to expand. --

Aug 23 2010 | 4:41 pm


It works like magic with my texture so thanks. Now I’ll see if this same principle can be applied to a grid made up with, which might come easier for my GPU.

Aug 23 2010 | 6:03 pm

There are a couple of things that strike me here as possible venues for exploration. If you are looking to essentially turn on and off rectangular sections of a larger textured plane, why not just generate an alpha channel and turn on blend_enable? You can use @file cc.alphaglue.jxs to apply an arbitrary alpha texture. If you want to break up a single texture to be used on an array of textured quads, you might try using a combination of jit.expr and to generate the geometry. For some examples, check out Jitter Recipes 36-38

Let us know what you come up with.

Aug 23 2010 | 6:19 pm

I did explore the slabs alternative; the problem is that I’m already pushing too many slabs already and I need to work with 9 different plane-grids.

I am now exploring for the first time the possibilities of gl.multiple and jit.expr. Below is what I have done so far: the part where I translate positions to a float32 matrix is particularly painful to see. Also, I’m aware my jit.expressions are pretty bad.

If you think gl.mesh is better suited for this task, or if you could offer the expression I should be using for positioning the tiles in gl.multiple I would appreciate it, as my head is about to explode.

-- Pasted Max Patch, click to expand. --

Aug 24 2010 | 5:45 am

I managed to work out something more decent than my last patch. At least I’m outputting the tiles in (mostly) the correct positions with mesh. If I manage to correct the weird vertex problem I’m having with textures and certain positions, plus realigning my quads as if they were one single plane, I’d consider myself happy.

Of course, this is way over my head for now (never really messed with expr or meshes before), so if you can lend me a hand or give me some pointers. I’m not asking for the complete homework, just some meaningful tips please.

Thanks everybody,

Rehash of nº 36, this time readable and respectful to the viewer:

-- Pasted Max Patch, click to expand. --

Aug 24 2010 | 11:57 pm

And here is a much improved version of what I’m trying to accomplish. Now it’s only fault is placement, scale (preferably 1.333, 1.) and vertex for the individual textures.

Any ideas?

This is a composite hack from nº 36 and 38 of mesh tutorials.

-- Pasted Max Patch, click to expand. --

Aug 25 2010 | 5:50 pm

can’t you just scale and position the gl.mesh using attributes?

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

Forums > Jitter