now my secret identity is known. my vigilante days are numbered!
:)
Here is a sample fragment shader that implements one of the blend
modes (overlay) for A/B mixing. If you can show me how to get this
working in a patch that has two texture inputs for one rect object at
the end of a gemhead render chain, that would really be awesome, and
I could wrap it easily in an abstraction.
Thanks for taking the time to look at it. Yeah, I know, weird Jitter
texcoord template, deal with it :)
---- fragment shader uniform vec4 amount;
// define our rectangular texture samplers uniform sampler2DRect tex0; uniform sampler2DRect tex1;
// define our varying texture coordinates varying vec2 texcoord0; varying vec2 texcoord1;
vec4 one = vec4(1.0); vec4 two = vec4(2.0); vec4 lumcoeff = vec4(0.2125,0.7154,0.0721,0.0);
vec4 overlay(vec4 myInput, vec4 previousmix, vec4 amount) { float luminance = dot(previousmix,lumcoeff); float mixamount = clamp((luminance - 0.45) * 10., 0., 1.);
vec4 branch1 = two * previousmix * myInput;
vec4 branch2 = one - (two * (one - previousmix) * (one - myInput));
vec4 result = mix(branch1, branch2, vec4(mixamount) );
vec4 mixresult = mix(previousmix, result, amount);
return mixresult;
}
void main(void) { vec4 input0 = texture2DRect(tex0, texcoord0); vec4 input1 = texture2DRect(tex1, texcoord1);
vec4 mix1 = overlay(input1, input0, amount* two );
vec4 mix2 = overlay(input0, input1, (1.0 - amount) * two );
vec4 result = mix(vec4(mix1.rgb,1.),vec4(mix2.rgb,1), amount);
gl_FragColor = result;
}
---- vert shader
varying vec2 texcoord0; varying vec2 texcoord1;
void main() { // perform standard transform on vertex gl_Position = ftransform();
// transform texcoords
texcoord0 = vec2(gl_TextureMatrix[0] * gl_MultiTexCoord0);
texcoord1 = vec2(gl_TextureMatrix[1] * gl_MultiTexCoord1);
}
On Jul 1, 2007, at 11:47 AM, chris clepper wrote:
Anton
You want to set the texture unit that pix_texture uses correct?
pix_texture should take a 'texunit $1' (or texUnit) message to do
this. Multitexturing was one of Jamie's projects which remains
unfinished...Send me a shader to work with if you can't get it working.
On 6/29/07, vade doktorp@mac.com wrote: Hello
i am looking for an example patch, or how to for multitexturing. Im
trying to port some GLSL shaders that implement mixers over to GEM.
How do I get gl_TextureMatrix[0] and [1], etc so to speak onto a rect?thanks, forgive me if this is obvious, but I looked around and did
not see any example code.v a d e //
www.vade.info abstrakt.vade.info
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/ listinfo/pd-list
v a d e //
www.vade.info abstrakt.vade.info