Skip to content

Allow loading an image multiple times with different params #1695

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

Merged
merged 1 commit into from
Jul 16, 2025

Conversation

slipher
Copy link
Member

@slipher slipher commented Jul 12, 2025

E.g. different nopicmip or imageMaxDimension.

Fixes Unvanquished/Unvanquished#2801

This could be useful if an image needs to be loaded with and without sRGB conversion (IF_ flags are part of the image params).

We have a handful of images in game assets that will be loaded multiple times:

image params mismatch for gfx/weapons/tracer/spark: 0x2 0 0/0 128 0 vs. 0x0 0 0/0 0 0
image params mismatch for models/buildables/arm/screen_s: 0x0 0 0/0 128 0 vs. 0x0 0 0/0 16 0
image params mismatch for models/players/human_male/base: 0x0 0 0/0 0 0 vs. 0x0 0 0/0 128 0

@illwieckz
Copy link
Member

Great! Indeed we may want to render an image in the UI or to render the same image on a 3D surface, so many flags may differ (fitscreen, srgb…). One good example of that is an ATCS clone that replaced the end game firework sprite with the granger emoticon.

@illwieckz
Copy link
Member

Maybe the _black, _red, _green_ and _blue images are exceptions too? At least for sRGB conversions 0 and 1 are always 0 and 1.

@slipher
Copy link
Member Author

slipher commented Jul 12, 2025

That would be possible, to set a boolean on image_t for built-in images that can ignore params: ones that have all pixels the same, and have color channels equal to 0 or 1. The practical benefits would be small though: _white, _black, and _flat are hard-coded into the shader parser (so it would never reach the image loader in most cases) and I don't think _red, _green, or _blue are used that often.

@illwieckz
Copy link
Member

OK, this is good enough for a start.

I don't think _red, _green, or _blue are used that often.

I may one day modify the shared_colors materials to use them in engine. But that's not a big issue: those images are all very small.

@slipher
Copy link
Member Author

slipher commented Jul 12, 2025

Hmm actually I do need to implement something like that, since it is impossible to reload a builtin image from a file -- loading will just fail. But it needs to be for any builtin image, not just ones that are truly param-independent. Maybe I will just use the hack of checking if it begins with _.

EDIT: did this.

@illwieckz illwieckz added T-Improvement Improvement for an existing feature A-Renderer labels Jul 12, 2025
Copy link
Member

@illwieckz illwieckz left a comment

Choose a reason for hiding this comment

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

LGTM.

@slipher slipher merged commit 3c925c7 into DaemonEngine:master Jul 16, 2025
9 checks passed
@slipher slipher deleted the image-mismatch branch July 16, 2025 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Renderer T-Improvement Improvement for an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Warn: reused image 'textures/nova_sfx/ventilation_01.tga' with mixed allowPicmip parm for shader"
2 participants