[Guide] Making spritesheets with Blender

Place to post guides, observations, things related to modding that are not mods themselves.
User avatar
SkaceKachna
Burner Inserter
Burner Inserter
Posts: 11
Joined: Fri Aug 01, 2014 2:38 pm
Contact:

[Guide] Making spritesheets with Blender

Post by SkaceKachna »

This guide was created for Blender 2.66a, but should apply to any other version (UI might have different layout).

Step 1 - Transparency and shadows
In order to be usable in game, renders must have transparent background.
You can do so in Render section > Shading, by setting Alpha Mode to Transparent as shown below:
Image 1
Rendered image will now have transparent background, we are half way throught. Now we need to add shadows, but also keep the transparency.
To show shadow of object, add a Plane (Add > Mesh > Plane) to the scene and put it under object like this:
Image 2
the shadow will be now rendered onto the plane. But a problem arises, the plane now covers the transparent background!
Make sure you have only plane selected, then in right panel, select Material section and click on New button:
Image 3
Scroll down in the newly created material until you find Shadow subsection. In this subection, check the Shadows only option:
Image 4
this will hide plane, and leave only the shadow casted onto it. This is the result so far:
Image 5
Step 2 - Camera
Now its time to properly setup camera, so our rendered object actually looks like it belongs to the game. In outliner select Camera, move to Object Data section (should have icon of film camera). In this section, change Lens to Orthographics.
Image 6
Now, we need to move our camera to be under right angle. To do so, go to Object section (with Camera still selected), under Transform section change Position to following: X: 5, Y: -5, Z: 0 and Rotation to X: 45, Y: 0, Z:45
Press Numpad 0 (Or, in 3D View, select View > Camera) to see throught camera perspective. Camera is now looking at some unknown position. Try changing Z value in Position until you can see your object:
Image 7
If the object is too big for the camera, go back to Object Data section of Camera and try changing Orthographics Scale:
Image 8
Finally, we need to determine result image resolution. You can do so in Render section, Dimensions subsection under Resolution. I chose 250 x 200, which is resolution used for bigger objects.
Note: Actual resolution won't affect camera size, but aspect resolution ratio will also change aspect ratio of camera.
Image 9
Our rendered images now looks like this:
Image 10
Step 3 - Lighting
You may noticed, that shadow is on the left from the object, thats wrong, as Factorio has shadows going to right bottom-ish corner.
Also the shadow is little weird (you can't see it properly in low resolution of the render), thats why we change the light type to Sun (currenty its Point).
Select Lamp (or any object you're using for lighting) and go to Object Data section and under Lamp subsection select Sun (I didn't select it in image, because it will change icon of Object Data, which would led to confusion).
Image 11
Now it's up to you to properly position and rotate shadow. You should end up with something similiar to this:
Image 12
If you now render image, you can see, that shadow, althrought rightly positioned, doesn't have any opacity. We can easily fix this by selection Plane we created for shadow receiver, go to it's Material, scrolling down to Transparency section, checking it, and changing Alpha value, I left it at about 0.5, it looked just about right.
Image 13
Result so far:
Image 14
Step 4 - Rotation
Now we need to actually create rotating spritesheet from this object. We will do so by creating Animation.
But, before we do so, If your object is made from more smaller objects, you need to join them into one transform group, so you only need to rotate one object.
Add Empty (Add > Empty > Plain Axes), move it to center of your object, deselect it, select all your objects to be rotated and, as last object, select newly created Empty. Now press [Ctrl] + [P], popup will appear at your mouse. Select Object (Keep Transform).
Image 15
Rotating Empty will now rotate every object under it.

Step 4.1 - One image
If you need only one image, you can now rotate empty to fit your needs.

Step 4.2 - Rotating spritesheet
Now, we're entering the more complicated stuff.
First we need to move to frame 0. You can do so in Timeline (bottom part of screen in default layout), by changing frame number to 0.
Image 16
Now press , new popup will show, select Rotation. This will create basic keyframe with object aligned with axis, which is easier for editing.
Now move to frame 1, rotate object to face upwards (regarding camera), by going into Object section of Empty. In Transform subsection, change Z Rotation to 45. Press again and select Rotation. This will be first frame of spritesheet.

Image 17


Decide what will be your frame count, I chose 64, same count as for example car in Factorio. Enter the frame count to End field in Timeline.
Next, move to one frame after the last (65 in this case). We're doing this, because if we set last frame (64) to be completly rotated, there would be two frames of object facing up in the spritesheet.
Now change object Rotation Z to -315, press and select Rotation.

Image 18


Rotation is now complete. But if you try to play it, it doesn't rotate at constant speed! Thats because Blender is making it smooth.
To fix this, we need to open Graph Editor. With Graph Editor focued, press [A] (lines should be bold now), then press [Shift] + [E], small popup will appear, select Linear Extrapolation.

Image 19


Animation should now be object rotating at constant speed.

Step 5 - Creating spritesheet
This part is quite complicated and can't be done using regular Blender functions, but some awesome guy actually made addon named Spritfy for this:

http://wiki.blender.org/index.php/Exten ... r/Spritify

You need to have ImageMagick installed (You may need to restart blender after installing it).

To install this plugin, download .py file from link above, open File > User Preferences, go to Addons section and click on Install from file... , find downloaded spritify.py and select it.

Image 20


Plugin will appear in addons list, find it using search bar at top left and enable it.

Image 21


Click on Save User Settings and close dialog. Spritfy subsection should be now visible under Render section.

Image 22


The interface is pretty self-explanatory... but you won't have the File count section visible.

This should be ok for most cases, but with bigger image resolution, problem arises. Factorio can't load images with width or height bigger than 2000px.
You will need to split your spritesheet to multiple smaller spritesheets. Thats why I had to create modification to original script, that adds the File count option:

http://cerno.ch/~kamen/upload/spritify.py

Instalation and controls of modified version is same as original, only difference is the File count option.

Now, all you need to do is render animation:

Image 23


and spritesheet (s) will be automatically created (if not, click on Generate Sprite Sheet button).

Downloads
factorio_render.blend - Example blender file (created using this guide)
spritify.py - Updated version of spritify allowing creation of multiple files

User avatar
Stragemque
Inserter
Inserter
Posts: 23
Joined: Wed Sep 10, 2014 11:20 am
Contact:

Re: [Guide] Making spritesheets with Blender

Post by Stragemque »

Great tutorial some really us full stuff i did not know about blender, will definitely try my hand at some skin work now. :)
zinovic

