Editor v3

Gorgon

So, the radio silence is now over, at least for this post. I’ve been toiling away on creating an editor for Gorgon so people can edit sprites, and images (somewhat).

A little about the editor

The editor is similar to the one in v2 in that it is completely plug in driven. That is, almost all functionality is based on plug ins, and without any plug ins the editor is nothing more than a file manager.

The advantage of this is that end users can write their own plug ins for their own content. For example, if you’re making a game that uses a tile map, you’ll likely want a tile map editor. Instead of writing your own full fledged editor, and trying to make it work with the Gorgon file system, you could write a plug in for the Gorgon editor that allows you to create tile maps. All file system manipulation is taken care of, and with default plug ins, even sprite creation and image handling is all in the same place as your tile editor.

Where this version differs from 2.0 is … well, pretty much everything else. The previous incarnation opened up a packed file and copied the contents to a temp folder, and when you worked on the content, it’d alter the file in the temp directory. When you saved the project, it’d repack the file with the updated content. This has proven to be less than performant.

The new editor works more like Unity now, in that you pick a folder on your hard drive and you use that for editing your content. The folder is no longer temporary, so you can use it directly in your applications, or, should you want a packed file, you can export it as a packed file using the Gorgon packed file format (a plug in, a developer could create one that writes zip files if they so choose). You can also import packed files using the default plug ins for the Gorgon packed file format, or zip files.

Plug ins

Obviously, the editor is useless without plug ins. So, Gorgon (as of this writing) comes with 2 plug ins out of the box. The image editor, and the sprite editor. As time and energy allow, more will be added as development continues.

Image Editor

Image Editor
The image editor, with a volume texture loaded. It even has a volume rendering preview.

The image editor is a bit of a misnomer. You don’t actually paint on the image/texture like you would in Paint.Net or Photoshop. It’s mostly a viewer, but there is some editing functionality like changing the image type, image format, updating array slices, mip levels and, if you have a 3D (volume) texture: depth slices. As you can see in the screenshot above, there’s a volume texture loaded with Perlin noise (and some alterations done by me – that’s the black line) with a nifty volume rendering preview to show how the texture will look. I’ve yet to see any image editor handle volume textures, so this is particularly handy.

Adding array index data, mip data, and depth data is easily done by dragging an image into the image area on the screen. You can drag from the file explorer on the right hand side, or you can drag from Windows Explorer. If you have a texture cube, it will even change the view to the typical cross format and you can drop an image into each face, and it will also support multiple image cubes in the same texture (by having an array count that is a multiple of 6).

If you want to edit the image data (i.e. paint some pixels), then Gorgon will take the current array index/mip level/depth slice and export it as a PNG file and load it into the editor associated with PNG files. When you are done editing, the image will automatically update in the editor.

When images are imported into the editor, they are converted to DDS format. Why? Well:

  • DDS is a ubiquitous format and has been around forever and designed for textures exclusively.
  • It supports every texel format.
  • It supports DXt compression – This is very useful when you have a lot of image data to load into the GPU.
  • And it’s just easier to deal with one file format instead of trying to guess which format should be used when loading/saving image data.

Now, with that said, images imported into the editor will be converted from their native format into DDS. So you can import any image file format supported by Gorgon, and, of course, by any image codec plug in you supply (this is supported, but no image codec plug in management is available in the editor yet – soon).

Sprite Editor

Sprite Editor
The sprite editor.

The sprite editor allows you to clip out sprites from image/texture files and save those clipping coordinates, and other metadata into a file that can be read back and used. This saves a lot of grief if you’re trying to build up a bunch of sprites by not having to copy them out by hand.

Sprites can be clipped in the usual way by dragging and resizing a rectangle around on the screen. And if you need pixel level accuracy, you can bring up the Manual Input window and enter the coordinates in by hand. You can also clip sprites by using a fixed size selection rectangle.

But, you’re not limited to just drawing a rectangle to get at your sprite data. You can also use the sprite picker to click on a sprite in the image, and the sprite editor will do its best to determine the bounds for that sprite and surround it with a tight fitting rectangle. Or, if you want some spacing, you can also pad the rectangle by a specified number of pixels.

The picker works by using a masking color/alpha value as means to locate the boundaries. When you click on the sprite it starts sampling the image in multiple directions and if it hits the masking color/alpha value, it stops and takes that as a minimum/maximum bound area. It then continues this process until the full extents are found (it’s basically a dumb flood fill). This masking color/alpha value can be modified by the user.

Sprites can also have their corners (vertices) moved independently to allow skewing of the sprite using a corner offset editor.

Other functions like altering the sprite color (or individual sprite corner/vertex color), and anchor point editing are also available. And the texture wrapping functionality changes the view to show what each wrapping mode along the X and Y axes would look like, and allows you to apply wrapping to the sprite (be aware though, that if you’re using a texture atlas, then the results will differ from the editor view).

Sprites can also be imported into the editor like images, and by using plug ins, external formats can be loaded and converted into the Gorgon sprite file format. Currently this import process supports Gorgon v1, v2 and v3 sprite files.

What’s next

Well, there’s a few things that need to go in. Such as plug in management support for sprites and images so users can bring in other formats not supported natively by Gorgon. Also, a tool to clip multiple sprites from a texture atlas using a grid, and a sprite atlas creation utility.

Ideally, I’d like to have a Font editor and Animation editor in there. But those will take some time to get off the ground. And the Animation editor is higher priority for me, so that one would be tackled first.

Anyway, that’s it. The most current commits on the v3.0 branch on Github have the updated editor code, so feel free to check it out. And report any bugs you find on the Github issues page.