jit.gl.slab example with 3 textures?


    Jan 06 2020 | 10:46 pm
    Hi, Is it possible to make 3 textures enter a jit.gl.slab object? (for, say, a 3-texture mixer, or a 2-texture mixer with LUT color mapping). Do you know of any Jitter-based example available? I haven't found one yet... Thanks, Jean-François.

    • Jan 07 2020 | 8:26 am
      Hi Jean-François,
      You can make a N-textures mixer by streaming them one after another (patch below) and if you have an arbitrary number of them, you can use a poly~ and send the output of each voice to the next. If you need a custom process with more than 2 texture, I think you'd better off using jit.gl.pix (though you cannot use shader file). You can export shader file from jit.gl.pix (and load them in a slab), but I am not aware that the opposite is possible. - Vincent
    • Jan 07 2020 | 2:48 pm
      Great, thanks for that, merci Vincent. I don't need the poly~ tip at this point, but it's a great one (what can you not do with poly~).
    • Jan 07 2020 | 4:16 pm
      to answer your original question, here is a simple slab that sums 3 inputs. use @inputs 3 in your slab box to create the necessary inlets.
      <jittershader name="default">
      	<description> Default Slab </description>
      	<param name="tex0" type="int" default="0" />
      	<param name="tex1" type="int" default="1" />
      	<param name="tex2" type="int" default="2" />
      	<language name="glsl" version="1.0">
      		<bind param="tex0" program="fp" />
      		<bind param="tex1" program="fp" />
      		<bind param="tex2" program="fp" />		
      		<program name="vp" type="vertex">
      <![CDATA[
      varying vec2 texcoord0;
      varying vec2 texcoord1;
      varying vec2 texcoord2;
      void main (void)
      {
          gl_Position = ftransform();
          texcoord0    = vec2(gl_TextureMatrix[0] * gl_MultiTexCoord0);
      	texcoord1    = vec2(gl_TextureMatrix[1] * gl_MultiTexCoord0);
      	texcoord2    = vec2(gl_TextureMatrix[2] * gl_MultiTexCoord0);
      }
      ]]>		
      		</program>
      		<program name="fp" type="fragment">
      <![CDATA[
      varying vec2 texcoord0;
      varying vec2 texcoord1;
      varying vec2 texcoord2;
      uniform sampler2DRect tex0;
      uniform sampler2DRect tex1;
      uniform sampler2DRect tex2;
      
      void main(void) 
      {
      	gl_FragColor = texture2DRect(tex0, texcoord0) + texture2DRect(tex1, texcoord1) +texture2DRect(tex2, texcoord2);
      }
      ]]>
      		</program>
      	</language>
      </jittershader>
    • Jan 07 2020 | 5:11 pm
      Thanks for that! @inputs 3, that's what I should have figured!