renderer: introduce IF_FITSCREEN and RSF_2D#1145
Conversation
d23c90c to
a9463ea
Compare
IF_FITSCREEN to rescale image to the smaller size larger than screenIF_FITSCREEN and RSF_2D
|
Example with the chasm map being loaded, with |
dc84053 to
f4dd2b3
Compare
f4dd2b3 to
87d8065
Compare
IF_FITSCREEN and RSF_2DIF_FITSCREEN and RSF_2D
5ca11c1 to
c567434
Compare
|
I added a cvar named Values:
The The The following examples are done with the game running on a Feature disabled with value Feature enabled with default Feature enabled with |
c567434 to
e8077d6
Compare
|
The distorted images I got with the ATi R300 are the same I got with the Raspberry Pi 3, so this should also fix that bug on RPI3 too. At the time I got a crash later, I don't know if reducing memory usage helps on that other topic. But after that the main menu should be reachable without bug on RPI3, even if other bugs may happen later. |
5164507 to
f812bd6
Compare
| // If r_imageFitScreen is disabled, use nopicmip instead. | ||
| if ( ( image->bits & IF_FITSCREEN ) && !r_imageFitScreen.Get() ) | ||
| { | ||
| image->bits &= ~IF_FITSCREEN; | ||
| image->bits |= IF_NOPICMIP; | ||
| } |
There was a problem hiding this comment.
Is there a motivation for having this be something we can disable?
There was a problem hiding this comment.
This is only for asset debugging. We can for example imagine a game that would have a very large 2D minimap larger than screen and that the player could scroll. If someone finds weird the image is blurry, he can disable the feature and deduce that's because the fitscreen flag is set somewhere for that image.
There was a problem hiding this comment.
The same would be usable for debugging any image that would have received the fitscreen flag but should not use fitscreen like some 3D textures (or worst, lightmaps…).
src/engine/renderer/tr_local.h
Outdated
|
|
||
| int deformIndex; | ||
| bool overrideNoPicMip; // for images that must always be full resolution | ||
| bool overrideFitScreen; |
src/engine/renderer/tr_local.h
Outdated
| float polygonOffsetValue; | ||
|
|
||
| bool noPicMip; // for images that must always be full resolution | ||
| bool fitScreen; |
src/engine/renderer/tr_init.cpp
Outdated
| cvar_t *r_ignoreMaterialMinDimension; | ||
| cvar_t *r_ignoreMaterialMaxDimension; | ||
| cvar_t *r_replaceMaterialMinDimensionIfPresentWithMaxDimension; | ||
| Cvar::Range<Cvar::Cvar<int>> r_imageFitScreen("r_imageFitScreen", "downscale “fitscreen” images according to screen size: 0: do not downscale, 1: downscale as much as possible without being smaller than screen size, 2: downscale to never be larger then screen size", Cvar::NONE, 1, 0, 2); |
There was a problem hiding this comment.
explicitly note that 0 is "disabled"
There was a problem hiding this comment.
Also added (default) after the default one.
src/engine/renderer/tr_local.h
Outdated
|
|
||
| int deformIndex; | ||
| bool overrideNoPicMip; // for images that must always be full resolution | ||
| bool overrideFitScreen; |
There was a problem hiding this comment.
Why do we need both overrideFitScreen and fitScreen? it sounds like we could just make do with fitScreen
There was a problem hiding this comment.
This was bad cargo cult reproducing something stupid already done withshader.noPicMip and stage.overrideNoPicMip, the override name is only meaningful for enums, not boolean, to set something an enum value is used. I'm just renaming that as stage.fitScreen and in the future one will have to rename stage.overrideNoPicMip as well.
There was a problem hiding this comment.
The reason why there are two variables is because one is for shaders (applying to all stages), one is for stages.
I'm not sure it makes sense to have it as a stage keyword though, but the same image could be used in UI (and then use fitScreen) while also being part of a 3D shader blended with other images that do not need this feature.
… larger than screen
The current implementation of this code is an ugly HACK, make this HACK work with RSF_FITSCREEN. This HACK will disappear once RSF_2D is implemented.
f812bd6 to
b1a8f01
Compare
|
I may also add some option to prevent the generation of useless mipmaps on such image. |
|
Actually the game use
|
In fact imageParams.filterType = filterType_t::FT_LINEAR;Which already prevents the generation of mipmaps, as mipmaps are only generated with |




Introduce
IF_FITSCREENto rescale image to the smaller size larger than screen.The idea behind this feature is that we have images that should not be rescaled smaller than screen to look good:
So for them we use
IF_PICMIP, either directly in code, either with material keywordnopicmip.But then this stupid thing happen, let's imagine someone playing on a low end device with not a lot of GPU memory and a 800×600 screen:
The 4K levelshot is fully loaded in GPU memory just to display it on a
800×600screen!Here is what happens once this feature is implemented AND (not done yet) the related images are configured to use
IF_FITSCREEN:This is far better!
So this feature scales down images flagged with
IF_FITSCREENto the smaller size larger than (or equal to) the screen, this way the image is never underscaled compared to the screen, while not being too much large for nothing.Made for:
RSF_FITSCREENandRSF_2DUnvanquished/Unvanquished#2999