wave-harmonic / crest

A class-leading water system implemented in Unity
MIT License
3.4k stars 475 forks source link

Sphere Water Interaction GPU Instancing #1096

Closed daleeidd closed 1 year ago

daleeidd commented 1 year ago

Greatly improves performance when many SWI instances are in the scene. Without instancing, there would be one draw call per LOD per instance. Now there is only one draw call per LOD.

This has been implemented for SWI only as it is necessary for its scalability due to the nature of its usage often been as a composite and requiring several instances to achieve a desired shape.

For example, the "Spinner" example had 126 draw calls and now has only seven draw calls.

GPU instancing can only draw 1023 instances per draw, which should be more than enough, so for now the SWI also carries this limitation.

Another downside of instancing is that inputs cannot be sorted, but I do not believe there is a use case for that anyway.

Eventually moving towards compute shaders will replace this.