Sliced images mapping a displacement mesh

I am building an effect which conceptually I got a multiple images layered where first is front the second… distributed en Z axis. and by using displacement map with a mesh it shows the portion of the corresponding image. So by the amount of grey color, white shows first and black last image.
I got this code: Displacement map is the grey color image input, blend is the amount of displacement, and ImageSource is single image. This sample works for one vertical pixel from ‘Image source’ but I would like to be able to get a list of images or one big image with many frames.And so these frames or images are mapping the mesh depending on the mesh curve so the DisplacementMap.

Vertex Shader::
uniform sampler2D DisplacementMap;
uniform float blend;
uniform vec3 LightPosition;

varying float colpos;

void main(void)
vec4 dv;
float df;

vec4 vari = gl_Vertex;

gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;
dv = texture2D(DisplacementMap, gl_MultiTexCoord0.xy);
df =  blend*dv.z;

colpos = df * length(vari)*3.;

vari.z += df/1.;
gl_Position = gl_ModelViewProjectionMatrix * vari;


Fragment Shader::
uniform sampler2D ImageSource;
uniform float LightRange;
uniform float TRYx1, TRYy1, TRYx2, TRYy2, TRYx3, TRYy3,A;
varying float colpos;

void main(void)
// Fake lighting shading with Lookup Table
float lookupX = clamp((1.0-LightRange) * colpos,TRYx2,TRYx1)+A;
float lookupY = clamp((1.0-LightRange) * colpos,TRYy2,TRYy1)+A;

// gl_FragColor = texture2D(Diffuse, vec2(lookupX, lookupY));
gl_FragColor = texture2D(ImageSource, vec2(lookupX, lookupY));

If you could help me to write, I will appreciate.
Thank you very much for your help!

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.