jorgenRe
Filter Inserter
Filter Inserter
Posts: 535
Joined: Wed Apr 09, 2014 3:32 pm
Contact:

Re: [Guide] Making spritesheets with Blender

Post by jorgenRe »

Awesome tutorial so BUMP :D!
Because it would have saved me so much time if i had seen it yesterday :D!

Edit:
It would be extremely nice if this post was stickied since it would make life easier for so many newbies :D!
Logo
Noticed the told change in FFF #111 so il continue to use my signature ^_^
Thanks for listening to our suggestions, devs :D!
I would jump of joy if we could specify which tiles spawned in a surfaces

starholme
Fast Inserter
Fast Inserter
Posts: 201
Joined: Tue Oct 21, 2014 7:25 pm
Contact:

Re: [Guide] Making spritesheets with Blender

Post by starholme »

I'd like to see this one stickied as well. ssilk? Do you mind doing that for us?

Koub
Global Moderator
Global Moderator
Posts: 7175
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: [Guide] Making spritesheets with Blender

Post by Koub »

Seems legit, excellent topic from my point of view.
Koub - Please consider English is not my native language.

Lollipop
Burner Inserter
Burner Inserter
Posts: 14
Joined: Sun May 24, 2015 8:57 am
Contact:

Re: [Guide] Making spritesheets with Blender

Post by Lollipop »

I have had some issues with the spritify plugin you have posted.
When I try to generate a sprite sheet nothing happens at all. I have made sure that the animation had been generated, and I have tried both auto-generation and the manual button.
I have tested the plugin in both blender version 2.74 and in 2.66a, and they both behave identically.
I do have ImageMagick installed on my system with proper path setup.
I have also tested with a path both on the C and D drive on my computer.
I have also tried out using the unmodified plugin, although it doesn't behave any differently.

I am posting this here because I haven't been able to find answers to this anywhere.

User avatar
SkaceKachna
Burner Inserter
Burner Inserter
Posts: 11
Joined: Fri Aug 01, 2014 2:38 pm
Contact:

Re: [Guide] Making spritesheets with Blender

Post by SkaceKachna »

Hey, thanks for sticking this post, I forgot the it even exists
Lollipop wrote:I have had some issues with the spritify plugin you have posted.
When I try to generate a sprite sheet nothing happens at all. I have made sure that the animation had been generated, and I have tried both auto-generation and the manual button.
I have tested the plugin in both blender version 2.74 and in 2.66a, and they both behave identically.
I do have ImageMagick installed on my system with proper path setup.
I have also tested with a path both on the C and D drive on my computer.
I have also tried out using the unmodified plugin, although it doesn't behave any differently.

I am posting this here because I haven't been able to find answers to this anywhere.
It's hard to guess what could be the issue, could you provide log from blender, when you try to generate the sprite? You will need to show the blender console (Window > Show Blender Console) then try to spritify image. Some kind of error describing your issue should show up.

jorgenRe
Filter Inserter
Filter Inserter
Posts: 535
Joined: Wed Apr 09, 2014 3:32 pm
Contact:

Re: [Guide] Making spritesheets with Blender

Post by jorgenRe »

Lollipop wrote:I have had some issues with the spritify plugin you have posted.
When I try to generate a sprite sheet nothing happens at all. I have made sure that the animation had been generated, and I have tried both auto-generation and the manual button.
I have tested the plugin in both blender version 2.74 and in 2.66a, and they both behave identically.
I do have ImageMagick installed on my system with proper path setup.
I have also tested with a path both on the C and D drive on my computer.
I have also tried out using the unmodified plugin, although it doesn't behave any differently.

I am posting this here because I haven't been able to find answers to this anywhere.
Yea i got the same problem as you, so i used a gimp plugin to make the spritesheets, though it only made them in 1 line so you had to manually set the lines of sprites together, though it worked :) However i see now in the bottom there is a comment with another plugin that seems to let you create a spritesheet with more lines :O
Link to gimp plugin for creating spritesheets:
http://registry.gimp.org/node/25129
Edit tested it and oh my it works like wonders :O!
So much time could have been saved :C!
Logo
Noticed the told change in FFF #111 so il continue to use my signature ^_^
Thanks for listening to our suggestions, devs :D!
I would jump of joy if we could specify which tiles spawned in a surfaces

Lollipop
Burner Inserter
Burner Inserter
Posts: 14
Joined: Sun May 24, 2015 8:57 am
Contact:

Re: [Guide] Making spritesheets with Blender

Post by Lollipop »

My apologies for replying so late.

I decided to get that log you have requested and i discovered that running blender through the command line yields no problems, which gave me some trouble with providing the log. I had to take an image, sorry.
log
For now I will simply run blender through the command line.

Related page on stackoverflow:
http://blender.stackexchange.com/questi ... -to-a-file

User avatar
SkaceKachna
Burner Inserter
Burner Inserter
Posts: 11
Joined: Fri Aug 01, 2014 2:38 pm
Contact:

Re: [Guide] Making spritesheets with Blender

Post by SkaceKachna »

By the looks of it, you don't have TMP directory prepared. Usually you only need to create C:\tmp, but if that won't work,
try to change your output directory. To do so, select Render, then go to Output panel, there is /tmp\, with tiny folder icon on its right.
Output

Lost Ninja
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sun May 24, 2015 8:59 pm
Contact:

Re: [Guide] Making spritesheets with Blender

Post by Lost Ninja »

I followed this guide with one or two problems, caused mostly by learning blender as I went...

1)When I got to the stage of making the plane for the shadow, I set it up as described in the tutorial but if I de-selected/re-selected it then I lost most of the options that I'd had initially. Even deleting the plane and adding a new one didn't resolve this (nor did undo back past the original adding of the first plane). The only way round this I found was to revert to my previous save. I'm sure it was me missing something but I still cannot see what.

2)When trying to play the animation after having set up the various key frames etc, nothing happened. Took me a while to work out I needed to set the last frame in the render dialog too.

3)Lastly no matter how I install ImageMagick (or where) Blender apparently cannot see it and so the script doesn't load. I have the correct programs, they are in the path. And they work when called from the command line, yet Blender insists that ImageMagick is required to use the script.

