How to cut a rendered model in two sprites
Moderator: Graphics Moderators
-
- Tycoon
- Posts: 1829
- Joined: 10 Jul 2006 00:43
- Location: Spain
How to cut a rendered model in two sprites
This is a tutorial to cut the models in two or more sprites to code it as PNG images. My English is not very good, and I have GIMP in Spanish, and I don't know how set it in English.
Some sprites have their own ground sprite (1429 or 1447), other sprites have a standard concrete ground (1420). Some examples are the hotel (1450 and 1453), the fountain 1455. The parks have a grass ground tile (1456 and 1457). Most of tropical sprites doesn't have ground sprite and can be cut. Some buildings (the church) have a default sprite (bare land) in some of their construction stages.
If the sprite doesn't have their own ground sprite, it must be rendered without ground. This is very important.
These steeps could be done with Your favorite image editor, It must support layers.
First, You need make four copies of the original layer, and set off the visibility of "reference" and "building".
Second, the layer "aux" must be rotated 180º and must be moved to the bottom, because the shape of the opposite side of the base will cut the "base" layer.
Some sprites have their own ground sprite (1429 or 1447), other sprites have a standard concrete ground (1420). Some examples are the hotel (1450 and 1453), the fountain 1455. The parks have a grass ground tile (1456 and 1457). Most of tropical sprites doesn't have ground sprite and can be cut. Some buildings (the church) have a default sprite (bare land) in some of their construction stages.
If the sprite doesn't have their own ground sprite, it must be rendered without ground. This is very important.
These steeps could be done with Your favorite image editor, It must support layers.
First, You need make four copies of the original layer, and set off the visibility of "reference" and "building".
Second, the layer "aux" must be rotated 180º and must be moved to the bottom, because the shape of the opposite side of the base will cut the "base" layer.
- Attachments
-
- Models from trg1r.grf
- models.PNG (33.09 KiB) Viewed 1772 times
-
- Four layers
- tuto00.PNG (56.21 KiB) Viewed 1773 times
-
- Reversed layer that will cut the bottom layer.
- tut01.png (60.15 KiB) Viewed 1772 times
Last edited by maquinista on 28 Aug 2008 18:09, edited 3 times in total.
Sorry if my english is too poor, I want learn it, but it isn't too easy.
- [list][*]Why use PNG screenshots in 8 bpp games.
[*]Caravan site New Industry. · Spain set. · Some spanish trains for locomotion[*]Favourites:GRVTS · ECS · FIRS
-
- Tycoon
- Posts: 1829
- Joined: 10 Jul 2006 00:43
- Location: Spain
Re: How to cut a rendered model in two sprites (WIP)
The next steep is get a layer mask. Click with the right mouse button on the layer name of "aux" an click in "Layer to Image Size".
Then, click in "add layer mask", and select "transfer layer's alpha channel". Click in the layer "base" with the right mouse button and click in "add layer mask", but this time select "white".
Select the layer mask of the layer "aux" (only click in the thumbnail) and copy it (ctrl + C). Click in the thumbnail of the layer mask "base", and paste the layer (ctrl + V) and then "Anchor layer". Turn off the visibility of the layer "aux", because It wont be used. The ground sprite is almost completed. But... the street lights was chopped
(It will be recovered latter).
Turn on the visibility of the layer "building", and draw a Path with the path tool. This path must define the outline of the building in the base. In transparent areas, this pat mustn't touch the building.
Then, click in "add layer mask", and select "transfer layer's alpha channel". Click in the layer "base" with the right mouse button and click in "add layer mask", but this time select "white".
Select the layer mask of the layer "aux" (only click in the thumbnail) and copy it (ctrl + C). Click in the thumbnail of the layer mask "base", and paste the layer (ctrl + V) and then "Anchor layer". Turn off the visibility of the layer "aux", because It wont be used. The ground sprite is almost completed. But... the street lights was chopped

Turn on the visibility of the layer "building", and draw a Path with the path tool. This path must define the outline of the building in the base. In transparent areas, this pat mustn't touch the building.
- Attachments
-
- Layer masks in GIMP's layers dialog.
- tuto02.png (2.07 KiB) Viewed 1736 times
-
- Where is the street lights? Is easy recover it.
- tuto03.png (19.85 KiB) Viewed 1742 times
-
- Path around the building. It mustn't touch the building in transparent areas.
- tuto004.png (56.24 KiB) Viewed 1738 times
Sorry if my english is too poor, I want learn it, but it isn't too easy.
- [list][*]Why use PNG screenshots in 8 bpp games.
[*]Caravan site New Industry. · Spain set. · Some spanish trains for locomotion[*]Favourites:GRVTS · ECS · FIRS
-
- Tycoon
- Posts: 1829
- Joined: 10 Jul 2006 00:43
- Location: Spain
Re: How to cut a rendered model in two sprites (WIP)
Next step: click in "select -> From Path" in the image's window and turn off the visibility of the layer "building". Select the layer (not the mask) "base" and click in "Lock Alpha channel" option.
Select a gray color (I always use this: RGB 555151 ), and fill the selected area with this color. You can use the "Bucket Fill" tool, or drag and drop the color from the toolbox.
Then, click in "select->invert" in the menu. Select the pencil tool, click in the layer mask of the layer "base", select a white color (RGB FFFFFF) and paint around the edges of the base layer (not around the selected area) also, paint in the street lights to recover them. See the second screenshot that aren't show in the post.
Select a gray color (I always use this: RGB 555151 ), and fill the selected area with this color. You can use the "Bucket Fill" tool, or drag and drop the color from the toolbox.
Then, click in "select->invert" in the menu. Select the pencil tool, click in the layer mask of the layer "base", select a white color (RGB FFFFFF) and paint around the edges of the base layer (not around the selected area) also, paint in the street lights to recover them. See the second screenshot that aren't show in the post.
- Attachments
-
- Select the layer, before lock the alpha channel. Then, fill the selected area with the color.
- tuto05.png (5.85 KiB) Viewed 1697 times
-
- Paint in the edge and the street light.
Use a white color and paint over the layer mask, not in the layer.
Also don't get a brush very small, a brush 5 px radius is a good brush. - tuto06.png (44.29 KiB) Viewed 203 times
-
- Ground sprite. Don't remove the selection.
- tuto07.png (6.76 KiB) Viewed 1697 times
Last edited by maquinista on 28 Aug 2008 17:47, edited 2 times in total.
Sorry if my english is too poor, I want learn it, but it isn't too easy.
- [list][*]Why use PNG screenshots in 8 bpp games.
[*]Caravan site New Industry. · Spain set. · Some spanish trains for locomotion[*]Favourites:GRVTS · ECS · FIRS
-
- Tycoon
- Posts: 1829
- Joined: 10 Jul 2006 00:43
- Location: Spain
Re: How to cut a rendered model in two sprites (WIP)
The next step is the "building" layer. Don't remove the selected area and select the layer "building" and turn its visibility on.
This will be done with the quickmask. Turn it on with SHIFT + Q, and the not selected area will take a red color.
Click in "colors->levels" and set the first text box in 254 (see screenshot) and the borders of the selection will have 100% selected. Press SHIFT + Q again and press delete (edit->clear, or delete in keyboard).
Click in "select -> none".
This will be done with the quickmask. Turn it on with SHIFT + Q, and the not selected area will take a red color.
Click in "colors->levels" and set the first text box in 254 (see screenshot) and the borders of the selection will have 100% selected. Press SHIFT + Q again and press delete (edit->clear, or delete in keyboard).
Click in "select -> none".
- Attachments
-
- Quickmask turned on with shift + Q.
- tuto08.png (5.51 KiB) Viewed 1679 times
-
- Applying levels.
- tuto09.png (10.83 KiB) Viewed 1683 times
-
- Base of the building deleted.
- tuto10.png (22.34 KiB) Viewed 1676 times
Sorry if my english is too poor, I want learn it, but it isn't too easy.
- [list][*]Why use PNG screenshots in 8 bpp games.
[*]Caravan site New Industry. · Spain set. · Some spanish trains for locomotion[*]Favourites:GRVTS · ECS · FIRS
-
- Tycoon
- Posts: 1829
- Joined: 10 Jul 2006 00:43
- Location: Spain
Re: How to cut a rendered model in two sprites (WIP)
The building is almost completed, but It will look a bit buried between the grass tiles. It must be raised two pixels, but.. Is needed a base to avoid transparent pixels in the game. This pixels gets random colors and looks ugly.
Take this image from wiki:
http://wiki.openttd.org/wiki/index.php/ ... 420_z0.png
Save it in the hard disk and drag and drop the file in to the building. It will be a new layer. Put this layer in the bottom of the layer stack. And move the layer at the center and at the bottom of the image, 2/3 pixels under the ground sprite. Sometimes this layer will be out of the canvas. Click in "image->Fit Canvas to Layers".
The building is finished. Save a copy in XCF.BZ2 format before take the PNG sprites.
The number of sprite of the ground is 1544. Set off the visibility of the layers "building", "aux" and "reference", and save a copy as "1544_z0.png". Set off the visibility of all the layers and turn on "building" only and save other copy as "1545_z0.png". You will be asked because PNG file format doesn't accept layers, select "merge layers" option. Don't save the PNG files with a layer mask selected (You would get the layer mask), select first the layer "building", or other layer.
Don't save too much metadata in the PNG file and don't save transparent pixels.
The next step is with PNGcodec, and It has been explained much better than I can do.
Take this image from wiki:
http://wiki.openttd.org/wiki/index.php/ ... 420_z0.png
Save it in the hard disk and drag and drop the file in to the building. It will be a new layer. Put this layer in the bottom of the layer stack. And move the layer at the center and at the bottom of the image, 2/3 pixels under the ground sprite. Sometimes this layer will be out of the canvas. Click in "image->Fit Canvas to Layers".
The building is finished. Save a copy in XCF.BZ2 format before take the PNG sprites.
The number of sprite of the ground is 1544. Set off the visibility of the layers "building", "aux" and "reference", and save a copy as "1544_z0.png". Set off the visibility of all the layers and turn on "building" only and save other copy as "1545_z0.png". You will be asked because PNG file format doesn't accept layers, select "merge layers" option. Don't save the PNG files with a layer mask selected (You would get the layer mask), select first the layer "building", or other layer.
Don't save too much metadata in the PNG file and don't save transparent pixels.
The next step is with PNGcodec, and It has been explained much better than I can do.

