shaders in jit.gl.sketch?


    Feb 14 2006 | 10:33 pm
    Hi there,
    Can someone help me out with a quick example of how to use a jit.gl.shader in a jit.gl.sketch cmdlist? Is that possible?
    Thanks, Evan

    • Feb 14 2006 | 10:39 pm
      Works here. All I did was add this:
      to the sketch help file along with a message "shader x" connected to jit.gl.sketch. Adjust the shader parameter to see if it's working.
      wes
    • Feb 14 2006 | 10:57 pm
      True, that's one way. I was thinking more of applying shaders to different objects in a sketch cmdlist, like (in psuedo-code):
      1. enable texture 2. use texture 3. use shader (from jit.gl.shader) 4. draw sphere or other shape
      Just curious - I have a jit.gl.sketch drawing lots of concentric spheres, and it would be great to apply shaders to some of those spheres but not all.
      thanks, -evan
    • Feb 14 2006 | 11:05 pm
      > Just curious - I have a jit.gl.sketch drawing lots of concentric > spheres, and it would be great to apply shaders to some of those > spheres but not all. >
      In this case, I would be includes to use a gridshape with @automatic 0 and multiple draws. If you have 2+ gridshapes, you can assign them differenct shaders or none at all. You just need to manage scale and positioning. I posted some JS stuff in javscript-dev that outlined how to do this.
      good luck, wes
    • Feb 15 2006 | 12:41 am
      On Feb 14, 2006, at 2:57 PM, evan.raskob wrote:
      > True, that's one way. I was thinking more of applying shaders to > different objects in a sketch cmdlist, like (in psuedo-code): > > 1. enable texture > 2. use texture > 3. use shader (from jit.gl.shader) > 4. draw sphere or other shape
      Actually there's (undocumented) code in place for binding shader programs in jit.gl.sketch. The commands are glbindprogram , and glunbindprogram (which is equivalent to glbindprogram with no argument). So, assuming you have an instance of [jit.gl.shader @name shady] in your patch, something like the following should work. At bottom is a simple example with a similar program, plus some extra bells and whistles to make it look better.
      reset, glbindprogram shady, sphere 0.5, glunbindprogram shady, moveto -0.5 0. 0., glcolor 1. 0.7 0.5, sphere 0.5
      Note that you can also bind/unbind textures in a similar fashion with glbindtexture . To unbind, you would provide no argument. In fact you can actually implement something like slab with these commands if you set up the modelview transform and geometry properly. FWIW, before we made a C object for jit.gl.slab, we prototyped it with jit.gl.sketch.
      Let us know if you encounter any problems.
      -Joshua
    • Feb 15 2006 | 3:59 pm
      that's awesome joshua, that's just what i was hoping for.
      and to answer wesley (and anyone else who is interested), i'm using jit.gl.sketch because it allows you to draw and texture multiple shapes at once, and then with the capture attribute, you can render it to a texture and then put it through a series of slabs and such. since you can't render only a group of jit.gl.gridshapes together and have them capture to a single texture (as far as i can figure out), you need sketch. i have a massive patch that uses this to create a series of versions of a single sketch rendering, and then i use a crossfader slab to fade between each for seamless fx blending between each rendering, plus other layers of gridshapes mixed into the final scene. very hot. even at 640x480 for each texture (explicitly set using @dim 640 480), it runs incredibly well on my 2 year old powerbook.
      best, evan
    • Feb 15 2006 | 4:23 pm
      one odd thing - in the example patch in your email, changing the X,Y,Z values in the "moveto X Y Z" line makes no difference on my machine, jitter 1.5.2 in OS X 10.3.9. is that because of my admittedly incomplete understanding of OpenGL? it'd be great of you could explain why it works like that, or if it's not supposed to work like that...
      thanks, evan
    • Feb 15 2006 | 4:24 pm
      Hey Evan,
      >since you can't render only a group of jit.gl.gridshapes together >and have them capture to a single texture (as far as i can figure >out)
      This is not entirely true. Please see:
      This gives a technique for using the "to_texture" message for capturing a scene to texture. I would imagine that using jit.gl.sketch is probably your most efficient option anyway, so it sounds like you are doing fine. I would love to see the results. -- AB
    • Feb 15 2006 | 5:08 pm
      and one question about coordinates: which is the best jitter-object for tracking movement, if the movement is supposed to be sent as coordinates (x,y) to another programme like flash ? im looking something similar to what eyesweb has for tracking ,....
      thanks a lot in advance, m.
    • Feb 15 2006 | 5:08 pm
      dear all,
      i have a friend who is programming c++, how could his code be translated into an jitter-object ? or something that works with jitter patch ?
      best, m.
    • Feb 15 2006 | 5:14 pm
      Have a look at http://www.mat.ucsb.edu/~whsmith/jool.html . There you fill find a Codewarrior project for doing C++ in jitter. If you're working on Windows, check out the jit.atari2600 posts. Kyle, who wrote the external, has bee doing C++ in Jitter in Visual Studio. If you ask, I bet he'll send you the project and you can use it as a starting point for doing C++ in Jitter on windows.
      wes
    • Feb 16 2006 | 5:34 am
      Sounds interesting.
      I am working with "to_texture" by the moment, does the "capture" keyword also copy the current rendered scene in the front buffer into the using texture or it does other tricks ? It would be great if it can capture an off-screen buffer.
      I have been looking into the documentation and seems there is alot hidden command I can cast on the jit.gl.sketch object. Anyone know if there is a compete list of usable commands ?
      ^_^, William