Closed curioustorvald closed 3 years ago
Calculation is the one slows things a lot; need to test all the recent commits on less powerful PC.
~41 fps on my macbookpro 9,2; shader is running very efficiently -- no boost even if smoothing is disabled.
Can't get the lightmap downsampling to work -- weird horizontal lines all over
With fixing camera position at integer numbers, downsampling only works when the screen is NOT resized.
Was able to achieve downsampling w/o texture issue (keeping default LINEAR filter was the culprit, fixed with NEAREST), now camera-related choppiness is an issue. Fortunately, downsample factor of 2 is not noticeable when blurring is turned on, so I'd settle there.
Tricks applied so far:
New idea: at least we can make drawing faster using fragment shader to make the GPU tile itself, and while you're at it, also apply it to the block drawing.
Lightmap is now fully downsampled, no need to draw blocks in a naive way -- just draw px on pixmap.
Update lightmap on every other frame is now ditched, will produce "jitter" when the camera moves.
One last question: Can we make it faster by calculating the lightmap on GPU using Fragment Shader?
Further optimisation was done by memoising the result of DynamicLumFunction every frame to cut down the unnecessary function calls caused by torches.
See branch "NEWLIGHT2"
Can be mitigated by updating only on every other frame (frameskip of 2 is too slow for fast-moving player). Old mini-tile smoothing can be replaced with blocky render with blur shader.