filbs111 / webgl-reflections

0 stars 0 forks source link

improve framerate #1

Open filbs111 opened 7 years ago

filbs111 commented 7 years ago

Unsurprisingly, runs at 1080p, 120fps (monitor refresh rate) OK on 4690K, GTX1080. However, on a Chuwi Hi12 with 2160x1440 screen, runs at ~10fps! Would like to run at higher FPS!

Added some test features to show that : If do not draw any world items (objects surrounding the portal object), framerate increases to 12fps. Frustum culling doesn't help noticably, and scaling the world items to ~0.1 gets the ~12fps. Therefore seems filled pixels are the problem here, rather than sending stuff to the vertex shader.

Not drawing the skybox and drawing items gets ~12fps. Drawing neither skybox nor items gets ~15fps.

A few things to try: 1) skybox drawing a) draw skybox after items (if items obscure a large fraction of sky, might be faster because can avoid texture lookup) b) copy skybox tex straight to render (for axis aligned cubemap render) c) reduce polys of sky (likely no effect) d) regular (not cubemap) texturing

2) reduce resolution of final render (2160x1440 is ~1.51920x1080, ~21024x1024)

3) align cubemap with camera to portal displacement, so can : avoid drawing "back" face texture reduce frequency of drawing "side" faces (eg to every other frame) with this, would be drawing 3 (1260x1440) + 3 = 6 times 1024x1024 per frame, rather than 3+6=9 as now, so might expect +50% framerate.

4) minor culling things that wont do better than switching off drawing items: a) cull items that are obscured by portal/reflector b) cull items on other side of portal that can't be seen (but will be seen by cubemap camera, so currently still drawn with "culling" on)

5) special case - don't draw the cubemaps or portal itself if not on final render screen (should speed up special case massively - just switching off cubemap rendering gives 22fps, pointing camera at sky gives 30fps)

6) direct rendering of stuff in portal instead of via cubemap. big enough for another issue.

filbs111 commented 7 years ago

seems like before did 2), AFAIK was rendering 1440x960 final render as devicePixelRatio=1.5, so is now by default slower! this partially explains why 3sphere-explorer project has higher framerate than wideanglecamera project - setting pixelSizeMultiplier to devicePixelRatio (1.5 on chuwi hi12) should retreive previous default performance.