Giter Site home page Giter Site logo

Comments (9)

huwb avatar huwb commented on May 18, 2024

Ok, thanks for the note. I think the first thing I'll do is an option to make the readback synchronous. This will add stalls but would be useful for comparisons/debugging. I'll post back when I've done this.

Besides that i'm thinking about two directions to solve this currently.

A first one is to compensate for the time delay and move the collision accordingly. See commit 8146864 . It records a timestamp with each readback request, and when it does get collision data it computes the velocity that the surface (height) is changing and then extrapolates forward to the current time. In my tests it was a able to track the surface pretty well, with the exception of some slight noise which i dont think would be a blocker, or could be polished out. It would need some kind of system to cache velocities etc, i can think about this.

The other thought i had was to actually start rendering out shape two frames ahead on the gpu, so that it can come back to the cpu in time (i guess this needs a fixed framerate to work 100%) things that are deterministic in time should work well, but for dynamic simulation stuff i guess this will just shift the lag into the sim. these disadvantages and the mess i'm guessing it will make of the code make me think the first option is worth exploring first.

i'll let you know when i have more..

from crest.

huwb avatar huwb commented on May 18, 2024

I hacked in the option to do synchronous readbacks (to avoid the async latency) for debugging/comparison. I decided to put it in a branch for now, but could probably be convinced to put it in master with #ifdef's and such. It's a static which I've added to the debug GUI - Use Async Readback.

Turning it on is expected to hit perf (it will make the CPU block-wait for the GPU to render everything and transfer over the shape), but its just for functionality comparison purposes.

If you get a chance, could you confirm this fixes the issue you report above?

8fa07a5

from crest.

dizzy2003 avatar dizzy2003 commented on May 18, 2024

from crest.

huwb avatar huwb commented on May 18, 2024

Sigh.. sorry.. i hacked that in a quickly and after experimenting now I've realised _useAsyncReadback must be left true on startup so that everything gets init'd properly, and then turned on/off while running.

My steps:

  • Assign OceanCollisionDemo script to camera
  • Assign OceanHeightDemo script to a cube
  • Press play (with _useAsyncReadback = true)
  • Turn _useAsyncReadback on/off using debug gui at runtime to compare

With this, I get something that tracks the surface very closely, even for an aggressive wave:

https://drive.google.com/open?id=1ZH8oc3zR4lioWYXtWZ6D1BoQrUOarKcM

I did my best to clamp it to 30fps. I pushed the hacks i did to make the video: fcf73a1

The white cubes sample the displacement, the red cube inverts the displacement to get the height.

They seem to track the surface closely for me. There is some visible error, but this is a quite extreme wave. Are you seeing the same level of error and is this proving to be an issue?

from crest.

huwb avatar huwb commented on May 18, 2024

One more capture, this time failing a bit less at running at 30fps:

https://drive.google.com/open?id=1Yml_gAO9fsFlzqikgdXC0UQhsghVNITn
f9bdede

from crest.

dizzy2003 avatar dizzy2003 commented on May 18, 2024

from crest.

huwb avatar huwb commented on May 18, 2024

Oh that made me realise - we should compare readback request queue lengths. This is the number of frames of latency. I've just added this to the debug GUI on master and merged this into this test branch. The GUI shows the min and max queue over all shape lods.

On my laptop I'm getting a solid [2,2] in both editor and standalone.

As you may have already seen, I have dictated the execution order for all update dependencies - it would be worth checking to make sure these are coming through in your project as well.

from crest.

dizzy2003 avatar dizzy2003 commented on May 18, 2024

from crest.

huwb avatar huwb commented on May 18, 2024

That sounds promising! I'll leave this open for the next day or two let me know if it regresses.

from crest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.