curioustorvald / Terrarum

Modular game engine for a side-scrolling tilemap platformer, and a game that runs on top of it
Other
13 stars 0 forks source link

LightmapRenderer.renderLightMap() is tad too slow #5

Closed curioustorvald closed 3 years ago

curioustorvald commented 7 years ago

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.

curioustorvald commented 7 years ago

Calculation is the one slows things a lot; need to test all the recent commits on less powerful PC.

curioustorvald commented 7 years ago

~41 fps on my macbookpro 9,2; shader is running very efficiently -- no boost even if smoothing is disabled.

curioustorvald commented 7 years ago

Can't get the lightmap downsampling to work -- weird horizontal lines all over

curioustorvald commented 7 years ago

With fixing camera position at integer numbers, downsampling only works when the screen is NOT resized.

curioustorvald commented 7 years ago

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.

curioustorvald commented 7 years ago

Tricks applied so far:

curioustorvald commented 7 years ago

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.

curioustorvald commented 6 years ago

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?

curioustorvald commented 4 years ago

Further optimisation was done by memoising the result of DynamicLumFunction every frame to cut down the unnecessary function calls caused by torches.

curioustorvald commented 3 years ago

See branch "NEWLIGHT2"