[rtexture] Cubemap mipmap loading improvements #4721
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Another two patches for loading cubemaps with mipmaps. Hopefully the last ones 😅
Two fixes in one PR for loading cubemaps with mipmaps:
GL_LINEAR_MIPMAP_LINEAR
/RL_TEXTURE_FILTER_MIP_LINEAR
orGL_NEAREST_MIPMAP_LINEAR
/RL_TEXTURE_FILTER_NEAREST_MIP_LINEAR
, because those require all possible mipmaps to be available1. For cubemaps with no mipmaps (just the base mipmap level), there is no need to generate any mipmaps (or use VRAM to store them), because the user wouldn't expect there to be any mipmaps in the first place. Thus, only build cubemap mipmaps when necessary.1
(on the CPU), regardless of the actual number of mipmaps present on the GPU. This change neatly ties in with the first patch, because we can just use the number of mipmaps the image has, were we may or may not have generated them.I tested that the
model_skybox
example still works, and obviously I tested it with my own IBL setup, where everything also works.As last time, I structured the PR to be able to just be rebased onto master if you want all the different changes to reflect in the tree.
Footnotes
This is not entirely true for "normal" OpenGL, but since there is no way to set
GL_TEXTURE_MAX_LEVEL
in plain raylib, I'd say it applies for us. See "The base and max levels must only specify mipmap levels that have been allocated [...]" here ↩