hi everybody!
im experimenting with some camera tracking and want to make a water surface, that is triggering waves where motion is detected.
i found an old patch wich makes displacement according to a greyscale image so i build a little machine in a gemframebuffer that casts waves and feed it to the glsl displacement shader wich works good.
now here is my problem:
i want to display a separate image on the geometry distorted by glsl shader.
but i have no idea how to modify the shader so i can feed her 2 textures
can somebody help me?
-
GLSL question
-
so basically i want to use one texture for the displacement, wich happens in the vertex shader
and another for the color, wich happens in the fragment shader.i have no idea, if its possible to feed a gemchain 2 textures, so a workaround i could imagine is to have the 2 textures merged side by side on one, and taking them apart again by using texture coordinates.
///vertex shader
uniform float K;
uniform vec4 translate;
uniform sampler2D tex0;void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
vec4 color = texture2D(tex0,gl_TexCoord[0].st);
float x = (color.r+color.g+color.b)/3.;
gl_Position = gl_ModelViewProjectionMatrix * (gl_Vertex + vec4(0.,0.,x,0));}
///fragment shader // Cyrille Henry 2007
uniform sampler2D tex0; /// here tex1 should be used somehow..?
void main()
{
vec2 C = gl_TexCoord[0].st;
gl_FragColor = texture2D(tex0, C); /// here tex1 should be used somehow..?
} -
you can find a solution for GLSL multitexture in this help patch:
GEM -> Examples -> 10.glsl/ > 05.multitexture.pdhope this helps.
it's not straightforward to me, but should work.and if you have a spare moment please give me feedback on this
http://puredata.hurleur.com/sujet-5000-collection-glsl-effectsthanks!
-
thanks a lot guido!
i will come back to you on your topic after that chrismasmadness is over.