'How to Run GLSL Program Based on System Time
I am trying to run different iterations of a shader program based on system time. I am hoping to set up an if else code to run one iteration of the program during the day and another at night. At the moment, I can't find how to bring system time into the glsl file. Any thoughts? Thanks!
Solution 1:[1]
Two options:
- Pass the time in a uniform from your application (e.g. number of seconds since midnight)
- If it's really just an if/else for day/night you can run a different shader program depending on the time. One way to do this would be to add conditional preprocessor directives (
#if defined(DAY)) instead of if/else, and modify the shader code dynamically before loading the program (add/remove#define daywith basic string manipulation).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | kshahar |
