RBXMX pixelMapper | Simple Python Map Image Rendering

RBXMX pixelMapper

Create images based on data from Raycasts in Roblox

Intro

Hi! I am Landon90. Last week I decided I want to try to make a simple way to create images that represent maps of Roblox games. I messed around a bit with Raycasting and trying to find a simple way to export all the data from the Raycasts that is needed to make an image. I found a solution, that may not be appropriate for everyone, but as long as it can help someone I would be happy!

Solution

RBXMX miniMapper is a technique used to gather raycast information and export it as a .rbxmx file which can be read by a python script so that an image can be made. You use the pixelMapper module script in Roblox studio to create a folder which you export as a .rbxmx file. Then run the python script or the .exe on the .rbxmx file to make an image.

How does it work?

The module script runs a grid of raycasts down in the area encompassed by the part named “Area” and sends the data into StringValues inside of a folder in the workspace. Then once the folder in the workspace is exported as a .rbxmx file, the Python script can read the .rbxmx file and create a .png image using Pillow.

Where can I get it?

You can get the module script for studio here
You can get the python script on GitHub here

What is RBXMX?

RBXMX is the file extension that can be used when saving Roblox data to files as an XML document.

What is pixelMapper

pixelMapper is just the name that I chose to call my method. It was originally called miniMapper, but this method is more specifically used to gather information for pixels in an image and is not an all-in-one for creating mini maps.

Examples

Crossroads (Studio Resolution 500x500)

500-500-Map

Crossroads Height Map Only (Studio Resolution 500x500)

500-500-HeightMap

Crossroads Auto Height Map and Color (Studio Resolution 500x500)

500-500-AutoHeightMap

Crossroads (Studio Resolution 1250x1250)

SFOTH (Studio Resolution 1024x1024)

SFOTH Height Map Only (Studio Resolution 1024x1024)

SFOTH Auto Height Map and Color (Studio Resolution 1024x1024)

Tutorials

Text Tutorial

RBXMX pixelMapper

A project by Landon90

V.0.9.0

Before you begin make sure…

  • You save changes to your game. If you try to make an image with too high of a resolution you can possibly crash your Roblox Studio. Know your computer’s limits.

  • If you want to run the Python script yourself make sure you have the latest version of Python installed from here

  • If you are running the Python script yourself make sure you have NumPy and Pillow

  • If you don’t want to use the Python script and are on Windows you can use the pixelMapper.exe however some antivirus software my flag it. To run it anyways you will have to approve of the program in your antivirus. If you do not trust this .exe you can make it yourself, but it does require Python.

  • You understand that within this document if there is any mention of miniMapper or RBXMX miniMapper, that is this project’s previous name. The name has been changed to RBXMX pixelMapper to better suit the work it does.

Tutorial

Step 1:

If you would like to create this script yourself, check out the source code from here

  • Type this into the command line. Feel free to leave the comment out, but do not yet press enter.

local mapper = require(workspace.pixelMapper:Clone()) --[[We clone this in the case you want to directly change the ModuleScript]]

Step 2:

  • Size the Area part within the pixelMapper ModuleScript to encompass the whole region you would like to have mapped.
    • Do not rotate the Area part. It must have an orientation of (0,0,0)

Step 3:

  • To set the resolution use the setResolution(x,y) function or change the script directly. If using the function your command line should look similar to the code below.

  • If you are manipulating the code directly, change the pixelMapper.resolutionX and pixelMapper.resolutionY variables.

local mapper = require(workspace.pixelMapper:Clone())

mapper.setResolution(x,y) --[[Replace x,y with the resolution you would like the base data image to be. The higher the numbers the more work and higher chance of crashing.]]

Step 4:

  • Choose the mode you would like to use to export.

  • exportMap(applyHeightmap, heightRange)

    • exports the information needed to create a colored image of the map. If applyHeightmap is true then it adds shading based on the height information and heightRange. heightRange defaults to .6 if not specified, and is the range that V in HSV can be manipulated per pixel.
  • exportHeightMap()

    • exports the information needed to create an image of only the heightmap in a grayscale format.
  • exportAll(heightRange)

    • calls exportMap() exportMap(true, heightRange) and exportHeightMap() giving you all possible export folders.
    • be careful when using this on a high resolution.

local mapper = require(workspace.pixelMapper:Clone())

mapper.setResolution(x,y) --[[Replace x,y with the resolution you would like the base data image to be. The higher the numbers the more work and higher chance of crashing.]]

mapper.exportMap() --[[This will give us the map color with no height information. You can use any of the other export functions to substitute.]]

Step 5:

  • Enter the chain of code into the command line.

  • Wait for Studio to process the entire script and create the folder in workspace.

  • Once the folder has been created, right click the folder and click ‘Save to File…’

  • Save the file as a .rbxmx with no spaces in the file name.

File being named properly with no spaces and saved as a .rbxmx file

Step 6:

  • Pass the .rbxmx file into the Python script.

    • If you are using Python put the .rbxmx file in the same directory as pixelMapper.py and try
      • python pixelMapper.py RBXMX-File-Name.rbxmx
    • If you are using pixelMapper.exe you can just drag the .rbxmx file onto the pixelMapper.exe file and it will run.
      • If you want to make the .exe file yourself run
        • pyinstaller --onefile --icon=pixelMapper.ico pixelMapper.py
  • Files should end up in the same directory as the .rbxmx file.

Original

Original pixelMap image before upscaling.

Upscaled

Original pixelMap image before upscaling.

Video Tutorial

Video Tutorial

RBXMX pixelMapper Tutorial - YouTube

14 Likes