Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by KingMan · May 10, 2013 at 07:37 PM · shadertextureblendingblend

3 texture blend shader

Hello. Here is my modified 2 texture blend shader. I trying to add third texture but it is not working.

Shader "3 Texture Blend" {

         Properties {
             _Blend ("Blend", Range (0, 2)) = 0
             _MainTex1 ("Base1 (RGB)", 2D) = "white"
             _MainTex2 ("Base2 (RGB)", 2D) = "black"
             _MainTex3 ("Base3 (RGB)", 2D) = "red"
         }
         SubShader {
             Pass {
                 SetTexture [_MainTex1]{}


   
                 SetTexture [_MainTex2] {
                     constantColor (0, 0, 0, [_Blend])
                     combine texture lerp (constant) previous }
                     
                 SetTexture [_MainTex3] {
                     constantColor (0, 0, 0, [_Blend])
                     combine texture lerp (constant) previous }
             }
         } 
     }

Help me please. I think maybe problem is in [_Blend].

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Owen-Reynolds · May 10, 2013 at 08:26 PM 0
Share

CG-user ins$$anonymous$$d of shaderLab (what you are using,) but: To test if it's working at all, substitute 0.4(?) for [_Blend]

Should probably have a blend2 variable, for controlling how #3 blends with (#1+#2). Otherwise you can't have a little bit of #2 and a lot of #3.

Then _Blend makes more sense from only 0-1 (the "in between" range of lerp.)

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by KingMan · May 12, 2013 at 05:04 PM

Finally i figured how it can be.Thanks all! But now i dont know how to add Light Affection to Shader)

         Properties {
                _Color ("Color Tint (A = Opacity)", Color) = (1,1,1,1)
             _Blend1 ("Blend", Range (0, 1)) = 0.0
             _Blend2 ("Blend", Range (0, 1)) = 0.0
             _MainTex1 ("Base (RGB)", 2D) = "red"
             _MainTex2 ("Base (RGB)", 2D) = "blue"
             _MainTex3 ("Base (RGB)", 2D) = "green"
         }
                
 SubShader {
             Pass {
                 Lighting On  
                 ZWrite On
                 
                 Material {
                     Diffuse [_Color]
                     Ambient [_Color]
                 }
                 
                 SetTexture [_MainTex1]{}
                     
                 SetTexture [_MainTex2] {
                     constantColor (0, 0, 0, [_Blend1])
                     combine texture lerp (constant) previous 
                     }
                     
 
                     
                     
                 SetTexture [_MainTex3] {
                     constantColor (0, 0, 0, [_Blend2])
                     combine texture lerp (constant) previous
                     }
                    
                          
             }
         } 
     }
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image PartyAssociate · Feb 05, 2014 at 12:11 AM 0
Share

You are a god among men. Thanks for this!

avatar image BrendonSMCD · Nov 17, 2015 at 01:08 PM 0
Share

@$$anonymous$$ingman

Fantastic little shader. Would there be a way of manipulating the mix on a vertice level ins$$anonymous$$d of the whole mesh? For example, having texture 2 blending in and out based on height? Or having texture 3 fading in and out based on normal direction?

This could be a great base for a terrain texturizer without the need for splatmaps.

avatar image
0

Answer by spiritworld · Dec 19, 2020 at 05:45 PM

I created a leaf shader that should blend between _Maintex (normal green) and _FallTex (yellow) and _WinterTex (bare branches) and came up with this

 float4 texA = tex2D(_MainTex, uv_MainTex);
 float4 texB = tex2D(_FallTex, uv_MainTex);
 float4 texC = tex2D(_WinterTex, uv_MainTex);
 float4 color = lerp(texA, lerp(texB, texC, step(0.6, _Blend)), step(0.3, _Blend));

Moving the _Blend value over 0.3 will show texB, and moving over 0.6 will show texC.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Shader for texture blending with a sharp outline. 1 Answer

Blitting to RenderTexture does not seem to be accurate 0 Answers

Blending between arbitrary numbers of textures on the same material 0 Answers

How can I combine a color texture with a b&w texture and get color? 2 Answers

Trying to blend 3 textures in shader 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges