Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by zN30Nz · Mar 22, 2019 at 04:24 PM · shadershaderstimescaling

How do I change the scale over a time for a shader?

So, i have been working on a project since a week, and i got a big problem!

I have a simple line renderer and a repeating/tiling texture added. Heres a picture for visualisation:

The next thing i did was writing a little code to change the offset with the time. So the lines are going in one direction:

The problem is that it looks kind of weird, because the little repeating line textures are just disappearing at the end of the line (renderer). So i would like to change the shader so that it would change the size of the little textured repeating lines with time. That means the lines would get tinier and shrink/fade away. Not just continuosly stay big and just disappear.The problem is, i dont know how to achieve that goal. I looked through many questions but i didnt find any helpfull answeres. Do i have to write a shader myself? And if yes, could you help me out? I never did that before. Also, i would prefer a c# solution :)

Thank you, NeoN!

dddd.png (114.2 kB)
ddd3.png (13.2 kB)
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by dan_wipf · Mar 23, 2019 at 07:11 AM

well have you tried to change the animation curve? this will give you an idea.

 var lr = GetComponent<LineRenderer>();
 AnimationCurve curve = new AnimationCurve();
 
 curve.AddKey(0.0f, 0.0f);
 curve.AddKey(1.0f, 1.0f);
 // or reversed
 curve.AddKey(1.0f, 1.0f);
 curve.AddKey(0.0f, 0.0f);
 
 lr.widthCurve = curve;
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 zN30Nz · Mar 23, 2019 at 10:57 AM 0
Share

Yep, the linerenderer has an inbuild scaling tool over lifetime aswell, the problem is that it just cuts of the circle ins$$anonymous$$d of scaling each individual circle down. Heres a picture:

alt text

And thats how i would like it to look (Drawn with my astonishing paint skills):

alt text

Thanks for your quick answer!

1.png (148.7 kB)
3.png (4.1 kB)
avatar image dan_wipf zN30Nz · Mar 23, 2019 at 07:27 PM 0
Share

ok played around with linerenderer, and i guess it’s not achievable with a simple setup.


so what i would do is setting a start point and an end point as a vector3 position, them you make a vector3 Lerp loop:

  Vector3 startPos = new Vector3(0,0,0);
  Vector3 EndPos = new Vector3(0,10,0);
  int Steps = 5;
  GameObject sprite;
  List<GameObject>() allObjects;
  
 //before any change you want to destroy the spawned objects first with a for loop => for(int i = 0; i<allObjects.Count){ Destroy(AllObjects[i]);}
 
  for(int i = 0; i<Steps; i++){
    var pos = Vector3.Lerp(startPos,ensPos,i+1/Steps);
    var obj = Instantiate(sprite,pos,Quaternion.Identity);
    obj.transform.size *= i/Steps;
    allObjects.Add(obj);
 }
avatar image dan_wipf dan_wipf · Mar 23, 2019 at 08:12 PM 0
Share

that’s just pseudo codr fyi => but you might get an idea what i forgot to write in code is, that you want to set the parent of the instantiatex objects to maybe the object where the script is called from

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

236 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 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 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 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 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 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 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 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 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 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 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 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 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 avatar image avatar image

Related Questions

Do i have too many shader variants? i feel like i do, i mean, is that 704 million? how did this happen? 0 Answers

FPS shader fixing 1 Answer

Need help to make a color replace shader 0 Answers

How to access shader graph property values through C# script? 0 Answers

Is it possible to blend 2 different materials via the shader graph? 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