Icon Renderer

Hi :slight_smile:

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! :wink: )

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 are assets/shaders/macosx/voxel.tzfx.json and assets/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

16 Likes

Very nice!

2 Likes

This will make generating icons for BUTT a breeze! Thank you very much for putting your time in to this ^^

5 Likes

:sweat_smile: I was going to tag you on this put i was looking at your images and thought you might have something similar already but guess not :sweat_smile:

1 Like

I had something yes but it wasn’t fully automatic, it was taking the icons from screenshots in-game, so this is 200% better.

3 Likes

Tip for installing the game for anyone else, you can use the following command (using steamcmd)

steamcmd +@sSteamCmdForcePlatformType macos +login username +force_install_dir /path/to/install +app_update 324510 validate +quit
1 Like

Full mini-guide for Linux users (anyone that wants to integrate this into existing tools etc.)

  1. Install prereqs (SteamCMD, Image Magick, Mesa/OpenGL)

  2. Install the MacOSX version of Boundless with the following command (replacing username and /path/to/install to your username and wherever you want it installed):

    steamcmd +@sSteamCmdForcePlatformType macos +login username +force_install_dir /path/to/install +app_update 324510 validate +quit
    
  3. Install the renderer:

    # Optional: if you are not using docker, 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 venv
    source venv/bin/activate
    
    # depends on a unreleased version of `modrengl`
    pip3 install git+https://github.com/moderngl/moderngl@67c9d33#egg=moderngl
    pip3 install git+https://gitlab.com/willcrutchley/boundless_headless_renderer.git
    
  4. Usage:

    # command usage the same as in OP now
    # render everything with no anti-aliasing
    # /path/to/install should match the path you installed Boundless to above
    # You _must_ add the --force-egl option, otherwise you need a DISPLAY
    boundless-icon-render -r 512 --force-egl -oibp -g /path/to/install
    
    # images will be in `out` folder in cwd
    

EDIT: There is actually a lot more setup for this if you are using Docker. If you need any help getting working inside of a Docker container, DM me.

2 Likes