Hi
I’ve been working on a little script to render icons for items, blocks etc and it’s finally in a state where I feel like I can share it.
EDIT: Usage and installation has been modified slightly thanks to some changes from @Angellus
It creates images a bit like these:
which hopefully you agree look fairly close to the real thing.
Almost everything is working well, including blocks, props and items, although don’t expect a flawless reproduction of what you would see in-game, there will always be slight differences.
The scope of the project is to render still images of items/props/blocks as they would appear in the GUI (think inventory slots).
This means that certain things aren’t rendered - such as chiselled blocks or the actual model (not crate) of a workbench. You also can’t customise the rotation of things - again the aim is to render things as they would appear in the game GUI.
The major thing which does not work is foliage - i.e the bushy leaves on a leaf block.
As such the script by default doesn’t render things like leaves or trellis blocks since they look incorrect, but this can be overriden if you’re up for some slightly more broken images.
If you notice something isn’t included which you think should be (other than foliage!) or anything looks incorrect, let me know and I’ll see if I can figure it out (suggestions are also welcome).
If you want to use/modify the code for your own project feel free, but it’d be lovely if you could tag/credit me since this did take me a looooong time (thanks! )
Download:
Installation
# Optional: create a virtualenv to avoid messing up your system Python
# you will need to re-run the `source` command in every new shell before running `boundless-icon-render`
python3 -m venv [environment_name]
source [environment_name]/bin/activate
# depends on a unreleased version of `moderngl`
pip3 install git+https://github.com/moderngl/moderngl@67c9d33#egg=moderngl
pip3 install git+https://gitlab.com/willcrutchley/boundless_headless_renderer.git
- Since I did not want to include any files from the game itself (not sure about the rules on this) you need to point the script to your boundless installation (see the usage section, this has been streamlined thanks to Angellus).
- Additionally the script requires shaders specifically from the macOS version of Boundless.
If you don’t have access to a mac, you can use a project named DepotDownloader or steamcmd to obtain these (so long as you own the game). (If you know a different way to get the files, go for it, any method should work!)
The files you will need areassets/shaders/macosx/voxel.tzfx.json
andassets/shaders/macosx/skylight.tzfx.json
. These should be placed in your own boundless installation (updating boundless shouldn’t affect these files)
Details on using DepotDownloader to get the required files
You will need to run the depotdownloader executable with the following arguments:
-app 324510 -username [STEAM_USERNAME] -password [STEAM_PASSWORD] -depot 324511 -filelist file.txt
where file.txt has the following two lines of text:
assets/shaders/macosx/voxel.tzfx.json
assets/shaders/macosx/skylight.tzfx.json
- Done?! Hopefully that all worked and you can move on to the usage section below. If anything was unclear do ask!
Usage
You can run the script by running boundless-icon-render
.
Files are output to the out
directory.
Running with -h
should display the help screen below:
note the inclusion of the
-g
option now. This is a required argument to provide the location of your boundless installation (which should include those shaders you downloaded earlier)
The one thing not covered in that help screen is --style
. This can be uniform
or greedy
(greedy
is the default).
With uniform
the camera is always placed a constant distance away from whatever is being rendered. This results in a constant “pixel density” in the rendered images, but also leads to a lot of empty space since this constant distance has to cater for the biggest objects.
As an alternative, greedy
attempts to position the camera as close as possible to minimise empty space in the images.
Hopefully that help screen makes everything else clear.
For the two sample images shown the commands used to render them were:
boundless-icon-render -r 512 -ao --name TOOL_HAMMER_RIFT -g [PATH_TO_BOUNDLESS]
boundless-icon-render -r 512 -ao -bc 13 --name WOOD_ANCIENT_TRUNK -g [PATH_TO_BOUNDLESS]
and if for example you wanted to render everything at 512x512,
boundless-icon-render -r 512 -oibp -g [PATH_TO_BOUNDLESS]
(WHICH IS EQUIVALENT TO)
boundless-icon-render --resolution 512 --override --items --blocks --props -boundless-path [PATH_TO_BOUNDLESS]
would do this (without the anti-aliasing).
Enjoy!
EDIT (13/04/21): Handling of decal colours has changed. Instead of rendering every possible combination of base and decal colour (resulting in over 6000 combinations) it instead uses the same colour index for the base and decal textures (resulting in just 255 combinations).
I think this is accurate for the things that the script tries to render.
A side effect of this is that the parameter -dc
has been removed since it is now redundant