In Unity, the number of game objects is a limiting factor. In order to show thousands of individually controllable objects, this limitation must be circumvented. In certain applications, this is possible. Using a mesh, updated each frame, we can control thousands of quads. Each quad displays a fish image, with a transparent background. Each quad also has a look point and a target point. Fish AI scripts control each quad's transform, look and target. Multiple meshes are used to simultaneously display bait balls of fish, seaweed, krill, and detritus, using only a fraction of the CPU at 120 fps.
Goal: Render 1000's of fish at a distance with AI at 120 frames per second in Unity to support featured content.
Issue: Thousands of individual fish game objects would already be too slow!
Single mesh: A single game object with a mesh can handle thousands of quads.
Multiple fish types: More than one fish type can be shown by using composite images and UV offsets.
Animation: Images can be animated, but all the fish will have the same frame in the animation. Each mesh can display its own animation.
Randomizing: Speed, scale, mirroring and behavior make mesh quads look more unique.
Stereoscopic 3D: Two meshes can be linked for stereoscopic 3D. This is perfect for showing 2D content in stereoscopic 3D.
Update: Each frame, the mesh is regenerated, with AI controlling quads, each displaying a fish image with a transparent background.
Resolution: resolution as low as 256 x 256 for fish, 1024 x 1024 for nettles.
Distance from viewer: In 3D, mono mesh objects should be at least arm's length from the viewer, at a high enough resolution.
Proof Of Concept: We are able to show up to 1500 2D fish at 120 fps to support one CPU-heavy interactive physics-enabled 3D content.
How a nettle falls apart when bitten by a leatherback turtle. Just explode.
Using bounding boxes to quickly locate map tile meshes.
A mesh of thousands of quads show fish images.
Several meshes show fish and seaweed.
View of fish wandering inside a bait ball.
Seeing what large meshes look like using the POINT render flag.
Visualizing point cloud data in Unity. Each point is a game object.
Working with control of quads and texture mapping.
Using mesh quads for fish and seaweed.
Different LODs for the same real-time mesh sampling tested for performance.
Finding edges.
Finding a height on a height map from a viewer using ray casting.
Double fish image used for a bait ball with two types of fish.
Ray casting to find intersection points.
Draping a grid on top of a mesh.
Finding the closest neighbor in a point cloud, as starting points.
Meshes can be generated from a height map.
Overview:
Realistic and fast nettle tops and tentacles are achieved with procedural meshes.
Several procedural nettles using LookAt and no physics. This solution uses less CPU than Unity physics, but does only what we need.
Nettle tentacle segments created with procedural meshes.
Self-generating game objects with AI. Very interesting.
Procedural nettle top.
Radial sine waves.
Working with sine waves.