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

Shadows and terrain blending. #6

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

Conversation

will-ca
Copy link

@will-ca will-ca commented Jan 4, 2022

To use:

  • Just run BuildTileset.sh. The source/original image files are in src/, and the build script will put blended versions in the right place in Images/.

Some ideas if you use this:

  • Play around with the settings! A lot can be done from just the shell script. E.G.:
    • Remove drop shadows from farms?
    • Make all mines use shear shadows instead of drop shadows?
    • Make oil well and manufactory use shear shadows instead of drop shadows?
    • Make shadow opacity, blur, angle, etc. look better?
  • Remove the base terrain backgrounds from natural wonders. The addBackground() steps in BuildTileset.sh automatically layers configured images on top of the blended versions of specified base terrains, so there's no need to make them part of the image. This will also let you add them to SHEARSHADOW_TILES or DROPSHADOW_TILES.
  • Revert changes to Mountain and Uluru. I edited the source sprites of these for cleaner blending, but only as a sloppy test. Revert changes to README. Also consider reverting/replacing Highlight and BorderImages. These need to be in the tileset because they need to have the same scale as tiles and units, but you can of course go with a different look. I tried to keep the commit history clean, so you should be able to undo each thing by just reverting the right commit (or cherry-picking everything else).
  • I would probably keep the src and build script in a separate branch, and then git add and cherry-pick only the final files into master for each update.
  • Fix up the scripts? E.G.: Fade out shear shadows below the base Y, make the bottom edges of tiles prettier, let the hex image expander work on an already-expanded image, make the hex mask function smoother yet (with vertical normals at ends of top edge?), implement the hex image mask and autocrop functions, don't add redundant shadows for the empire colour masks, etc.
  • Darken unlit parts of sprites?

As an alternative to merging this, downloading only the BuildTileset.sh and TileTransformer.py would also work as long as you copy all the needed images to src/5Hex/.

Oh, also: Don't merge this into master until yairm210/Unciv#5874 is merged and released for Unciv. Everything will just look broken without tileScale support.


EDIT: The diff isn't very readable, but the history's cleaner. Only the first four commits really matter.

@ravignir
Copy link
Owner

ravignir commented Jan 6, 2022

Dear god, it will take me a while to go over all of it :D

@will-ca
Copy link
Author

will-ca commented Jan 6, 2022

Lmao... Yeah, sorry. I wasn't thinking of the diff, so 99% of the changes are automatically generated and don't really need to be reviewed or PR'd.

I'll open another PR that's the same but without the automatic stuff and cleaner to read.

@ravignir
Copy link
Owner

ravignir commented Jan 7, 2022

Do i need linux to run that script? I am battling it since yesterday and i am about to give up as it keeps throwing me an error saying ModuleNotFoundError: No module named 'PIL'

@will-ca
Copy link
Author

will-ca commented Jan 7, 2022

Do i need linux to run that script? I am battling it since yesterday and i am about to give up as it keeps throwing me an error saying ModuleNotFoundError: No module named 'PIL'

@ravignir ...I believe you kinda/not-really need Linux for BuildTileset.sh (or Mac, or the Windows Subsystem for Linux, or Cygwin— You need Bash, which is installed by default on Linux but available just about anywhere nowadays— Mac uses Zsh by default, which is like Bash and may be (probably is) similar enough to work as a drop-in replacement here).

However, that error is spit out by Python, which means you seem to already be getting past the Linux bit. It refers to PIL/Pillow, the Python library I'm using to perform all the image operations.

TL;DR: Running either:

pip install Pillow

OR

python3 -m pip install --upgrade pip
python3 -m pip install --upgrade Pillow

...Should do fix it. (They do the same thing.)

Docs:

https://pillow.readthedocs.io/en/stable/

Package info:

https://pypi.org/project/Pillow/

Detailed installation instructions:

https://pillow.readthedocs.io/en/latest/installation.html

@will-ca
Copy link
Author

will-ca commented Jan 7, 2022

@ravignir Right, I've updated BuildTileset.sh so it will offer to install Pillow/PIL automatically if necessary, and made zsh (Mac) support official. You should be able to use that if you download/pull the new version from either here or #7.

If it still doesn't work, please paste your terminal output here! I wrote the dang thing so I can probably just tell you what's going wrong or add a fix instead of you having to spend hours battling it.

@ravignir
Copy link
Owner

Process SpawnPoolWorker-43:
Traceback (most recent call last):
  File "C:\Users\RV\AppData\Local\Programs\Python\Python310\lib\multiprocessing\process.py", line 315, in _bootstrap
    self.run()
  File "C:\Users\RV\AppData\Local\Programs\Python\Python310\lib\multiprocessing\process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\RV\AppData\Local\Programs\Python\Python310\lib\multiprocessing\pool.py", line 114, in worker
    task = get()
  File "C:\Users\RV\AppData\Local\Programs\Python\Python310\lib\multiprocessing\queues.py", line 368, in get
    return _ForkingPickler.loads(res)
AttributeError: Can't get attribute 'mog' on <module '__mp_main__' from 'C:\\Users\\RV\\Downloads\\5Hex-Tileset-blended6\\5Hex-Tileset-blended\\TileTransformer.py'>

Somehow, i was able to get there. @will-ca

@will-ca
Copy link
Author

will-ca commented Jan 11, 2022

@ravignir It appears to be a bug/limitation in Python itself that sometimes happens with multiprocessing:

https://bugs.python.org/issue25053

I've updated TileTransformer.py and BuildTileset.sh to disable multiprocessing by default. The crash you showed should be avoided now. Can you try again with the new TileTransformer.py and BuildTileset.sh?

(To reenable multiprocessing you can use the new -P flag. E.G. ./BuildTileset.sh -P. But that's not necessary, so it can be ignored if it causes crashes.)

@ravignir
Copy link
Owner

oz
oaz
so here are the initial results, after editing the image files and script.

@will-ca
Copy link
Author

will-ca commented Jan 13, 2022

Cool! And glad to see it now in the hands of a capable tileset artist.

…Ooh, the mountain bases look clean; Did you fix shadows showing below the base height? Side note: I think Victoria Falls may look better as a shear shadow than a drop shadow— I think that's one of the questionable default choices I'd made?

Also, looks like the shadows for Krakatoa and Cerro de Potosi are clipped at the edges. Possible solutions:

  • Increase tileScale/expansion factor to make room for them.
  • Decrease shear amount to move them away from the edge.
  • Change base sprite to move them away from the edge.
  • Implement and use another mask operation that uses the min of image alpha and a fadeout function. (Optimal solution IMO. I can PR this if you'd like.)

Do you have a branch, with the scripts, that I can open PRs against? I'd like to implement some features in the script that I haven't had a chance to yet:

  • Clip the unneeded southern regions from hexMaskPolygonalBalanced() so the southern edges of the map look nicer.
    • This will also let you use an extra "addBackground()" in the shell script to add a neat "bedrock"-type texture beneath all the base tiles if you want.
  • Implement hexMaskFromImage() so you can switch out to a custom blend mask if you so choose.

Also I am aware of yairm210/Unciv#5954, which affects how the blending looks in CityScreen. The fix should be relatively simple; I'll submit it to Unciv soon. It can also be worked around immediately by switching the Bash script to use fuzzPolygonalDilate instead of fuzzPolygonalFeather, although IMO fuzzPolygonalFeather gives better results in all other cases.

Aside from that, how do you feel about the workflow and results?

@ravignir
Copy link
Owner

Cool! And glad to see it now in the hands of a capable tileset artist.

Are you sure about that? :D

…Ooh, the mountain bases look clean; Did you fix shadows showing below the base height? Side note: I think Victoria Falls may look better as a shear shadow than a drop shadow— I think that's one of the questionable default choices I'd made?

I've edited Mountain Sprite and changed some values in script.

Also, looks like the shadows for Krakatoa and Cerro de Potosi are clipped at the edges. Possible solutions:

  • Increase tileScale/expansion factor to make room for them.
  • Decrease shear amount to move them away from the edge.
  • Change base sprite to move them away from the edge.
  • Implement and use another mask operation that uses the min of image alpha and a fadeout function. (Optimal solution IMO. I can PR this if you'd like.)

I decided to change sprites, should be ok now.

Do you have a branch, with the scripts, that I can open PRs against? I'd like to implement some features in the script that I haven't had a chance to yet:

https://github.com/ravignir/5Hex-Tileset/tree/blending

  • Clip the unneeded southern regions from hexMaskPolygonalBalanced() so the southern edges of the map look nicer.
    • This will also let you use an extra "addBackground()" in the shell script to add a neat "bedrock"-type texture beneath all the base tiles if you want.
  • Implement hexMaskFromImage() so you can switch out to a custom blend mask if you so choose.

Also I am aware of yairm210/Unciv#5954, which affects how the blending looks in CityScreen. The fix should be relatively simple; I'll submit it to Unciv soon. It can also be worked around immediately by switching the Bash script to use fuzzPolygonalDilate instead of fuzzPolygonalFeather, although IMO fuzzPolygonalFeather gives better results in all other cases.

Aside from that, how do you feel about the workflow and results?

I am quite happy with the results, it is a great script, I am a total noob when it comes to creating these. Looks like the only problems I've encountered were all Python's fault. BTW, Can you make another version of bubbly borders, but thinner?

@will-ca
Copy link
Author

will-ca commented Jan 15, 2022

Are you sure about that? :D

Indeed! I find the colour palette in 5Hex quite soothing to look at for some reason. And the scale and dedication are just admirable and enviable.

BTW, Can you make another version of bubbly borders, but thinner?

I've updated the border example repos to include the SVG source files, plus a Markdown file documenting some special techniques and workflows in them. You'll need a recent-ish version of Inkscape to edit them.

The high thickness was actually kinda a cheat on my part: I either couldn't or didn't want to figure out how to make the blurred inner colours show on only one side of the solid outer border, so I guess I just made the outer border thick enough to cover up half of the blur. I think you can probably get a thinner border by just playing around with the stroke thicknesses, blur radius, offset, and opacity though.

@ravignir
Copy link
Owner

Are you sure about that? :D

Indeed! I find the colour palette in 5Hex quite soothing to look at for some reason. And the scale and dedication are just admirable and enviable.

BTW, Can you make another version of bubbly borders, but thinner?

I've updated the border example repos to include the SVG source files, plus a Markdown file documenting some special techniques and workflows in them. You'll need a recent-ish version of Inkscape to edit them.

The high thickness was actually kinda a cheat on my part: I either couldn't or didn't want to figure out how to make the blurred inner colours show on only one side of the solid outer border, so I guess I just made the outer border thick enough to cover up half of the blur. I think you can probably get a thinner border by just playing around with the stroke thicknesses, blur radius, offset, and opacity though.

just a random thought: what if you added support for border variants to make them more random? You already did this here: yairm210/Unciv#5837

@will-ca
Copy link
Author

will-ca commented Jan 17, 2022

just a random thought: what if you added support for border variants to make them more random? You already did this here: yairm210/Unciv#5837

The biggest question IMO is what syntax to use in specifying the variants. Currently tile variants are already supported and use numbers, but extending that to more images could get confusing and borderline ambiguous because unit nation colours also use numbers. So break tileset compatibility and use letters as in that PR? Or use numbers everywhere, but end up with names like "Archer1-2.png" where the first number means variant and the second number means nation colour? …Maybe the first option; So far 5Hex's ancient ruins are the only existing use of tile variants that I've noticed, so the compatibility break may not be that bad.

I'll revive/update that PR and see where it goes.

@ravignir
Copy link
Owner

Or use numbers everywhere, but end up with names like "Archer1-2.png" where the first number means variant and the second number means nation colour?

Imo, that is easy to understand. "1" is variant, "-2" is layer.

@will-ca
Copy link
Author

will-ca commented Jan 18, 2022

Imo, that is easy to understand. "1" is variant, "-2" is layer.

Part of that concern IMO would be name collisions. Suppose it was "Archer-1-2.png" instead of "Archer1-2.png".

Now "Archer-1" could be either a variant of "Archer" or a nation colour for "Archer".

And now suppose a mod wants to add a unit called "Archer-1"? Idk. It just seems like it could all get quite messy if not well thought-out.

Hm. How would you feel about subdirectories being used for variants?

Units/Archer.png
Units/Archer-1.png
Units/Archer-2.png

Units/Archer/Variant1.png
Units/Archer/Variant1-1.png
Units/Archer/Variant1-2.png
Units/Archer/Variant2.png
Units/Archer/Variant2-1.png
Units/Archer/Variant2-2.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants