Skip to content

KUBA18i/SVG2UDMF

Repository files navigation

SVG2UDMF

A program that convert SVGs into Doom geometry, in UDMF format. Requires prior setup, can work with vectorised raster images. headpic

Examples:

Vector image to Doom Vector to Doom Raster image to Doom, vectorised in colour with Illustrator Raster to Doom, Illustrator Raster image to Doom, vectorised contour with svgco.de Raster to Doom, svgco If the SVG contains gradients, the program will convert them to a median singular colour. Handling gradients

Usage manual:

Typical SVGs won't work properly; it is necessary to prepare them first. What has to be done is:

  • Turn all Bezier curves into arrays of straight paths.
  • Use the CSG Divide modifier to make sure none of the polygons are overlapping one another.
  • Splice the remaining Compound Paths into two or more regular polygons. Once the SVG is composed of just simple polygons, it is ready to be processed.

Here's a video demonstrating how to use SVG2UDMF: Youtube Video

A written manual will also be provided below, in multiple stages. The workflow relies on Adobe Illustrator, but it is likely possible to achieve similar results with other applications, such as InkScape.

Preparing the SVG for export.

After opening the SVG in Illustrator:

  1. You must ensure all the objects are composed of straight lines and no Bezier curves, so you have to select them (you can use Ctrl+A), then select from the top left menu Object->Path->Simplify.... A small toolbar will appear, and you must press the gear icon near its right edge. In the menu that opens, check Convert to Straight Lines and drag the slider all the way to the left. If the preview looks okay, press OK. If not, cancel the operation, then select Object->Path->Add Anchor Points from the menu in the top left a few times, and repeat the process.
  2. Select all objects, and press Pathfinder->Divide to ensure no objects overlap one another.
  3. Now your image will be composed of mostly polygons, but also a few Compound Paths. Use the search bar in the bottom right menu to filter Compound Paths, and inspect how many of them are present. Your task now is to either split those compound paths into polygons, ignore them, or outright delete them. A Compound Path is pretty much a polygon that contains other polygons inside of it, so what you should do is use the Knife tool (you can find in hiddenin the toolbar on the left), then slice it so you are left with multiple polygons that don't have polygons inside of them. Since the sliced paths are likely going to be curvy, you should go through steps 1 and 2 again after you're done.
  4. Ungroup all objects, then save the SVG.

Using SVG2UDMF

If you're on Windows, you can just drag and drop the prepared SVG file onto SVG2UDMF.exe. Now you have a text file containing a bunch of geometry in the UDMF format. Since UDB expects BZIP2 compressed files for its prefabs, you can just drag and drop the resulting file into compressbzip2.bat. You will now have a .dbprefab file, ready to be loaded onto UDB.

If you're on Linux however, you can still run the Linux binary I have provided, then compress the result, like so:

SVG2UDMF_linux in.svg
bzip2 -c in.out.txt > out.dbprefab

Import into Ultimate Doom Builder

After you have a ready .dbprefab file, start UDB, then create a new map. In the menu that pops up, select UDMF/GZDoom format, and add svgcolours.pk3 (the PK3 I included in the release zip) as a resource. The PK3 contains 147 textures usable for floors, and they are solid colours defined in the SVG specification. Click the tree icon, or simply click Add Prefab, then select the file you have just created. After you see the silhouette on the screen, don't fret; you just press the Flip Vertically button on the panel on the right (sorry about that). Feel free to drag it wherever you want, and also resize however you want. After you're done, press Enter. The resulting sectors will likely need some refinements, and sometimes be very thin and/or broken, but you still have a solid set of lines to work with. The intent behind this program isn't to provide everything on a silver platter, but to reduce the amount of work necessary by creating such an image from scratch.

Raster to Vector?

Tools like Adobe Illustrator and svgco.de can turn raster images into vector ones, with varying results. Naturally, simple sketches with flat colours and shading will convert pretty nicely, whereas photos with great colour depths will look atrocious. But it's still a good idea to try and experiment, and perhaps reducing the colour depth of the input image or simply turning it into a monochromatic contour will work better. In the video and the images above, I demonstrate three raster pics that I had converted this way, so this is indeed a viable strategy. Naturally, after you've vectorised an image, you still need to follow the steps like with regular SVG files.

Proposed uses:

  • Drawing images with sectors is a popular practice in the Doom scene, so this software should definitely appeal to those that do it.
  • If anyone wishes to create a Doom map based on a real location, then using an actual top down map, like provided by OpenStreetMaps, together with this software will make it easier to ensure all the objects are up to scale.
  • It is likely possible to use Blender to import a scene from a more advanced game engine (such as Quake), then render the top down view as a SVG, which in turn can be converted into a Doom map.

Compilation

On Windows, if using VS2022, one can simply open the .sln file included in the repo, then compile. On Linux, one can accomplish this by running the compile_linux.sh file. Otherwise, one could use g++:

g++ main.cpp colours.cpp pugixml.cpp -o SVG2UDMF.exe -I.

Credits

SVG2UDMF is by Jakub Majewski
Doom is by Id Software
UDMF was devised by the Doom community and the ZDoom team
PugiXML was made by Arseny Kapoulkine

About

Convert SVGs into Doom geometry, in UDMF format.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors