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
1
Question by snmt_singh · Jul 30, 2014 at 12:30 PM · shaderdeltatimeglsl

provide delta time to shader (GLSL)

I am using a custom shader (GLSL) in my game which requires time (Delta time) , for fragment shader, now i don't know from where to provide delta time to "uniform vec2 time". Thank you.

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
3
Best Answer

Answer by CHPedersen · Jul 30, 2014 at 12:55 PM

Generally, values are passed to shaders using one of the static variants of Shader.SetGlobalXXX if the variable should be globally available to all shaders, or the non-static Material.SetXXX if the variable is to be available to only that particular shader. In your case, it would be Shader.SetGlobalFloat, or Material.SetFloat, since Time.deltaTime is a floating point value.

But in your specific example, you don't need to pass the value manually, because Time.deltaTime just so happens to be one of the built in shader values which are passed by the engine for you. Please see the tables at this link for a comprehensive list of these built in variables:

http://docs.unity3d.com/Manual/SL-BuiltinValues.html

The one you need is called "unity_DeltaTime", and is a float4. The x-component contains the deltaTime itself, while the y, z and w components of the vector contain different variants useful in other scenarios.

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 Ferb · Mar 22, 2015 at 02:15 PM 0
Share

The link provided is dead, now the list of built-in shader variables is at http://docs.unity3d.com/430/Documentation/Components/SL-BuiltinValues.html

avatar image jethrogillgren · May 16, 2018 at 06:12 PM 0
Share

The link provided is dead, now the list of built-in shader variables is at https://docs.unity3d.com/$$anonymous$$anual/SL-UnityShaderVariables.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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Cg Language incompatibility Desktop VS GLSL Android 0 Answers

Hatching Shader? 0 Answers

Grabpass refraction masking 0 Answers

How to prevent shader optimizations? 1 Answer

Where can you store data in a shader, so that it's not computed for every fragment? 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