[Guide] Making spritesheets with Blender

Place to post guides, observations, things related to modding that are not mods themselves.

[Guide] Making spritesheets with Blender

Postby SkaceKachna » Tue Aug 12, 2014 9:21 pm

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
Image


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
Image


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
Image


Scroll down in the newly created material until you find Shadow subsection. In this subection, check the Shadows only option:

Image 4
Image


this will hide plane, and leave only the shadow casted onto it. This is the result so far:

Image 5
Image


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
Image


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
Image


If the object is too big for the camera, go back to Object Data section of Camera and try changing Orthographics Scale:

Image 8
Image


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
Image


Our rendered images now looks like this:

Image 10
Image


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
Image


Now it's up to you to properly position and rotate shadow. You should end up with something similiar to this:

Image 12
Image


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
Image


Result so far:

Image 14
Image


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
Image


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
Image


Now press [I], 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 [I] again and select Rotation. This will be first frame of spritesheet.

Image 17
Image


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 [I] and select Rotation.

Image 18
Image


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
Image


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
Image


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

Image 21
Image


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

Image 22
Image


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
Image


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
SkaceKachna
Burner Inserter
Burner Inserter
 
Posts: 11
Joined: Fri Aug 01, 2014 2:38 pm

Re: [Guide] Making spritesheets with Blender

Postby Stragemque » Fri Sep 12, 2014 7:32 pm

Great tutorial some really us full stuff i did not know about blender, will definitely try my hand at some skin work now. :)
zinovic
User avatar
Stragemque
Burner Inserter
Burner Inserter
 
Posts: 11
Joined: Wed Sep 10, 2014 11:20 am

Re: [Guide] Making spritesheets with Blender

Postby jorgenRe » Mon Jun 01, 2015 6:05 am

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
Image

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
jorgenRe
Filter Inserter
Filter Inserter
 
Posts: 479
Joined: Wed Apr 09, 2014 3:32 pm
Location: Tromso Norway

Re: [Guide] Making spritesheets with Blender

Postby starholme » Mon Jun 01, 2015 8:13 pm

I'd like to see this one stickied as well. ssilk? Do you mind doing that for us?
starholme
Fast Inserter
Fast Inserter
 
Posts: 145
Joined: Tue Oct 21, 2014 7:25 pm

Re: [Guide] Making spritesheets with Blender

Postby Koub » Mon Jun 01, 2015 8:58 pm

Seems legit, excellent topic from my point of view.
Koub - Please consider English is not my native language.
Koub
Moderator
Moderator
 
Posts: 1245
Joined: Fri May 30, 2014 8:54 am
Location: France

Re: [Guide] Making spritesheets with Blender

Postby Lollipop » Thu Jun 04, 2015 2:41 pm

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.
Lollipop
Burner Inserter
Burner Inserter
 
Posts: 10
Joined: Sun May 24, 2015 8:57 am

Re: [Guide] Making spritesheets with Blender

Postby SkaceKachna » Thu Jun 04, 2015 2:56 pm

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.
User avatar
SkaceKachna
Burner Inserter
Burner Inserter
 
Posts: 11
Joined: Fri Aug 01, 2014 2:38 pm

Re: [Guide] Making spritesheets with Blender

Postby jorgenRe » Thu Jun 04, 2015 2:57 pm

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
Image

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
jorgenRe
Filter Inserter
Filter Inserter
 
Posts: 479
Joined: Wed Apr 09, 2014 3:32 pm
Location: Tromso Norway

Re: [Guide] Making spritesheets with Blender

Postby Lollipop » Fri Jun 12, 2015 2:37 pm

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
Image

For now I will simply run blender through the command line.

Related page on stackoverflow:
http://blender.stackexchange.com/questions/6921/how-to-write-the-output-of-blender-console-out-to-a-file
Lollipop
Burner Inserter
Burner Inserter
 
Posts: 10
Joined: Sun May 24, 2015 8:57 am

Re: [Guide] Making spritesheets with Blender

Postby SkaceKachna » Fri Jun 12, 2015 4:13 pm

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
Image
User avatar
SkaceKachna
Burner Inserter
Burner Inserter
 
Posts: 11
Joined: Fri Aug 01, 2014 2:38 pm

Next

Return to Modding discussion

Who is online

Users browsing this forum: No registered users and 2 guests