[sharing] porting shaders to jit.gl.pix with codebox

alterprojects's icon

Hi y'all,

Just here to share some work Adam Rokhsar got into last month -- porting GLSL from Mr. Doobs wonderful shader sandbox ( http://glsl.heroku.com/ ) into jit.gl.pix using CodeBox. It's a great and relatively easy way to get complicated shaders running in Max, and I think there are some tools in here that will be really useful to the community (lots of ways to create nice looking sin waves that would be useful to artists doing A/V, for example).

All of this is pretty basic, and not all of it is running as it should, but hopefully this can be a starting point to getting more complicated shaders running in Gen, as I think there are a lot of very useful tools out there that could benefit the community.

Please let me know if you have any questions or if there are any scripts you would like help cracking into Gen.

JitGLPixForums.zip
zip
Rob Ramirez's icon

thanks for sharing!

i went ahead and ported the remaining ones you were having troubles with.
take a look, as there are some some simplifications i made that might help you out in the future.

more-gl.pix-shader-ports.zip
zip
alterprojects's icon

thanks Rob! yes this looks great and you elegantly illustrate some things I discovered later.

for those interested in doing this, I guess the most basic things to clear up are as follows:

resolution = [dim]
gl_FragCoord = [cell]
gl_FragCoord.xy / resolution.xy = [norm]

While I used the Gen objects and plugged them into inlets which were declared as variables in CodeBox, Rob's solution of just calling them up in CodeBox is much cleaner.

for people interested in more shaders google experiments produces a lot of very impressive shaders, albeit they are beyond my immediate capabilities. an example of one that I think would be very useful for many Jitter users would be from this cell shader from the project ro.me:

anybody feel like having a go at this with me?

bart at max (previously BITter)'s icon

Hello,

Interested because i am testing and learning to understand shaders now for months.
This to start using shaders more intensive in Jitter and WebGL.

But after a few hours diving in GLSL code i start to feel me weird :), so i don't know that i want to continue.

Anyway; can you explain me more about this and how to use Gen objects with CodeBox for this?
I don't think so, but; is there some possibility to write and visualise shaders direct in Max/Jitter?

LLT's icon

ALTERPROJECTS sorry I did not pay attention to your post.
I made my experience on my side and posted elsewhere .... :)

I come here now to share.

bart at max (previously BITter)'s icon

Thanks, already checking out!

Can i contact you for a small programming job?

alterprojects's icon

wow! great work. thanks for sharing... i will definitely dig into this :)

LLT's icon

It's great if there is movement on this side :D

@ BITTER
  If I can do something for you ....
contact@laurentlatorpille.com

LLT's icon
bart at max (previously BITter)'s icon

Nice shader one!
@LLT
Try to contact you but no answer.
Still interested?

artoo's icon

I am trying to get to grips with the .jxs file format.

alterprojects, you state that

gl_FragCoord.xy / resolution.xy = [norm]

I know that gl_FragCoord.xy / resolution.xy is the first line of many fragment shaders I have seen, and that this produces normalizes coordinates. I am struggling to work out how to express this within a .jxs file.

Have toy had any success in this regard?

alterprojects's icon

Hi R2, I'm not too familiar with .jxs but maybe your problem could be that you need to define your variables? posting an example would help solve your problem.

artoo's icon

I have been working using the bricks shader I lifted from this document

I thought this was good as it doesn't manipulate any textures passed through from the vertex program.

I thought it would be straightforward to replicate the background rectangles from this shader

But i can't seem to make it work - it obviously doesn't help that i have no idea what I am doing.

I thought it would be neat, and a great step forward in my glsl/jitter education to create a very simple shader with this rectangle background, and load it up into one of the devices from Fabrizio Poce's v-module suite, and pass in color and rectangle size variable as uniforms, and tweak them with my midi-controller.

Any assistance you can provide would be greatly appreciated.

artoo's icon

bricks.jxs zipped up

bricks.zip
zip
oli larkin's icon

anyone know if it would be possible to port this one to Jitter?

I've been trying to start by porting the blur shaders to .jxs but not having much luck

rdstart.zip
zip
Ben Bracken's icon

Oli, the example you linked to is doing a bunch of other stuff, but Wes's reaction diffusion example might be helpful to check out:

Max 6.1/examples/jitter-examples/gen/reaction.diffusion.color.world.maxpat

01ri's icon

I've been trying to port examples from http://glsl.heroku.com into jit.gl.pix using CodeBox. With everything involving lighting, it ends up looking green/yellow instead of black and white e.g. with the fairly simple example attached. Can anyone see what's going wrong?

I'm probably just missing something very obvious here.

Thanks,

jit.gl_.pix_lighting.maxpat
Max Patch
01ri's icon

Realised as soon as I'd posted.
Seems that putting one vec inside another just uses the first value in the vec.