-
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
revamp cubemap code and fix quake3 skybox with small bottom face, fix #142 #179
Conversation
|
Note that this issue was first faced with Tremulous maps so the issue is very likely to occur because that was a supported feature of Tremulous, hence the regression label. |
|
Hi @illwieckz |
|
Why not examine the sizes of all sides and scale them all to the biggest just in case there exists a skybox with this trick done on another side than the bottom? You could even have the algorithm skip sides that already equal the detected size. |
|
oh right, there was some boring spaces, fixed! |
|
@megatog615 I thought about it but it would require some extra code for an occurrence that will probably never happen… probably not worth it. |
|
I just thought about a way to check on all faces while not being so much intrusive so I added a commit trying that instead. By the way even if it may look possible to do this for all kind of supported cubemap, I really doubt this kind of feature exists outside of quake3. |
|
I was bored by the skybox code so I revamped it entirely. The skybox code was very ugly with 10 gotos and buggy behavior, for example it would not attempt to load any multi-file skybox if a single-file skybox was successfully loaded but had invalid content. Also, the code was inefficient, for example it was doing the image rotation operation for every face even if the rotation had an angle of The skybox faces are now resized to the size of a square that has for width and height the greater width and height found among the six faces of the cube. This way it would not only fix the quake3 skyboxes with smaller bottom faces, but also non-square skyboxes. |
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.
We no longer have to live in fear: the goto's are vanquished!
src/engine/renderer/tr_image.cpp
Outdated
| @@ -1937,23 +1937,53 @@ static void R_Rotate( byte *in, int width, int height, int degrees ) | |||
| ri.Hunk_FreeTempMemory( tmp ); | |||
| } | |||
|
|
|||
| byte *R_Resize( byte *in, int width, int height, int width2, int height2 ) | |||
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.
This could use a comment or a different name to indicate that it's specifically for upsampling, not any resize.
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.
do you think that algorithm does not work for downscaling?
we only use it to upscale, but isn't it generic enough to downscale too?
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.
Well maybe, if not with the best quality. But there's already a downsampling function ResampleTexture in the same file.
55afc66
to
6e3792d
Compare
b114737
to
1d45c0c
Compare




Skybox code revamp
The skybox code was very ugly with 10 gotos and buggy behavior, for example it would not attempt to load any multifile skybox if a single-file skybox was successfully loaded but had invalid content.
Also, the code was inefficient, for example it was doing the image rotation operation for every face even if the rotation has an angle of 0°, hence allocating a new image, copying all the pixels in the new image et. for nothing.
Irregular skybox fixing
Some quake3 skyboxes were shipped with a smaller bottom face, for example a
16×16bottom face while other faces were512×512that was probably a trick to save file size when textures were stored losslessly in a tga and bandwith was low as voice modems.To fix this, a new
R_Resizefunction is added totr_image.cppthat is just a wrapper toResampleTexturethat makes in-place resizing easier.The faces are resized to the size of a square that has for width and height the greater width and height found in any face. This way it would not only fix the quake3 skyboxes with smaller bottom faces, but also non-square skyboxes.
A warning is displayed so the user is encouraged to fix the skybox because 1. we workaround something that is broken, 2. user may is likely to have access to tools with resize algorithms that produce better looking results.
In any way, those kind of small bottom faces were likely to not be seen, that's also why they were downscaled at first.