Routine to blend multiple textures in hlsl according to alpha mask values

hi All !
I would like to create a float array in my hlsl fx file.
vvvv gives me:

"Literal loop terminated early due to out of bounds array access X3504"

in two words, I have 9 textures and a “master blend_coeff” which goes from 0 to 1000.
going from 0 to 1000 reveals texture 1, then 2, then 3…

here’s part of code which contains error:

float4 PS(vs2ps In): COLOR
	float k[9](9);
	for (int m=0;m<10;m++){
	if (coeff_col>=m*111 && coeff_col<=m*(1000/9)+(1000/9)) {
k[m](m)=mapping_values(coeff_col,0,m*(1000/9)+(1000/9),0.,1.);///problem here
        float4 col1 = tex2D(Samp1, In.TexCd);
	float4 col2 = tex2D(Samp2, In.TexCd);
	float4 col3 = tex2D(Samp3, In.TexCd);
	float4 col4 = tex2D(Samp4, In.TexCd);
	float4 col5 = tex2D(Samp5, In.TexCd);
	float4 col6 = tex2D(Samp6, In.TexCd);
	float4 col7 = tex2D(Samp7, In.TexCd);
	float4 col8 = tex2D(Samp8, In.TexCd);
	float4 col9 = tex2D(Samp9, In.TexCd);

	float4 col=col1*k[0](0)+col2*k[1](1)+col3*k[2](2)+col4*k[3](3)+col5*k[4](4)+col6*k[5](5)+col7*k[6](6)+col8*k[7](7)+col9*k[8](8);
	return col;

thanks in advance !
(just so exciting to discover the FX world of vvvv :-)

the for loop has 10 steps 0…9 your array has only 9 entries 0…8.

sampling all 9 textures when you only show 2 or 3 at a time is not very efficient btw…

arr…of course !
thanks tonfilm.
the final patch will let the viewer see every image layers at the same time at different positions of the screen… that’s why, I have to sample all textures ;-)
thanks !

ok so next step is little bit buggy to me…

I have sphere mask which goes from 0 to 1 alpha value.
I would like this mask to reveal every 9 textures in a fade.

for instance: for points in image where alpha mask=1/9, alpha of point’s first
texture alpha =1…
for points in image where alpha mask=2/9, alpha of point’s first texture=0,
alpha of those points texure2 alpha =1…

my issue is only the last texture is displayed as if alpha of mask was 1 everywhere and every time…

here’s the patch and fx file to demonstrate my issue…
thanks in advance

debug_blend_9.v4p (27.8 kB)
blend_9_textures.fx (5.5 kB)

little up ?
thanks in advance

haven’t checked the whole code, but it seems that the mapping_values function is not clamped to 0…1 it will just surpass the destination min…max in both directions if the input is outside input min…max. so put the output of mapping_values into the saturate function to clamp it between 0…1.