How to change opacity of each texture in MixMaterial?

This works really well so far and I love it, so I’m using all of the textures here but some of them I want to change the opacity so it is not as solid, is it possible to do so?

so diffuseTexture1 will have 100% opacity while diffuseTexture2 might have 50% opacity.

All using the same mixmaterial

It is already what it is doing through the mixTexture1/mixTexture2 properties.

In these textures, you use the r/g/b/a channels to mix the different textures. For eg, using 255 will make the corresponding layer fully opaque, using 128 will blend this layer with the next one in 50%/50% proportion.

I tried this and not sure if im getting something wrong. If you have 2 mixmaps and make the 2nd mix map have 50% opacity on photoshop, does that mean that the textures drawn on the mix material will be 50% opacity too?
im not getting that result. Im using the same mixmap for both mixmaps on mixmaterial.

When you say 255, do you mean the rgba values but specifically the A?

I would however like to try and get that opacity at a layer/texture level as well on the mixmaterial, so i will try a few things.

From my understanding of the code, mixmap.g is the blend factor between texture1/texture2, mixmap.b the blend factor between texture2/texture3 and 1-mixmap.a the blend factor between texture3/texture4. mixmap.r is a static multiplication factor for texture1:

	vec4 mixColor = texture2D(mixMap1Sampler, vTextureUV);

	mixColor.rgb *= vTextureInfos.y;
	
	vec4 diffuse1Color = texture2D(diffuse1Sampler, vTextureUV * diffuse1Infos);
	vec4 diffuse2Color = texture2D(diffuse2Sampler, vTextureUV * diffuse2Infos);
	vec4 diffuse3Color = texture2D(diffuse3Sampler, vTextureUV * diffuse3Infos);
	vec4 diffuse4Color = texture2D(diffuse4Sampler, vTextureUV * diffuse4Infos);
	
	diffuse1Color.rgb *= mixColor.r;
   	diffuse2Color.rgb = mix(diffuse1Color.rgb, diffuse2Color.rgb, mixColor.g);
   	diffuse3Color.rgb = mix(diffuse2Color.rgb, diffuse3Color.rgb, mixColor.b);
	finalMixColor.rgb = mix(diffuse3Color.rgb, diffuse4Color.rgb, 1.0 - mixColor.a);
2 Likes