JS capture jit.gl.mesh to texture (with jit.gl.node and automatic 0)
Hey there,
I'm trying to render my jit.gl.mesh to a texture with jit.gl.node and automatic 0 in JS .
It doesn't seem to work, I know I could render to jit.gl.texture with begincapture() stuff but I really need the node FSAA . Do you have an idea what the problem is ?
The JS code:
var window = new JitterObject("jit.window", "render_scene");
var render_scene = new JitterObject("jit.gl.render", "render_scene");
render_scene.erase_color = [0, 0, 0, 1];
var node = new JitterObject("jit.gl.node", "render_scene");
node.erase_color = [0, 0, 0, 1];
node.capture = 1;
node.adapt = 1;
node.automatic = 0;
node.depth_enable = 0;
var vertex_matrix = new JitterMatrix(3, "float32", 1024);
var my_expr = new JitterObject("jit.expr");
my_expr.expr = ["cos((norm[0]*0.75-0.125)*TWOPI)*0.76", "sin((norm[0]*0.75-0.125)*TWOPI)*0.76", "0"];
my_expr.matrixcalc(vertex_matrix, vertex_matrix);
videoplane = new JitterObject("jit.gl.videoplane", "render_scene");
videoplane.texture = node.out_name;
videoplane.transform_reset = 2;
videoplane.automatic = 0;
videoplane.depth_enable = 0;
var mesh = new JitterObject("jit.gl.mesh", node.name);
mesh.jit_matrix(vertex_matrix.name);
mesh.draw_mode = "points";
mesh.point_size = 5;
mesh.transform_reset = 2;
mesh.automatic = 0;
mesh.depth_enable = 0;
function bang(){
render_scene.erase();
mesh.draw();
node.draw();
videoplane.draw();
render_scene.drawclients();
render_scene.swap();
}
Thanks !
" another caveat, is you can't render in non-automatic mode when capturing to texture, so you must set automatic=1 "
https://cycling74.com/forums/capture-javascript-with-jit-gl-node
I post you a example.
if Rob see this patch, can he confirm that s the way to do it.
it seems to me a bit clumsy, but i did not find an other way.
I will prefer to draw on the node and capture without having to pass 2 bangs.
Is there a PROPER way?
Thanks
Hey SPA,
Thanks for the tips, it does work but as you said it looks a bit Clumsy/Hacky. Is there any other method I could use to render to a texture with FSAA ? I mean I know about the FXAA shader but it doesn't look as nice to me, maybe because it's post processing. I'm thinking about something like capture to jit.gl.texture with begincapture() stuff but with FSAA ?
Thanks for the help !
Best regards, louis
Also, with this technique, it seems impossible to render one jit.gl.mesh multiple times to a texture. Which is easy with jit.gl.texture way. Is there really any other option to render one jit.gl.mesh multiple times to a texture with FSAA ?
I think to capture a node, its got to be in automatic 1.
I spent quite a good time trying to find an other solution.
Perhaps try with jit.gl.sketch , you can draw objects.
If you find a way, keep posting.
Our only hope is a Rob solution ....
Yea I did try a lot of things yesterday but I didn't find any alternative ...
The node as to be in automatic 1 but also the object which is render, no ?
It's kind of annoying if you plane to render the same object multiple times to the node ...
Thanks for the help, I really appreciate this.
Let's hope for a Rob solution then !
try jit.gl.sketch...
unfortunately the jit.gl.node begin_capture notification is not currently supported in JS (this feature is described briefly here ).
Thanks for the info.
I'm using more and more Javascript for gl structures.
Rastering Gl branches seems obvious... Is there any plan to implement this begin_capture notification?
Is there an other JS way, instead of the method i use in my posted patch? (turning to automatic 1 for 2 bangs...)
When turning the node to automatic 0, i suppose that all the objects belonging to this node does not take ressources for rendering.
Is it the case also with anim.nodes? should i set to automatic 0 the main anim?
I'm capturing jit.gl.text.
Is there a way to access the indexes of the splits generated, with jit.gl.text with the line length arguments?
In JS, it seems that some objects need the use of external bang/pull messages, like jit.movie output_texture 1, jit.gl.slab.
So in some way, those object are not automatic, cos they still need to be driven by an external bang. is this correct?
I found on the forum (with difficulty) those method. Could you list somewhere in the reference those special procedure?
Many questions... happy new year!!!
thanks for this great leap forward for jitter Gl, those last years...
Kind of an issue I was having issues with. Thanks for info
I'm using more and more Javascript for gl structures.
Rastering Gl branches seems obvious... Is there any plan to implement this begin_capture notification?
I've logged a feature request to allow for receiving the begin_capture notification in JS via a JitterListener object. the capturing jit.gl.node will still require automatic enabled.
Is there an other JS way, instead of the method i use in my posted patch? (turning to automatic 1 for 2 bangs...)
based on my understanding of what's being asked, I don't see why non-automatic mode is necessary here (i.e. what can't be achieved with automatic rendering.
When turning the node to automatic 0, i suppose that all the objects belonging to this node does not take ressources for rendering.
Is it the case also with anim.nodes? should i set to automatic 0 the main anim?
the resources are still in use (textures, shaders, vertex buffers) but nothing will be rendered if automatic is disabled (same as enable is 0). you only need to set automatic 0 on anim.nodes if you are managing the transform hierarchy updates yourself (not recommended for most use cases).
I'm capturing jit.gl.text.
Is there a way to access the indexes of the splits generated, with jit.gl.text with the line length arguments?
I don't understand the question.
In JS, it seems that some objects need the use of external bang/pull messages, like jit.movie output_texture 1, jit.gl.slab.
So in some way, those object are not automatic, cos they still need to be driven by an external bang. is this correct?
slab / pix are driven by an input texture or matrix in the left inlet (or a bang if an updated input texture is not required). movie output is driven by a bang unless automatic is enabled.
I found on the forum (with difficulty) those method. Could you list somewhere in the reference those special procedure?
not sure what you're referring to.
In jit.gl.text, when you use the line_length > 0., it automaticaly wraps the text after this length.
I'd like to have access to the character slice of this wrap. like String.slice(i)
example: mode 3d
Text: Hello Jitter!
line_length: 1.5
result:
He
LLo
Jitt
er!
split result: 2 6 10
based on my understanding of what's being asked, I don't see why non-automatic mode is necessary here (i.e. what can't be achieved with automatic rendering.
I'm trying to use jit.gl.node as a raster capture for all the objects linked to it. so the resulting output_texture (on a videoplane) is only actualised when something change in the node.
this way, the node is off most of the time and does not use ressources of openGl for most of the time. does it make sense?
slab / pix are driven by an input texture or matrix in the left inlet (or a bang if an updated input texture is not required). movie output is driven by a bang unless automatic is enabled.
that's not the case in JS, no?
for slab, you've got to draw and pull the resulting texture for each frame:
slab .jit_gl_texture(texture.name);
slab.draw();
videoplane.texture = slab.capture;
but with jit.gl.texture you can set it once and it will be actualised automaticaly:
videoplane .jit_gl_texture(texture.name);
is this correct?
I'd like to have access to the character slice of this wrap. like String.slice(i)
currently outside the scope of jit.gl.text.
I'm trying to use jit.gl.node as a raster capture for all the objects linked to it. so the resulting output_texture (on a videoplane) is only actualised when something change in the node.
simply disable the node (via automatic 0 or enable 0) until your patch / JS logic detects that it needs updating.
that's not the case in JS, no? for slab, you've got to draw and pull the resulting texture for each frame:
slab.jit_gl_texture(texture.name);
slab.draw();
videoplane.texture = slab.capture;
i believe that last one should be videoplane.texture = slab.out_name;
but yes, that's essentially the same as the patch version of sending a texture to a slab input, which triggers the slab to process its texture and output.
following up on the jit.gl.node capture non-automatic objects from JS feature... looks like I was mistaken and this is already something that is possible from JS.
i've attached a basic example, please let me know if that doesn't work for you.
a bit late,
great and thanks a lot.
so basically, the node is processed between the :
1st : begin_capture
and ending with: capture
I'm going to test it in my text rastering.
I suppose that when node is in automatic 0 , it does not receive the begin_capture
Do you think that those js processes in the 'pipeline' are slowing down the rendering a lot?