I am making a first-person horror game that runs in the browser: you wake on the last metro at 03:14 in a station that is not on the map, and something hunts you by sound. It is Three.js for the picture, React for the menus and HUD, and a fixed-step engine at 60 Hz that the renderer only reads and interpolates.
Free demo in the browser (the prologue and the first station, press "Run game"): https://kibbitz.itch.io/0314
It is still in early development, with more stations planned. My test machine is a laptop with Intel Iris Xe, so most of the recent work was about frame time. The numbers below are from that laptop.
Where it started: 13-14 fps in the first station at a 1920x1080 window, 1222 draw calls.
What helped, in order:
- One glass material had
transmission: 1, which makes three draw every opaque object a second time. Replaced with a plain cheap glass: 1222 -> 679 draws. - Two-sided see-through materials were drawn twice:
forceSinglePass. - Static geometry is merged by default now. A piece is kept as its own mesh only when it has to move, hide or dim. Merged by look, in cells of about 24 m: 679 -> 528.
- Small still pieces far from the camera are dropped through
layers: about 416. - MSAA 4 on a float target was the biggest single cost on the integrated GPU. There is now a middle quality tier for integrated GPUs (picked from the WebGL renderer string): FXAA instead of MSAA, and a fixed pixel budget of about one megapixel whatever the window size, stretched to fit.
- Light counts and shadow flags never change during a session, so nothing recompiles mid-game. Resolution only steps at a cut.
- The shader warm-up compiled programs for the canvas instead of the float target the scene really uses, so every program was built again inside the first frame. Compiling against the real target took boot to title from 25.5 s to 12.5 s.
Where it is now: 28-39 ms a frame at the poses I measure, so about 26-31 fps on the Iris Xe. Better, but 30 is only met at the lighter spots.
What I have not solved: what is left is GPU time, not draws. The title screen at 178 draws costs about the same as the platform at 443. If you have fought per-pixel cost on integrated GPUs (lights per pixel, bloom, float targets), I would like to hear what worked for you.
And if you try the demo, tell me how it runs on your machine.