Skip to main content
6 events
when toggle format what by license comment
Aug 4, 2018 at 14:27 comment added DMGregory You could run the floaters themselves on the GPU, referencing the same shader function that evaluates wave height in a common include. Each frame you'd provide a buffer of updated floater positions/sizes, then later read back the resulting forces to apply for each. It's more complicated and there's risk of stalls or added latency if not coordinated right, though since water is sloshy you probably wouldn't notice a frame or two of latency badly. You could also generate the shader and CPU-side wave function from a common source, transpiled to each language at build time so they stay in sync.
Aug 4, 2018 at 14:20 comment added Ben Hayward Oh I see what you're saying. The only disadvantage I can see in that, is that developers working on the project would need to guarantee that any alteration made to the logic in the shader is replicated exactly in the floater script (and vice versa). If one was able to sample directly from the mesh/shader there would be no need for duplication. Is there any way to do the latter? I get the impression the latter would be more costly but might make for more maintainable code?
Aug 4, 2018 at 14:08 comment added DMGregory "each floater samples the water height at its position (eg. by evaluating the same wave function you use in the shader)" That means you use the same math code in your floater script that you use in your shader. Because you're running the same math on the same input coordinates, you'll get the same answer the vertex shader came up with.
Aug 4, 2018 at 14:05 comment added Ben Hayward Hi @DMGregory Thanks for the answer. I have seen similar implementations, but I thought that the only way to do this was to raycast from various points on the "floating" model, which means the water mesh would need a collider(??). Secondly, how would you go about sampling the height of the vertices from a given point? Many thanks
Aug 4, 2018 at 13:28 history edited DMGregory CC BY-SA 4.0
Fixing subject singular/plural
Aug 4, 2018 at 13:19 history answered DMGregory CC BY-SA 4.0