Porting Shaders from Shadertoy

Jan 20, 2014 at 5:53am

Porting Shaders from Shadertoy

I have been inspired by the site Shadertoy, and am trying to port some of the more simple shaders from shadertoy into .jxs files for use withing max4live.

Shadertoy makes use of some standard uniforms.

uniform vec3 iResolution; // viewport resolution (in pixels)
uniform float iGlobalTime; // shader playback time (in seconds)
uniform float iChannelTime[4]; // channel playback time (in seconds)
uniform vec3 iChannelResolution[4]; // channel resolution (in pixels)
uniform vec4 iMouse; // mouse pixel coords. xy: current (if MLB down), zw: click
uniform samplerXX iChannel0..3; // input channel. XX = 2D/Cube
uniform vec4 iDate; // (year, month, day, time in seconds)

Are there similar uniforms within jitter?

I guess sampler2d and sampler2drect are analagous to the iChannel uniform? What about resolution and time uniforms?

Also is it possible to pass-in/reference an audio signal – I would really like to try to create shaders that reacted to an audio signal playing within live.

Jan 20, 2014 at 1:25pm

simple example of a shader -> gen port with audio input.


– Pasted Max Patch, click to expand. –


Jan 22, 2014 at 10:42am

Thanks so much for this…

I have found a number of examples of shaders that have been recreated as max patches but none that have an audio input.

Do you know if it is possible to reference audio from within the fp part of a .jxs file that is loaded into a jit.gl.slab object?

Jan 24, 2014 at 7:37am

Not sure what you mean.. Can you explain that a bit better?

Jan 29, 2014 at 10:21am

I am such a n00b – apologies if I struggle to explain myself well.

I have become inspired the rather excellent site http://www.shadertoy.com, and have been thinking about the best way to port some of the shaders into m4l, particularly the ones that are responsive to audio. I guess that shadertoy acts as an environment that can host shaders, and passes in certain variables (the uniforms listed in my first post).

I have been using the excellent V-Module suite created by Fabrizio Poce. He has created a few devices that you can use to load up .jxs files. What I would really like to do is to modify one of these devices to perform a similar job to the shadertoy website, i.e I can load in a .jxs file containing vp/fp programmes ported from shadertoy, and the device will feed in certain uniforms, textures, audio signals, that the shaders can process.

I guess I would be creating an audio effect device in m4l?

Looking at this example


the audio seems to be passed in as a texture into the fp code – I am not really sure how that would work in the world of jitter/m4l.

I hope that clarifies what I am trying to achieve – I really hope you can help point me in the right direction.

Jan 30, 2014 at 3:56am

If you want to go the “old school way” and work with jit.gl.slab
you will have to adapt your glsl shader.
Thats means that you need to write the corresponding xml header and add a second texture for your audio input (replacing the ichannel0 from the shadertoy example).
Use the “@inputs 2″ attribute to get another input for your jit.gl.slab object.

Hope that helps.

Feb 3, 2014 at 12:49pm

you can turn audio into a texture by first sampling into a jit.matrix, and then sending that matrix to the input of either jit.gl.pix, or jit.gl.slab.
lots of info on turning audio into a jitter matrix by searching the forum and tutorial articles, and checking out the following examples folder:
Max 6.1/examples/jitter-examples/audio/


You must be logged in to reply to this topic.