Forums > Jitter

Losing resolution when rendering GL to jit.matrix

May 26, 2009 | 9:17 pm

I want to render an openGL scene to a jitter matrix to export it as a movie in jit.qt.movie, but when I do so the image becomes very pixelated and I substantially lose resolution. Does anyone know how to get around this without greatly increasing the dimensions of the matrix?


May 26, 2009 | 9:57 pm

I had the same question a few days ago, couldn’t find any solution Sad


May 26, 2009 | 10:46 pm

post a patch. this will help us figure out what’s going on. The rendering will have the resolution of the matrix you’re rendering into. Is this not the case?
wes


May 26, 2009 | 11:42 pm

In my tests this week, the rendering resolution has to do with the opengl window you are sending data to your matrix from…so if your matrix windows is fullscreen and your openGL window IS NOT you will see things pixelated like crazy. Having the GL and matrix window fullscreen at the same time will give you perfect resolution and stuff, but will slow your CPU down to a halt.


May 26, 2009 | 11:46 pm

I don’t really follow what’s going on. Are you rendering to a window and then somehow copying to a matrix? What is the flow?
wes


May 27, 2009 | 12:21 am

I am doing all my opengl goodness, then at the end of the day using gl.asyncread or whatever to load that into a matrix…the only way I get full resolution/details is if my matrix window is the same size as my opengl window…aka to have my matrix window fullscreen I would need to have my opengl fullscreen as well, slowing down cpu….try this:

render a rotating sphere with wireframe mode in opengl, then use gl.syncread (or whatever its called) to output that to a matrix…try to fullscreen ur matrix while the opengl screen is tiny


May 27, 2009 | 7:35 am
marcoskohler wrote on Tue, 26 May 2009 19:21
I am doing all my opengl goodness, then at the end of the day using gl.asyncread or whatever to load that into a matrix…the only way I get full resolution/details is if my matrix window is the same size as my opengl window…aka to have my matrix window fullscreen I would need to have my opengl fullscreen as well, slowing down cpu….try this:

render a rotating sphere with wireframe mode in opengl, then use gl.syncread (or whatever its called) to output that to a matrix…try to fullscreen ur matrix while the opengl screen is tiny

changing the size of the matrix display window has nothing to do with its internal resolution, only the jit.matrix dimensions do. what happens if you record a jit.qt.movie from your render, using jit.gl.asynchread, at a specific resolution—say 500 X 500—then play it back in a window that’s the same dimensions? is it still pixelated? It should be perfect, if I’m understanding this right.

Going fullscreen will therefore remap the size of what you see as the matrix, but not change the resolution at all. result=pixelation, especially with the rectangular screen vs. the generally square world of OpenGL, but the original matrix is fine. So keep track of what you’re recording using the jit.matrix and the render from jit.gl.render/asynchread should "look fine" if it’s played back at the same resolution (or a multiple/division of it should look pretty much OK too).

However, there are CPU slowdowns when going fullscreen in some cases, which I think is another issue, but I don’t know. Using very big jit.windows which cover the whole screen, but aren’t "fullscreen $1" generally solves this. You can eliminate the menubar too.


May 30, 2009 | 2:16 pm

I am having some problem of rendering in to a jit.matrix
Can anyone give me ae hand?
According to the documentation of jit.gl.sketch you can draw to a jit.matrix. But I cannot get it to work
I initialized my objects as;

window = new  JitterObject("jit.window", "draw_plane");
myrender = new  JitterObject("jit.gl.render", "draw_plane");
back_draw = new JitterMatrix("matrix_render");

When I draw;

myrender.send("erase");
myrender.send("draw_pixels", new Atom[] { Atom.newAtom("matrix_render") });
myrender.send("drawswap");
sketch.setAttr("drawto", "matrix_render");
sketch.send("reset");
DrawColorSquare(vo1, vo2, vo3, vo4,1.0f,0.0f,0.0f);

