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 /
This question was closed May 25, 2018 at 12:54 AM by bpears for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by bpears · May 07, 2016 at 12:28 AM · shadertime

How is SinTime measured in shaders?

Trying to use SinTime, doesnt seem to work how I expected. What kind of value is SinTime giving? is it a -1 to 1 value? or a continuous growing int?

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

  • Sort: 
avatar image
1
Best Answer

Answer by Bunny83 · May 07, 2016 at 04:40 AM

Well, just looking at the name i would guess it's between -1 and 1. By taking a quick look into the documentation we can see that sintime is actually a float4 and each component has a different value.

So:

 _SinTime.x == Sin(t/8)
 _SinTime.y == Sin(t/4)
 _SinTime.z == Sin(t/2)
 _SinTime.w == Sin(t)


Comment
Add comment · Show 5 · 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 bpears · May 07, 2016 at 04:51 AM 0
Share

Seen docs, but when I try to clamp to half of sintime, to sintime, it seems to not smoothly transition from the half.

avatar image bpears · May 07, 2016 at 04:52 AM 0
Share

I'm trying to make it it less strong of a sin wave basically. But it is not turning out smooth.

avatar image Bunny83 · May 07, 2016 at 06:00 AM 0
Share

What does "clamp to half of sintime" mean? Clamping always sounds like it will not end up smooth ^^. And what do you mean by "less strong"? If you just want to lower the amplitude, just multiply it by a value smaller than 1.0.

 _SinTime.x*0.2 --> [-0.2, 0.2]

If you want a slower frequency you have to provide that manually. Unity only provides those 4 predefined values.

You can calculate the sine directly in the shader, but it's actually a waste of GPU power since you would recalculate it for every vertex / fragment. It's better to provide your custom value with a global shader parameter and set / update the value in Update in a script

avatar image bpears Bunny83 · May 07, 2016 at 01:05 PM 0
Share

Ah, that makes more sense. Thanks for your help.

avatar image bpears Bunny83 · May 07, 2016 at 03:28 PM 0
Share

Well, I guess I phrased that wrong, I am trying to up the base line value of sine, but I guess I could juts + 0.1 or whatever. But what I'm trying to do is more like force SinTime, to be the same as Time, or a bit slower. And I assume Time is like SinTime to amplitude of 1 constantly. But it doesnt seem to do Sin anymore when clamped, just outputs the $$anonymous$$ of clamp.

like

 clamp(_SinTime.w,_Time.x, _Time.y)


Justed edited the xyzw, so they match up as

 clamp(_SinTime.w(time),_Time.x(time/20), _Time.y(time))

Follow this Question

Answers Answers and Comments

58 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

Related Questions

How can i create a time bubble effect ? 0 Answers

How to force the compilation of a shader in Unity? 5 Answers

Shader time related questions 1 Answer

Built-in ShaderLab "_Time.y" and "Time.time" are not equal? 5 Answers

Change input values based on Time 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