PixelGuys / Cubyz

Voxel sandbox game with a large render distance, procedurally generated content and some cool graphical effects.
GNU General Public License v3.0
420 stars 49 forks source link

Resolution up-/downscaling #99

Closed IntegratedQuantum closed 3 months ago

IntegratedQuantum commented 11 months ago

I would love it if other games had this option. My monitor is often too big for my integrated graphics card, which makes games lag and sometimes even setting all graphics features to lowest is not sufficient for lag-free gameplay.

Additionally this feature might be useful for debugging and performance-testing.

zenith391 commented 11 months ago

I've seen some games implement it as resolution scale, usually configurable from 25% (downscaling) to 200% (upscaling). It shouldn't be too hard to implement

IntegratedQuantum commented 11 months ago

Yeah, super-sampling is also a good idea. Though the downscaling might be a bit finicky. I cannot just linearly interpolate because I need to do some post-processing on the individual pixels first for fog calculations.

zenith391 commented 11 months ago

Usually, rendering scale is just applied to the viewport size, so let's say the window size is 800x600, a 75% would have a viewport size of 600x450 (like if the window was 600x450) instead of 800x600. So in theory it shouldn't change anything in the fog calculations (unless Cubyz can only render with sizes of powers of 2 but that's not the case) and the only thing that change is that the UI is still rendered at native resolution.

Basically do fog calculations before downscaling

IntegratedQuantum commented 11 months ago

The problem is that the shader that currently renders from the internal framebuffer to the screenbuffer is also handling the fog. This shader can and should be directly reused for upscaling, but for downscaling a new shader would be required, that manually samples and interpolates.

a 75%

I don't want to do weird stuff like that. I want to use nearest-neighbor sampling for upscaling. I don't like how blurry it looks when games use linear sampling. And for nearest-neighbor sampling only powers of 2 make sense. So I would probably limit the entire thing to the factors ¹⁄₄, ¹⁄₂, 1, 2