If I change the line;
sketch.setAttr("drawto", "matrix_render");
to
sketch.setAttr("drawto", " draw_plane");
I can see the color square I am drawing


May 30, 2009 | 5:02 pm

are you also banging your matrix each frame?


May 30, 2009 | 5:05 pm

Yes
I am trying to create a pond
I draw all the stuff in the pond using sketch
Then use the matrix to add water ripples


May 30, 2009 | 5:09 pm

again, my suggestion is to make this stuff work with a max patch, and then move to java if you still feel the need.


May 30, 2009 | 5:20 pm

Initially I was doing it as a max patch (not the water ripple)
After some time the logic became far too complex to handle in max patch. So I brought it into external the logic is very easy to handle
Anyway can you suggest anything on how to render to a matrix?


May 30, 2009 | 6:45 pm

yes, jit.gl.asyncread is for recording an opengl window and adjusts the matrix size it outputs to the size of the window. This is simply how the object works. To get a higer rez image, you need either a larger window to to render directly to a matrix. Either way, it’s going to be slow. reading back data from the gpu is not the fastest operation.

wes


May 30, 2009 | 6:49 pm

Thanks for the information
What about the code I have written. Is it wrong?


May 30, 2009 | 7:01 pm

I can’t find any documentation on the usage of jit.gl.asyncread


May 30, 2009 | 8:22 pm

here’s how to render opengl to a matrix. you have to set drawto on both the gl.render and the gl.sketch.

jit.gl.asyncread is fully documented in the help patch and reference page, as well as on the forum.

– Pasted Max Patch, click to expand. –

May 31, 2009 | 3:26 pm

Robtherich thanks for the information. I understand what needs to be done.

In my application I don’t output the matrix. I have the jit.window created within the code.
So how do I pass the matrix to the window in code?
I tried;
window.send("draw_pixels", new Atom[] { Atom.newAtom(back_draw.getName()) });
and it didn’t produce the results.
Following is the current code with the change you have suggested;
Init;

window = new  JitterObject("jit.window", "draw_plane");
myrender = new  JitterObject("jit.gl.render");
myrender.setAttr("erase_color",  new float[] {0.0f,0.0f,0.0f,1.0f });
sketch = new JitterObject("jit.gl.sketch");
back_draw = new JitterMatrix();
back_draw.setAttr("name","matrix_render");

drawing;

window.send("draw_pixels", new Atom[] { Atom.newAtom(back_draw.getName()) });
myrender.send("erase");
myrender.setAttr("drawto", back_draw.getName());
myrender.send("drawswap");
sketch.setAttr("drawto", back_draw.getName());
... draw some stuff

June 1, 2009 | 6:12 pm

guys, can you offer any advice on this?


June 1, 2009 | 8:53 pm

create a stripped down java class which only does the matrix readback, and a stripped down patch with comments detailing what you want to do and what’s not working.

post the patch, class files and java source as a zipped folder.


June 2, 2009 | 7:47 pm

Robtherich thanks for your help.

I have created simple application. The patch does nothing but send bang messages to the java external.
There are 2 sections in my code (section 1 is commented now)
If section 1 is uncommented and section 2 is commented you can see a red square. But if we do it other way it is not working (comment section 1 and uncomment section 2).

This is the problematic line
window.send("draw_pixels", new Atom[] { Atom.newAtom("matrix_render") });
but I don’t know what to use here

Inside the java external I create the jit.window, jit.gl.render and jit.gl.sketch using them I draw red square on the screen.
What I wanted to do is get the red square into a jit.matrix and render the jit.matrix on to the window

– Pasted Max Patch, click to expand. –

June 3, 2009 | 12:39 am

try changing the line to:
window.send("jit_matrix", back_draw.getName());

not sure if that’s it, but something like that.

also, you need to set the drawto attribute of both your gl.render and your gl.sketch, and not in the draw() method. it should only be set once at startup (or dynamically based on user input), not every frame.

lastly, the matrix should be sent to the window last, after all the gl stuff has rendered into it (you have it happening first in your draw method).


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