- Home /
Trying to blend 3 textures in shader
Hi,
I'm having troubles blending 3 different textures together in a shader with a "multiply" blending mode, i want 3 sliders to adjust blending for each texture but i didn't found a way to do that.
Thanks for any help
Answer by Bunny83 · Nov 11, 2017 at 01:54 AM
This sounds a bit strange. What should those 3 sliders control? Since you want multiply as blendmode, bright values keep the original values, dark values make the result dark. If you want a 0-1 value to specify how much "effect" each texture has, you actually need to "overbright" each texture with your slider value.
fixed3 res = clamp(tex0 + tex0Slider,0,1) * clamp(tex1 + tex1Slider,0,1) * clamp(tex2 + tex2Slider,0,1);
Note that if tex0Slider is "0" you actually get the full effect of this texture. If the value is "1" the result is basically (1,1,1) == white so a multiply doesn't has any effect. Of course if all slider values are "1" the result would be plain white. If all slider values are 0 the result is the same as tex0*tex1*tex2
Note ins$$anonymous$$d of tex0 + tex0Slider
you could also use lerp towards white. This will ramp the components based on their value. So the color (0, 0.8,0.4) when lerped towards (1,1,1) with a factor of 0.5 the result would be (0.5, 0.9, 0.7) while using the simply add the result would be (0.5, 1, 0.9).
Ins$$anonymous$$d of clamp(x, 0, 1) you probably want to use "saturate" ins$$anonymous$$d. It's basically the same thing So the alternative would look like this
fixed3 res = saturate(lerp(tex0,1,tex0Slider)) * saturate(lerp(tex1,1,tex1Slider)) * saturate(lerp(tex2,1,tex2Slider));
Your answer
Follow this Question
Related Questions
Shader: Modify XY Position of Texture 0 Answers
Shader: Mask Without a Texture? 2 Answers
Shader Tiling Texture Overlapping between X and Z Axes 0 Answers
Blending normal texture and texture made with shader 0 Answers
cartoon lit shader with transparency? 0 Answers