Open sprunk opened 1 week ago
Wouldn't be better to load all images from the map or the game and put it into a lua table for easy access?
Access how? You could convert it into a 2d lua table so it's image[x][z] = {r, g, b, a}
but that sounds like it would have pretty terrible perf and memory overhead. But sure, maybe there could be a Spring.ReadImageAsLuaTable("path") -> table
.
Access it by having it load up when the game starts and close it when the game close.
That would be bad, you'd load up a ton of garbage that you might use once and not need anymore afterwards.
User story
Reading an image has many use cases that would be useful in synced.
define a complex curve by drawing a 1xN gradient, for example for custom weapon damage fall-off.![image](https://github.com/beyond-all-reason/spring/assets/2573076/3d8b814f-d823-4bb6-b6ff-14d8a522eeb4)
define metadata for map terrain simply by drawing over it.![image](https://github.com/beyond-all-reason/spring/assets/2573076/cdd21547-8544-4661-8f10-7a871d0a90ad)
encoding spatial patterns in an image can generally result in both more readability and less verbosity compared to a bunch of numbers in a lua file.
In particular, the engine currently implements game design via the metalmap being part of the map format. Making it possible to read resource distribution from a raw image would let us decouple it. Mappers would probably be happy as well.
Request & implementation remarks
Add a synced interface to read a pixel from an image file, i.e.
I am not specifying what the
img
param should be because there are caveats: