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 ina · Jan 02, 2013 at 01:22 AM · texturematerialshaderslerp

Material.Lerp for transparent spec material with two different textures

Is it possible to get Material.Lerp to work for the same material but with two different textures in the before and after states

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by whydoidoit · Jan 02, 2013 at 07:20 PM

Here's a shader that will do that...

 Shader "Whydoidoit/Lerp" {
 
     Properties {
     
         _MainTex ("First Texture", 2D) = "white" {}
         _BlendTex ("Second Texture", 2D) = "white" {}
         _Blend ("Blend", Range(0,1)) = 0.0
     
     }
     
     SubShader {
         Tags {"RenderType"="Opaque"}
         LOD 200
         CGPROGRAM
         #pragma surface surf Lambert
         
         sampler2D _MainTex;
         sampler2D _BlendTex;
         float _Blend;
         
         struct Input {
             float2 uv_MainTex;
             float2 uv_BlendTex;
         };
         
         
         void surf(Input IN, inout SurfaceOutput o) {
             
             half4 c1 = tex2D(_MainTex, IN.uv_MainTex);
             half4 c2 = tex2D(_BlendTex, IN.uv_BlendTex);
             o.Albedo = (c1.rgb * (1-_Blend)) + (c2.rgb * _Blend); 
             o.Alpha = 1;
         
         }
         
         ENDCG
         
     }
     Fallback "Diffuse"
 
 }
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
avatar image
1

Answer by Julien-Lynge · Jan 02, 2013 at 07:04 PM

@ina,

I don't believe so, but I haven't specifically tried it. Most likely you'd want to write a custom shader that uses two textures and a float value to sample both of them. This is very hard to do if you've never written a shader, but if you want to try it, check out this page: http://docs.unity3d.com/Documentation/Components/SL-SetTexture.html

There's an example there (Alpha Blending Two Textures) that might just do what you want.

Comment
Add comment · Show 3 · 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 whydoidoit · Jan 02, 2013 at 07:21 PM 0
Share

That alpha shader in the docs is blending based on the alpha of texture1

avatar image Julien-Lynge · Jan 02, 2013 at 07:22 PM 0
Share

You're right - I didn't look closely enough :)

Would be easy enough to change to an inspector float value, if you understand the basics of ShaderLab - but that could require quite a bit of reading.

avatar image whydoidoit · Jan 02, 2013 at 07:25 PM 0
Share

Yeah - I can't do those fixed function things though :) Hence surface shader below...

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

10 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

Related Questions

CRT/LCD screen shader (for materials) 4 Answers

Animating from texture to texture 1 Answer

Is it possible to make an image sequence into an animated normal map? 0 Answers

How can I pan a texture to specific location on a sheet? 1 Answer

There is an issue with texture wrapping around sphere's in unity 0 Answers


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