Sci-Fi tunnel + Space Invader 3D shooter with fast GPU instancing

Hi, here is the first working version of the prototype using GPU instancing. Wireframe and glow are not working on the tunnel yet.

https://playground.babylonjs.com/#YSKAH2#4

SPACE = Toggle settings

You can create your own enemy by editing the enemyMatrix. I created two materials for the enemy, R means use red solid block, O means white wireframe and finally _ means empty space.

const enemyMatrix = [
        [R, _, O, _, _, _, _, _, O, _, R],
        [_, _, _, O, _, _, _, O, _, _, _],
        [_, _, O, O, O, O, O, O, O, _, _],
        [_, O, O, R, O, O, O, R, O, O, _],
        [O, O, O, O, O, O, O, O, O, O, O],
        [O, _, O, O, O, O, O, O, O, _, O],
        [O, _, O, _, _, _, _, _, O, _, O],
        [_, _, _, O, R, _, R, O, _, _, _]
    ]

You can console.log your current settings by pressing +. Each keypress creates a keyframe. Create as many as you wish, copy out the final json object, replace the pathData variable value at the start of the script. Chane processPath(true) to processPath(false) to disable randomizing the path in play mode and use the pathData variable instead.

You might want to change the animationLength at line 26 to whatever value you want. It is basically the time between two keyframes. The pathData contains the distance when the keyframe was recorded, so the code can be modified to use dynamic animationLength.

Some very satisfying numbers:

The previous version:
https://forum.babylonjs.com/t/sci-fi-tunnel-space-invader-3d-shooter-fast-prototype/18822

5 Likes