Coder Social home page Coder Social logo

Cheap cpu approximation about crest HOT 2 CLOSED

wave-harmonic avatar wave-harmonic commented on May 20, 2024
Cheap cpu approximation

from crest.

Comments (2)

huwb avatar huwb commented on May 20, 2024

Thanks SirPolly! I'll write some thoughts below.

Crest also uses gerstner waves, and there are functions to sample displacement/height - see the ShapeGerstnerBatched component. This is stateless, although the time is currently driven by an internal variable in the OceanRenderer (_elapsedTime) right now. It would be possible to use any time here though.

The unfortunate caveat with the above is that these functions dont take into account the depth of the ocean floor (which dampens the waves which have long wavelengths). This is because the sea depth is rendered on the fly on the GPU, or cached in textures on the GPU. An option here would be to read the sea depth on the CPU and use this when computing the wave shape on the CPU. Another option would be to use some kind of manual dampening of the waves using primitives such as spheres, which could be used on both the CPU and GPU.

The best path to get the collision on the CPU is to read back the GPU shape textures. This has a couple of frames of latency. I'm guessing though that this would not work for a networked game because you probably need the future state of the ocean, and therefore latency is not acceptable.

A final option is to bake out the ocean shape into textures as an offline step instead of computing them on the fly - for example bake out 32 frames of animation from a simulation software such as blender, and then read these textures on both the CPU and GPU. This would be cheap but requires the offline setup steps.

Let me know if this makes sense and if it addresses your questions!

from crest.

huwb avatar huwb commented on May 20, 2024

I'll resolve this (I'm a "zero inbox" kind of guy :)) but feel free to keep this conversation going, i'll get notifications if you reply.

I'm interested to know if there are any generic changes i can absorb into crest to make it work better for networking, so it would be good for me to understand this better.

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.