I find the Jitter/OpenGL options overwhelming

estevancarlos's icon

I generally understand much of the theory behind MSP and have wrapped my head around Max. I also understand general concepts with non-OpenGL Jitter. However all the OpenGL concepts seem overwhelming and confusing to me. If I'm not mistaken, Jitter+OpenGL presents many different ways to skin a cat? How many external file formats are relevant to it? There's JXS, Lua, and others? And there's jit.gen. Does that offer the same type of functionality as JXS and Lua or are they completely different paradigms? I can't tell... it's really unclear to me how to approach this. The main question I have, which I'll rephrase, is: Do JXS (jit.slab), jit.gen, and Lua allow you to achieve the same results but in different ways?

metamax's icon

estevancarlos, my understanding is that [jit.gl.pix] is the only gen object that uses the GPU, much like [jit.gl.slab] - the difference being [jit.gl.pix] compiles the code internally while [jit.gl.slab] reads it from a file. It's not clear to me if there is a performance benefit to either compared to the other. I don't think there is but I vaguely recall that compiling it makes it bit faster than slab. Either way.. it's easier for me to build stuff in Gen than straight GLSL (openGL shader code) so I prefer [jit.gl.pix].

Regarding the relationship between jitter and GL. Standard Jitter uses the CPU and GL uses the GPU. Jitter also operates upon matrices (hence the term MOP objects... "matrix operator objects") while jit.gen/pix *generates* MOP objects. That is, when coding and patching within gen/pix, you don't think of the code as operating upon a matrix as much as it is defining the functionality of something that will. The main differences being, you can't access arrays or dynamically change dimensions, data types, etc. when patching inside gen. The compiled result is something that operates on a given input, but you need to define that matrix and access individual elements of that matrix elsewhere.

It's also worth noting that the benefits of using [jit.gl.pix] usually entail staying within the GPU domain as long as possible. Going back and forth between the GPU and CPU can be expensive so it's good to plan things out, get all of your matrices prepped for the journey to the GPU and only bring it back to the CPU as needed. Hope that helps. I'm only just starting getting the hang of it.

Joseph Hyde's icon

Metamax, you're obviously pretty on it with jit.gl.pix - I've found your posts on it really informative and clear. It's something I've been a little timid in getting into, mainly because there doesn't seem to be much in the way of documentation. Would you have any pointers you could give to find the way in?

Andro's icon

Hi Joseph.
Heres a link to a wiki page i made ( but never finished due to being a code noob)
https://cycling74.com/wiki/index.php?title=Porting_Shadertoy_tutorials_to_jit.gl.pix
It translates basic shadertoys tutorials into jit.gl.pix.
Was a great way for me to learn the basics.
Hope it helps !

johyde's icon

I did see that Andro - it's definitely on my 'to do' list. Thanks for doing that, and thanks for the reminder!

metamax's icon

johyde, check out the Joy of Swiz and read all of the reference docs. There isn't much available but it's a good start. I agree with Sandro about porting shaders. That's what I have been doing and it has helped me understand some basics. Learning how shaders work from the GL side of things is good too.

