Randomize textures from variants. #5837
Closed
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.
Pretend the letters are slightly different textures:
Adds
ImageGetter.getRandomImageVariant(baseFileName: String, seed: Int? = null): String
, which randomly chooses an image variant from all available, following the pattern:{"baseName", "baseName-A", "baseName-B", …, "baseName-Z"}
.Short-circuits quickly and should add only minimal overhead if there are no variants available.
Returned result is a new image path String, so it can further be used in other image-getting functions, like
getLayeredImageColored
. (Note the nation-coloured letters above.) (#3231 is also partly inspiration for this.)Used in all invocations of
.getImage
inTileGroup
, and only inTileGroup
.Hashcode of tile position
Vector2
is used as seed for terrain-y images to make sure the map doesn't change during gameplay.Added a
var randomnessSeed: Int
toMapUnit
that is set on construction and preserved on.clone()
for the same purpose. Currently@Transient
, deciding a visual effect isn't worth a save file field. I could see myself getting attached to a special Frigate and getting sad when it's changed on a save reload or something, though.I actually skimmed through all 118 invocations of
.getImage()
, andTileGroup
was really the only place where it made sense to use random variants. It's just as well to have such a clearly defined scope.Test files in above screenshot are available as example mod: https://github.com/will-ca/Unciv-Tileset-Variants-Example. If you fork it and tag the fork, I'll delete my repo to keep all the examples consolidated.
Why? Abstract reasons: Perfectly repeating patterns are very unnatural and jarring in textures. Randomly mixing just two or three variants is often enough to break up large-scale patterns a lot. Likewise clones don't exist, so slightly different units are always a really cool touch IMO.
Direct reason/Example: I was experimenting with breaking up coastlines/biomes with fractal and blended boundaries (#5835). Some results looked fairly natural. But repeating textures and patterns are still a big immersion breaker— What are the odds of there being fifty of the exact same, very distinctive mountain?
FantasyHex does a really good job hiding the repetition where possible and working it into the visual style otherwise. That gets harder with more realistic tilesets. I notice a lot more repetition with 5Hex. Contemplated CGI-generating a "photorealistic" tileset— Repetition would be a nightmare unless variants are possible.