- Attachments
-
- Added the concrete tile.
- tuto11.png (26.5 KiB) Viewed 252 times
-
- Where put the concrete tile.
- tuto12.png (15.89 KiB) Viewed 250 times
-
- Saving PNG files.
- tuto13.png (23.42 KiB) Viewed 246 times
Sorry if my english is too poor, I want learn it, but it isn't too easy.
- [list][*]Why use PNG screenshots in 8 bpp games.
[*]Caravan site New Industry. · Spain set. · Some spanish trains for locomotion[*]Favourites:GRVTS · ECS · FIRS
- habell
- Transport Coordinator
- Posts: 374
- Joined: 04 Mar 2004 12:47
- Location: Veenendaal, The Netherlands
Re: How to cut a rendered model in two sprites
Thanks for this very clear tutor 

-
- Tycoon
- Posts: 1829
- Joined: 10 Jul 2006 00:43
- Location: Spain
Re: How to cut a rendered model in two sprites
How to set the offsets easily:
I use PNGcodec with batch files. This files are very useful, because You won't need use the console.
A batch file has the extension .BAT or .CMD, and has intructions line by line.The final line "pause" allows to read the result of the "pngcoding" process. Without the "pause", the console window will shut down very quickly.
To cheek if the sprites are well positioned I run the game, and I find the sprite in the screen or I try to build it. Then, I bulldoze the surrounding tiles. I appears pixels with random colors or is a bit lower than the other tiles, the sprite is not well positioned. With a screenshot (Print Screen key) and a image viewer (I use Irfanview, with paste) with a very large zoom, It is easy to count the pixels that the sprite must be moved.
I use PNGcodec with batch files. This files are very useful, because You won't need use the console.
A batch file has the extension .BAT or .CMD, and has intructions line by line.
Code: Select all
pngcodec.exe
pngcodec r 1495_z0.png x_offs=-125 y_offs=-53
pngcodec r 1496_z0.png x_offs=-125 y_offs=-53
pngcodec r 1568_z0.png x_offs=-125 y_offs=-106
pngcodec r 1569_z0.png x_offs=-125 y_offs=-106
pngcodec r 1424_z0.png x_offs=-125 y_offs=-233
pngcodec r 1425_z0.png x_offs=-125 y_offs=-233
pngcodec r 1534_z0.png x_offs=-125 y_offs=-292
pngcodec r 1535_z0.png x_offs=-125 y_offs=-292
pause
To cheek if the sprites are well positioned I run the game, and I find the sprite in the screen or I try to build it. Then, I bulldoze the surrounding tiles. I appears pixels with random colors or is a bit lower than the other tiles, the sprite is not well positioned. With a screenshot (Print Screen key) and a image viewer (I use Irfanview, with paste) with a very large zoom, It is easy to count the pixels that the sprite must be moved.
- Attachments
-
- Example with concrete tiles. If You move a window (of the game) over the strange pixels, It will take random colors. If these colors are different than the surrounding tiles, It will be easier to count the offset pixels.
- offsets.png (32.85 KiB) Viewed 1464 times
Sorry if my english is too poor, I want learn it, but it isn't too easy.
- [list][*]Why use PNG screenshots in 8 bpp games.
[*]Caravan site New Industry. · Spain set. · Some spanish trains for locomotion[*]Favourites:GRVTS · ECS · FIRS
Who is online
Users browsing this forum: No registered users and 13 guests