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 PolyPanda · Nov 01, 2011 at 09:19 AM · materialslerp

Lerping textures

I got this code but it does not seem to work for textures.Can anybody tell me what I'm doing wrong?

 public Material Mat1, Mat2;
 public float Sec;

 // Use this for initialization
 void Start () {
 
 }
 
 // Update is called once per frame
 void Update () {

     float lerp = Time.time / Sec;
     renderer.material.Lerp(Mat1, Mat2, lerp);

 }

It does work when I assign two materials with just color but it doesn't work when the materials have textures. Is there another method for textures?

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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by StephanK · Nov 01, 2011 at 09:32 AM

There is no build in way of lerping textures in unity. I guess what you want to do is blend one texture into another. You could do this with a shader instead, that uses two textures and exposes a "blend" property.

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 ellens · Sep 06, 2012 at 07:44 AM

I have made a script and a custom shader just for this:

http://www.sundh.com/blog/2012/09/real-time-blend-2-textures-in-unity/

Hope it helps!

Comment
Add comment · Show 1 · 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 Fattie · Sep 06, 2012 at 07:46 AM 1
Share

totally awesome - your blog is amazing BTW !!

avatar image
0

Answer by syclamoth · Nov 01, 2011 at 09:33 AM

Materials don't work that way, I'm afraid. Look through the documentation for Material- do you see any 'Lerp' function in there?

This is because materials are more complicated than just a few numbers, the way Vectors and Colors are. Each material contains a lot of information which cannot easily be 'interpolated' between point A and point B.

However, if all you are trying to do is change the textures, you can use a shader which interpolates between two given texture inputs by some value (which can be assigned in a script). There's one solution here. I recommend becoming familiar with the shader language Unity uses- it will be extremely useful to you even if (like me) all you ever do are rough hacks of what you need- as long as you know the basics, you can go a surprisingly long way.

Comment
Add comment · Show 1 · 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 Fattie · Sep 06, 2012 at 07:48 AM 2
Share

@kieren, what's this ?

http://docs.unity3d.com/Documentation/ScriptReference/$$anonymous$$aterial.Lerp.html

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

6 People are following this question.

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

Related Questions

Lerping multiple materials of a gameobject within a coroutine 0 Answers

How to Lerp between two materials 1 Answer

Lerp isn't completing itself 3 Answers

Lerp doesn't work after using a lerp? 1 Answer

How do I add multiple points using Lerp? 3 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