help with my first shader

Dec 8, 2008 at 12:22am

help with my first shader

I’m attempting to write my first shader and could use a little help. It replicates a very simple modular patch I’ve been using for a while that simulates the flicker of a television screen on whatever is in front of it- the colors moving across the face of the viewer, etc. I’ll attach both the patcher and shader versions, and hopefully someone can correct me on what I’ve done wrong.

Thanks,
Zach

{
“boxes” : [ {
"box" : {
"maxclass" : "newobj",
"text" : "jit.matrix 4 char 4 4",
"id" : "obj-8",
"numinlets" : 1,
"fontname" : "Arial",
"numoutlets" : 2,
"outlettype" : [ "jit_matrix", "" ],
“patching_rect” : [ 148.0, 100.0, 112.0, 20.0 ],
“fontsize” : 12.0
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “jit.convolve”,
“id” : “obj-2″,
“numinlets” : 2,
“fontname” : “Arial”,
“numoutlets” : 2,
“outlettype” : [ "jit_matrix", "" ],
“patching_rect” : [ 106.0, 206.0, 70.0, 20.0 ],
“fontsize” : 12.0
}

}
, {
“box” : {
“maxclass” : “newobj”,
“text” : “jit.op @op +”,
“id” : “obj-11″,
“numinlets” : 2,
“fontname” : “Arial”,
“numoutlets” : 2,
“outlettype” : [ "jit_matrix", "" ],
“patching_rect” : [ 50.0, 281.0, 75.0, 20.0 ],
“fontsize” : 12.0
}

}
, {
“box” : {
“maxclass” : “inlet”,
“id” : “obj-10″,
“numinlets” : 0,
“numoutlets” : 1,
“outlettype” : [ "" ],
“patching_rect” : [ 78.0, 40.0, 25.0, 25.0 ],
“comment” : “”
}

}
, {
“box” : {
“maxclass” : “inlet”,
“id” : “obj-13″,
“numinlets” : 0,
“numoutlets” : 1,
“outlettype” : [ "" ],
“patching_rect” : [ 153.0, 40.0, 25.0, 25.0 ],
“comment” : “”
}

}
, {
“box” : {
“maxclass” : “outlet”,
“id” : “obj-14″,
“numinlets” : 1,
“numoutlets” : 0,
“patching_rect” : [ 55.0, 361.0, 25.0, 25.0 ],
“comment” : “”
}

}
],
“lines” : [ {
"patchline" : {
"source" : [ "obj-11", 0 ],
“destination” : [ "obj-14", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-13", 0 ],
“destination” : [ "obj-8", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-10", 0 ],
“destination” : [ "obj-2", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-10", 0 ],
“destination” : [ "obj-11", 0 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-8", 0 ],
“destination” : [ "obj-2", 1 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
, {
“patchline” : {
“source” : [ "obj-2", 0 ],
“destination” : [ "obj-11", 1 ],
“hidden” : 0,
“midpoints” : [ ]
}

}
]
}



simulates the flickering of a television screen

what is on the tv




< ![CDATA[

// texcoords
varying vec2 texcoord0;
varying vec2 texcoord1;

// samplers
uniform sampler2DRect tex0;
uniform sampler2DRect tex1;

// tv show
uniform vec4 show;

// entry point
void main()
{
vec4 a = texture2DRect(tex0, texcoord0);
vec4 b = texture2DRect(tex1, texcoord1);

vec4 convolution = mix(a,show);
gl_FragColor = convolution + b;
}

]]>

#41231

You must be logged in to reply to this topic.