andro, I finished 27 of those tuts (I couldn't figure out one of them). I'll dig them up and post them. And I ported a boatload of other shaders... some are really nice. I don't know how the hell I did it. Anyway, I must have 50+ of them. I like the wiki, but we should also get a new thread started and flood it with shader examples to encourage more discussion.

edit: .... examples of from sources other than shadertoy as well...

johyde's icon

Thanks Metamax. I think I fundamentally don't understand shaders in some way - not so much the code but the concepts - the whole pipeline thing. Don't know why, but it's been a bit of a 'block' for me. I'll give it another go though - Christmas break ahead of me, and some nice starting points here. Having a go at porting something sounds like a good way to start. Yes, do post the ones you did if you get a chance!

Federico-AmazingMaxStuff's icon

Hey Johyde, you can check my tutorials on jit.gl.pix and jit.gen on my youtube channel: https://www.youtube.com/channel/UCvDUaH2fbXP_Yc5Lc9UXfqA
Basically there are three types of shaders: vertex, fragment and geometry (you don't see the last one so often though).
jit.gl.slab requires both vertex and fragment shaders, while jit.gl.pix is basically the gen way to write a fragment shader.
The vertex shaders work with, well, vertices. So if you apply a jit.gl.slab shader to a jit.gl.gridshape you can modify the shape of the object working on each vertex at a time. The fragment shader works out the final color of the shape or the image (if you're working with a jit.gl.videoplane).
It's important to get that when working with a fragment shader you're working with one pixel at a time. Your shader program will be applied to any pixel in a parallel way (the gpu is made to work in parallel using multiple cores).
Regarding the pipeline: it works like a server-client thing. The cpu is the client, the gpu is the server. You transfer instructions from the client to the server, which executes them. The slower part, as said, is the transferring of data between the cpu and the gpu.
When you use shaders, you modify the fixed pipeline to render things the way you want. And you can do that for any shape on your patch. The jit.gl.pix object can just create textures though.

metamax's icon

federicofod, great stuff! Thank you for sharing. I will be sure to check out your videos.

johyde, I still find shaders mysterious and have only recently become a bit obsessed with them. I'll post what I have. I just need to clean them up a bit.

estevancarlos's icon

Thanks for the response @metamax and thanks for those tutorials @FEDERICOFOD. I've noticed you sharing them on facebook. They're great. I'm reading an ebook on GLSL as I type this. As well as looking through the provided materials in Max. What I find overwhelming (and maybe I should get over it) is some of these file formats and different language styles that all relate to OpenGL. I probably just need to accept the way it is and continue studying. However I'm looking at *.jitmtl, *.glsl, *.jxs, *.jxp and that doesn't even include jit.gen.

I understand what jitmtl does. I sort of understand what jxs does. I'm completely unfamiliar with jxp. So many different things here.

Screen-Shot-2015-12-19-at-9.48.33-PM.png
png
Rob Ramirez's icon

.glsl files are OpenGL shader files and not specific to Jitter. the file contains glsl code defining a shader program, and the extension is arbitrary, but is usually something like glsl, fp, vp, frag, vert, program.

.jxs files are Jitter XML Shader files. they are XML formatted files that define a complete shader for use in Jitter. search the max reference for "The JXS File Format" for more info.

.jxp files are Jitter XML Pass files and are also XML files that define pass effects for loading in jit.gl.pass. search the file browser for the pass.custom.effects.maxpat example patch for more info.

.jitmtl are Jitter Material files, and are JSON dictionaries that define materials for importing / exporting from jit.gl.material.

hope this helps.

johyde's icon

Thanks everyone, and Estevancarlos - hope you don't mind me piling on to your thread. Some really useful stuff to look at there - that's my Christmas sorted!

Andrew Benson's icon

A more detailed explanation of JXS and writing GLSL for Jitter can be found in this article I posted in 2007:
https://cycling74.com/tutorials/your-first-shader/

I would also recommend Gregory Taylor's Gen series on this site to get started with Gen. For more examples, take a look at the most recent Jitter Recipes as well. Beyond a certain point, wrapping your head around GLSL and how it works will really help you get going with Gen in Jitter, especially concepts like vectors, sampling, mixing, and smoothsteps are very useful.

I personally find Gen to be a major help to getting work done in Jitter, and anymore my patches tend to look like jit.matrix-->jit.gen-->jit.gl.mesh, or jit.grab->jit.gl.pix->jit.gl.pix->jit.gl.pix->jit.gl.videoplane.
:)

metamax's icon

jit.grab->jit.gl.pix->jit.gl.pix->jit.gl.pix->jit.gl.videoplane.

Andrew, what are some good strategies for applying an unknown number of gl effects to an image/video? Instead of stringing together a bunch of fixed objects, I'd like to have a single [jit.gl.pix] object and change its contents with gen messages from from [umenu] - so the edited output becomes the new input. How is that best handled while staying on the GPU?

Chris Vik's icon

I'm going through your article on GLSL for Jitter, Andrew, but I can't seem to find the tut.blank.jxs anywhere in the Max 7 folder structure.
Any chance someone could copy/paste it here?

foldh's icon

Hi Chris, that .jxs file is part of the download included on Anthony's article from 2013. Direct link here > https://1cyjknyddcx62agyb002-web-assets.s3.amazonaws.com/shader_writing.zip

Great Vimeo tutorial by the way. Learned a few things there.

Chris Vik's icon

Cheers Foldh!
Have you got a link to the article itself?

And thanks for the praise. I'm posting week 2 to the Max project site shortly. And have another one in the works which should be out in another week or so.

foldh's icon

I look forward to the next video!