- Home /
blending materials with sliders
Hi,
I have a project where we have a room with diffrent lighting options. I wanted to texture bake the diffrent lighting options as a map and with a slider have the user blend between those diffrent options. I'm a novice when it comes to scripting,so if anyone can give some guidence on this and point me in the right direction I would greatly appreciate it.
Thanks!
Answer by robertbu · Feb 14, 2013 at 09:03 PM
You will find a very simple shader with blending posted here:
http://answers.unity3d.com/questions/392616/fade-shader-one-texture-fades-in-the-other-fades-o.html
Typically these shaders use _Blend as a variable so doing a Google search on "Unity3d _Blend shader" will produce hits.
I've never used it, but you might take a look at: Material.Lerp().
Answer by jingi_w · Mar 26, 2013 at 11:52 PM
Hi,
Thanks for responding! I found the blend 2 textures shaders on the Wiki site
http://wiki.unity3d.com/index.php/Blend_2_Textures.
I've attempted to try to modify it to incorporate more that 2 textures. I was able to add a third but unfortunetly it will only blend the tex01 and 02 but not the third. I'm a new to writing shaders. Not sure what I did wrong here.
Here's what I modified.
Shader "Blend 3 Textures" {
Properties {
_Blend01 ("Blend01", Range (0, 1) ) = 0.5
_Blend02 ("Blend02", Range (0, 1) ) = 0.5
_MainTex ("Texture 1", 2D) = ""
_Texture2 ("Texture 2", 2D) = ""
_Texture3 ("Texture 2", 2D) = ""
}
SubShader {
Pass {
SetTexture[_MainTex]
SetTexture[_Texture2]
{
ConstantColor (0,0,0, [_Blend01])
Combine texture Lerp(constant) previous
}
SetTexture[_Texture2]
SetTexture[_Texture3]
{
ConstantColor (0,0,0, [_Blend02])
Combine texture Lerp(constant) previous
}
}
Any help would be greatly apperciated.
Thanks!
If you have a new question, please post it as a new question, not as an answer to an existing question.