-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resize textures using GL_PROXY mechanism (and other things) #394
Conversation
It looks like there is some code right next to the code you added which is supposed to do exactly the same thing. What is |
I get |
Interestingly those are the values on the original code to scale down lightmaps:
Is That said, this hardware is not meant to support Testing against I still think the Basically |
I added a commit to fix skybox scaling according to the hardware limits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt you are supposed to divide the cubemap max size by 6, but who knows. According to this the max size is supposed to be at least 1024, so reporting the correct value would be illegal... I wonder if 4096 is a default value when the implementation doesn't provide a max size.
I just noticed something really stupid... GL error checking is disabled by default (r_ignoreGLErrors 1
). Turning it on, however, terminates the program the first time as an error. Of course the sensible thing to do would be a non-fatal log message. This should help diagnose things, since using a texture larger than the max size is one of the GL errors which can be produced.
I agree r_picmip
is a puzzling feature. I guess you could use it to test the downsampling code, or as a brute force way to reduce GPU memory. Both of which could be done with picmax as well. A quick google suggests it has been mostly popular as a cheat to make enemies more visible in various games.
I rewrote entirely the code to compute an image size, or to be more precise, to compute a pixel size in memory (see #378). I added two shader keywords, The The I added another cvar, So basically, texture is downscaled using Pictures may help to understand, in all those screenshots, models shaders have
|
This doesn't sound like a great practice to encourage, since you would still pay full price in file size and load times. Wouldn't something like this be better as part of the map build process? |
This is better as part of a map build process, but a mapper can still write shaders based on third-party texture set and other situations. Note that I did not added that because of a urge need. I see a real need for picMin so I did it, and right after than I've seen picMax could be done for free. There would be no issue to not have it, but once picMin is implemented, picMax costs nothing, so why not. |
src/engine/renderer/tr_image.cpp
Outdated
@@ -170,286 +580,270 @@ void R_ImageList_f() | |||
{ | |||
image = (image_t*) Com_GrowListElement( &tr.images, i ); | |||
char buffer[ MAX_TOKEN_CHARS ]; | |||
char imageType[ MAX_TOKEN_CHARS ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just use std::string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still TODO
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, there is still usage of Com_sprintf
, not sure how to handle that with std::string
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.c_str()
to get a char*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't know how to do this with std::string
:
Com_sprintf( imageType, sizeof( imageType ), "%5i ", image->type );
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Com_sprintf -> Str::Format
07bd0cf
to
69c1d4e
Compare
I've added a commit temporarily named |
This is basically what does the
after:
Original behavior sounded wrong, right? |
Unfortunately the new code to detect images being too large for the hardware does not work, or not the way we expect it. I never see them being downscaled. |
It works, but not the way we expect it for cube maps. If I double width and height when passing them to
Edit: hu, no, that does not work, I forgot I have previously set |
Well, if I do this (notice the scalingStep = CheckImage2D( internalFormat, scaledWidth << 3, scaledHeight << 3, 0, format, GL_UNSIGNED_BYTE ); it works:
|
I noticed that, on this computer reporting |
The current branch works, but I have no explanation for the multiplier. I've set |
I got this on debug build, I don't know how to fix it: #0 0x00005555558d618e in Str::AssertOnTinyFormatError (reason="\"tinyformat: Not enough conversion specifiers in format string\"") at /home/illwieckz/dev/buildme-unvanquished/Daemon/src/common/String.cpp:37
#1 0x0000555555650b73 in tinyformat::detail::streamStateFromFormat (out=..., spacePadPositive=@0x7fffffff4181: false, ntrunc=@0x7fffffff4188: -1, fmtStart=0x5555559bcf38 "", formatters=0x7fffffff4410, argIndex=@0x7fffffff4184: 5, numFormatters=7) at /home/illwieckz/dev/buildme-unvanquished/Daemon/libs/tinyformat/tinyformat.h:607
#2 0x00005555556518e2 in tinyformat::detail::formatImpl (out=..., fmt=0x5555559bcf38 "", formatters=0x7fffffff4410, numFormatters=7) at /home/illwieckz/dev/buildme-unvanquished/Daemon/libs/tinyformat/tinyformat.h:807
#3 0x0000555555651da9 in tinyformat::vformat (out=..., fmt=0x5555559bcef8 "Uploading compressed image %s with %d×%d size, mip %d, layer %d", list=...) at /home/illwieckz/dev/buildme-unvanquished/Daemon/libs/tinyformat/tinyformat.h:963
#4 0x00005555558223c1 in tinyformat::format<char [64], int, int, unsigned short, unsigned short, int, int> (out=..., fmt=0x5555559bcef8 "Uploading compressed image %s with %d×%d size, mip %d, layer %d") at /home/illwieckz/dev/buildme-unvanquished/Daemon/libs/tinyformat/tinyformat.h:973
#5 0x0000555555821a7f in tinyformat::format<char [64], int, int, unsigned short, unsigned short, int, int> (fmt=0x5555559bcef8 "Uploading compressed image %s with %d×%d size, mip %d, layer %d") at /home/illwieckz/dev/buildme-unvanquished/Daemon/libs/tinyformat/tinyformat.h:982
#6 0x0000555555820e8b in Str::Format<char (&) [64], int&, int&, unsigned short&, unsigned short&, int&, int&> (format=...) at /home/illwieckz/dev/buildme-unvanquished/Daemon/src/common/String.h:315
#7 0x000055555581faa9 in Log::Logger::Debug<char (&) [64], int&, int&, unsigned short&, unsigned short&, int&, int&> (this=0x555556236c80 <Log::defaultLogger>, format=...) at /home/illwieckz/dev/buildme-unvanquished/Daemon/src/common/Log.h:220
#8 0x000055555581e932 in Log::Debug<char (&) [64], int&, int&, unsigned short&, unsigned short&, int&, int&> (format=...) at /home/illwieckz/dev/buildme-unvanquished/Daemon/src/common/Log.h:272
#9 0x00005555558189c2 in R_UploadImage (dataArray=0x7fffffff4b18, numLayers=1, numMips=8, image=0x7fffd5f3b200, imageParams=0x7fffffffcf70) at /home/illwieckz/dev/buildme-unvanquished/Daemon/src/engine/renderer/tr_image.cpp:1127 |
…ters makes easy to extend and to pass data through multiple cascading functions
The upper limit of 3 assumed textures were still sized like in 1999. The code now already checks the value to not be negative.
I close this as commits will be cherry-picked in dedicated PRs. |
The ATI X1950 PRO can display the game with medium preset including full size textures except the skybox that is
1024^6
size:With
r_picMax
set to512
, everything looks good:The
r_picMax
cvar expects the size of an edge, sor_picMax
512 will scale down every image larger than a square image of512×512
size.Using
r_picMax 512
will scale down textures fromtex-vega
that are1024×1024
large but will not scale down textures fromtex-pk01
that are512x512
large. This way a map using both vega and pk01 textures will look highly textured with512×512
textures everywhere while usingr_picmip 1
would have displayed a mix of nice512x512
and ugly256×256
images.Both
r_picmip
andr_picMax
can be used at the same time. For example, by usingr_picmip 1
andr_picMax 512
, once minimap is set as nopicmip (see Unvanquished/Unvanquished#1230 ), the game will scale down all textures but the minimap to keep it clear, unless it is larger than 512, but minimaps with size up to 512 will not be scaled down…I added two shader keywords:
picMin
andpicMax
.The
picMin
one allows an artist to tell the renderer to never downscale a texture under this size. This is useful for models for example, since seeing details like the eyes and others is better.The
picMax
allows an artist to tell the renderer to downscale the texture to this size, even if the player is playing full size.I added another cvar,
r_picMin
, which allows to override thepicMin
value set in shader, and when it is set to-1
, never downscale images that haspicMin
value (it would be like making themnopicmip
).