Skip to content
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

Search preloaded random textures in TextureManager::GetRandomTexture #783

Closed

Conversation

dpw13
Copy link
Collaborator

@dpw13 dpw13 commented Feb 20, 2024

We currently only check textures loaded from files when selecting a random texture. Since we purge textures between presets, if a preset uses something like sampler_rand00, no presets will be found, the returned sampler will be null, and we end up creating invalid GLSL. This PR doesn't check the results of GetRandomSampler to make sure they're valid, but does extend GetRandomSampler to include preloaded textures. As this list includes volumetric textures, also filter textures by type. This type defaults to 2D textures and is not otherwise specified elsewhere as I can't find evidence that GetRandomSampler is ever expected to return a 3D texture.

Copy link
Member

@kblaschke kblaschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will completely eliminate using the textures from disk, and also removed the prefixed random texture selection. m_textures only contains a few textures used by previous presets, the "M" and headphones image and the noise textures - solely using it will reduce the number of visible textures a lot and often use the crappy noise textures, which we don't want.

While the texture purge clears the scanned texture file list, there's a call to ScanTextures(); in this method which will refresh this list if it was purged.

So rather than changing the whole random texture selection process into something seemingly much worse, we should focus on fixing the reason why the m_scannedTextureFiles might be empty in a certain case when it shouldn't be.

Note that if you don't set a texture path, this list will always be empty. Instead of returning a nullptr, we could as well create a 1x1 black texture and return this instead.

@dpw13 dpw13 marked this pull request as draft February 21, 2024 13:12
@dpw13 dpw13 self-assigned this Feb 21, 2024
@dpw13 dpw13 added the bug label Feb 21, 2024
@dpw13
Copy link
Collaborator Author

dpw13 commented Feb 21, 2024

This turned out to be an empty search path in frontend-sdl2, which I'll fix separately. It looks like things work as expected when the texture search path is sane.

@dpw13 dpw13 closed this Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants