Blending a spread of texture using foreach loop

Hi,

before with Beta/DX11 I was doing this :

float4 pBlender(float4 PosWVP: SV_POSITION, float2 uv: TEXCOORD0): SV_Target
{
	float4 color = float4(0.0, 0.0, 0.0, 1.0);

	for(int i = texcount-1; i>=0; i--)
	{
		float4 col = texArray.Sample(s0, float3(uv, LayerID[i]));
		col.a *= Alpha[i];
		
		if (BlendMode[i]==0){color=bld(col,col,color);}//NORMAL
		if (BlendMode[i]==1){color=bld(color+col,color,col);}//ADD
		if (BlendMode[i]==2){color=bld(color-col,color,col);}//SUBSTRACT
		if (BlendMode[i]==3){color=bld(max(color,col),color,col);}//LIGHTEN
		if (BlendMode[i]==4){color=bld(min(color,col),color,col);}//DARKEN
		if (BlendMode[i]==5){color=bld(color*col,color,col);}//MULTIPLY

	}
	return float4(color.rgb * transition, color.a);
}

The BlendModes don’t matter for now and it also doesn’t have to be a TextureArray, maybe an other way is possible in Gamma.

Testing with just 4 textures, this is what I thought it should look like :

Problem is, I have no idea how to set a default texture (or color?) the way I did it in HLSL before the loop and I don’t get the result I expect which would be one final texture…

Any hint ?

Thx.

This seems to work:

BlendSpread.7z (968.0 KB)

Great !
I just had to change invert the inputs otherwise this is exactly what I was looking for.
Thx.

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