Jump to content

Shader Time Variable by Delta Time or Float - better habbits?


Pryme8
 Share

Recommended Posts

So would there be any benefits or cons to doing something like this:

var time = 0;
engine.runRenderLoop(function(){
        scene.render();     
         var d = engine._deltaTime;
         time+=d*0.0001;
          shader.setFloat('time', time);        
});

as opposed to:

var time = 0;
engine.runRenderLoop(function(){
        scene.render();     
        time+=0.01;
        shader.setFloat('time', time);        
});

Is there a way to guarantee clients will get the same time 'coordinates' on a shader even with different io speeds?

Link to comment
Share on other sites

Ok cool, the other one I was thinking about was doing like:
var start = Date.now();
var time = 0;

loop{
  var now = Date.now();
  time = now - start;
 setTime...
}

but if the getAnimationRatio works then Ill go with that!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...