#Hi there

1 messages · Page 1 of 1 (latest)

wooden hull
#

Current look:

#

Note = the water seems laggy during collisions. This is not a performance issue, just a test that I performed by skipping a frame for the calculations. Don't mind it.

fierce bough
# wooden hull Note = the water seems laggy during collisions. This is not a performance issue,...

This can certainly be done in a shader on the GPU. Though, you wouldn't do it in the same shader that draws the water to the screen. It would be a separate pass for just the simulation and could be done with a compute shader.

However, I wouldn't recommend optimizing before you have any performance problems. Try making a synthetic scene with more and wider water spots and profile what the performance is actually like with your current implementation. If it's not good, find out what's slow about it. Maybe there are trivial optimizations you can make without going all the way to a compute shader.

#

If you're still unable to get good performance with your script implementation, you could try implementing it in a C# job with Burst compilation. You can get significant performance gains that way while still having everything in C#.

wooden hull
fierce bough
# wooden hull That would be ideal to be honest ^^ I will listen and keep optimizations for lat...

A compute shader is a different type of shader that can be executed on the GPU. It's more general purpose, not for processing vertices or drawing pixels on screen, but just do some kind of work in parallel across many compute threads. High end GPUs come with thousands of compute cores these days, compared to the 8-16 cores you usually see in CPUs. Each compute core is much slower and less capable than a CPU core, but there's many more of them, so they will usually finish a task faster if it's a problem that can be parallelized well.

C# Jobs is a Unity feature that has nothing to do with compute graphics, but is a way to write multithreaded code that is easier and safer. You define what the job does in C# code and schedule it, then Unity takes over and manages actually running it optimally across the CPU cores that are available. The job will run in the background, hopefully finishing by the end of the frame, but you can force the main thread to wait for it to complete in case it doesn't.

Burst is an additional package that can be used to optimize your C# jobs by converting them to highly optimized native assembly code. 10x-30x performance improvement is not rare to see with it enabled.