Still I found a way round that with a standalone sprite sheet stitcher that works after a fashion (more complex to set up than I'd like).

Lollipop
Burner Inserter
Burner Inserter
Posts: 14
Joined: Sun May 24, 2015 8:57 am
Contact:

Re: [Guide] Making spritesheets with Blender

Post by Lollipop »

When installing ImageMagick, are you then allowing it to add itself to the systems path variable? If you do not, then ImageMagick cannot be used as a system command. Have you tried localizing the system path variable and check it?

In any case, do as SkaceKachna said, and enable the console in blender and post the output when run run spritify. This will give him to actually work with.

Lost Ninja
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sun May 24, 2015 8:59 pm
Contact:

Re: [Guide] Making spritesheets with Blender

Post by Lost Ninja »

I have tried installing IM into two different places, and had either or both of these locations added to my path, I can use the various IM programs from the command line (in any directory I choose) (eg convert - version) which implies that the IM has been added to my system path correctly. However regardless of where it is install blender appears unable to see it. (I have restarted both blender and the PC between installs.

Code: Select all

C:\IM;D:\Files\035-Programs\ImageMagick\;C:\Python34\;C:\Python34\Scripts;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;%systemroot%\System32\WindowsPowerShell\v1.0\
C:\IM & D:\Files\035-Programs\ImageMagick\; are the two different locations. I have tried with and without the trailing slash.

And until I can get Blender to recognise that IM is installed I will be unable to run the script to even find out what the console reports.

I'm using Blender 2.74 if that helps.

spritesheet
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sun Aug 02, 2015 6:17 am
Contact:

Re: [Guide] Making spritesheets with Blender

Post by spritesheet »

Wow, this will save me a ton of time!

So far I was rendering each frame as a separate png and then using a third party software to convert them into a spritesheet.

Thanks for the information!

Guest_4544
Long Handed Inserter
Long Handed Inserter
Posts: 59
Joined: Sat Dec 12, 2015 1:28 am
Contact:

Re: [Guide] Making spritesheets with Blender

Post by Guest_4544 »

This tutorial is very gud. It would also been very helpful if you mentioned that one has also to delete crop-cache.dat which would have saved me a few trouble figuring out why the sprites looked glitchy in-game.

if one wants to make a animation for lets say a car how should one do it? By using 128 frames for the wheels animation or even 512 frames?

A small guide to it would be nice.


I also had to use TexturePacker to make sprite sheets because the spritify plugin on v2.76 churns out a unusable mess, yet somehow the gif function works fine. I am using Linux 64bit if that should tell you something. And yes I have Imagemagick installed

AenAllAin
Long Handed Inserter
Long Handed Inserter
Posts: 61
Joined: Sat Apr 02, 2016 3:10 am
Contact:

Re: [Guide] Making spritesheets with Blender

Post by AenAllAin »

Wow! You saved me so much time getting this together. Thank you so much for this!

oresKa2
Burner Inserter
Burner Inserter
Posts: 19
Joined: Sun Aug 30, 2015 9:10 pm
Contact:

Re: [Guide] Making spritesheets with Blender

Post by oresKa2 »

should have know this before starting my 3 day graphical struggle

pancakeddd
Manual Inserter
Manual Inserter
Posts: 1
Joined: Fri Jul 01, 2016 7:22 am
Contact:

Re: [Guide] Making spritesheets with Blender

Post by pancakeddd »

Hey, i have been having this problem with that sprite plugin. every time i try to generate i get this error Image

jkeywo
Inserter
Inserter
Posts: 20
Joined: Fri Apr 08, 2016 9:19 am
Contact:

Re: [Guide] Making spritesheets with Blender

Post by jkeywo »

pancakeddd: Your problem is how you installed ImageMagick... 1/2 way througb there are a bunch of checkboxes, tick the one that mentions something like "legacy tools (e.g. convert)" and your problem should go away, that's what I ended up doing and it worked for me.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: [Guide] Making spritesheets with Blender

Post by darkfrei »

jkeywo wrote:pancakeddd: Your problem is how you installed ImageMagick... 1/2 way througb there are a bunch of checkboxes, tick the one that mentions something like "legacy tools (e.g. convert)" and your problem should go away, that's what I ended up doing and it worked for me.

Code: Select all

def find_bin_path_windows():
    import winreg

    REG_PATH = "SOFTWARE\ImageMagick\Current"
    
    try:
        registry_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, REG_PATH, 0,
                                       winreg.KEY_READ)
        value, regtype = winreg.QueryValueEx(registry_key, "BinPath")
        winreg.CloseKey(registry_key)
        
    except WindowsError:
        return None
            
    return value
I think this code can be portable, not installed only. How to change it?

PS: Blender Cycles Asset
Factorio_Building_3x3_03.blend.7z
(263.98 KiB) Downloaded 273 times
Harvester_05.7z
(274.83 KiB) Downloaded 317 times
Last edited by darkfrei on Fri May 18, 2018 4:06 pm, edited 2 times in total.

Post Reply

Return to “Modding discussion”