Author Topic: Using Blender to Create Simutrans Graphics  (Read 15078 times)

0 Members and 1 Guest are viewing this topic.

Offline Sarlock

Using Blender to Create Simutrans Graphics
« on: October 12, 2013, 02:12:11 AM »
Using Blender to Create Simutrans Graphics

When I first installed blender and loaded it for the first time, I spent several hours trying to figure out how to do even the simplest function.  It was difficult to navigate around the scene and even more difficult to figure out how to construct an object.

Having used it for a good while now, I have finally figured a few things out and I am hoping that writing this tutorial will assist others in learning the program in a much shorter time and begin to make beautiful graphics for Simutrans as well.

Blender has many advantages when creating Simutrans graphics that a normal hand-drawn method does not.

  • You can scale objects with ease.  You can increase the size of your entire structure or just parts of it with just a few clicks.  Doing that by hand requires you to often redraw entire sections.
  • You can produce all 4 rotations easily.
  • You can produce most snow images much easier than by hand
  • You can borrow objects from other projects and add them to your current one in any location/rotation
  • Built in anti-aliasing.  The renderer does this for you.  Doing this by hand requires considerable skill.
  • Shadows.  Everything in your scene will have a shadow that is done at the right angle.

Zeno has also posted some convincing reasons to try to use blender here.

Blender tutorials written by Zeno.

I will preface this tutorial right now to say that this is for using the Windows version.  Everything is basically the same for other operating systems except for a few Windows-specific keyboard shortcuts.
It is also important to mention that I am still quite new to blender.  For every tutorial instruction I give below there are probably 5 or more different ways to accomplish the same task, many of which are probably faster and more efficient than what I present.  I offer only what I've learned thus far.

Disclaimer: This tutorial is current as of Blender 2.68.  Subsequent versions may change some of the commands and layout.

If you find any errors in this tutorial, something doesn't work, etc, please let me know right away.

I will attempt to update this as necessary with any future changes.

PART 1: Navigating The Scene

By now you have installed blender and are ready to use it for the first time (or maybe you've used it in the past and gave up, as I almost did).

Your scene opens up with a camera (the pyramid with the black triangle on top), a light (the circle with the two dashed circles around it) and a cube.

Holding down your mouse wheel allows you to rotate your view around the centre.  Hold it down and move your mouse around and you will be able to rotate around and see your cube from any direction.  If you do not have a mouse wheel, you can also rotate the camera using your numberpad: 2, 4, 6 and 8 will rotate your view up, down, left and right.

The mouse in blender is a bit counter-intuitive until you get used to it.

Selecting an object: You can select an object with the right mouse click.  Select the camera with a single right click.  Select the lamp with a single right click.  Now select the cube again with a right mouse click.

Moving an object: Single click the object you want to move, it will get a yellow outline around it.  Now hold the right mouse button down and move the object.  Once the object starts moving, you can release the right mouse button and the object will stay mobile with your mouse.

You have two options at this stage: if you click the right mouse button again,  the object will abort its movement and return to its original location.  If you click the left mouse button, the object will be placed at its new position.

UNDO: Short-cut key for undo is CTRL-Z.  You will use this a lot.  This is one of many key short-cuts that blender just assumes that you know.

Selecting more than one object: Hold down your SHIFT key and then right click more than one object.  You will see that the last object you select will have a yellow outline and the other objects selected before will have orange outlines.  You will do this a lot in the future.  Also notice that you can deselect one of your objects using this as well.  If you have selected the cube and camera and only want the cube, SHIFT-right click the camera and it will deselect it. (if the camera is not the current selection, in yellow, you will need to click it twice to remove it, once to make it the active selection in yellow and then another time to deselect it)

Important shortcut commands to remember:

These two commands are your best friends.  Learn them.

A - Select/Deselect All A is used to select everything on the screen.  In our starting scene it will select the cube, camera and the lamp.  In a large complex scene it will grab everything.  The A key is a toggle, first press selects everything, second press deselects everything.  You will find that your use of A is most often used to deselect things that are currently selected.  Go ahead and right click the cube to select it.  Now press A.  The selection is cleared.  Very useful.  You will use this thousands of times.

B - Box Select B is used to make a selection of an area using a box.  Press B and you will get some dashed crosshairs on the screen.  Now single left click where you want to start the box and drag the box across the screen to capture the items that you want to select.  Single left click again and it will select every item that fell inside the box.  Press A to clear the selection.
  Box Deselect: Press B, then SHIFT It took me a long time to discover this handy tool.  If there are areas you want to deselect while you have a bunch of things already selected, you can deselect them by pressing B, as above, then as you are dragging your selection box, hold down the SHIFT key.  Make your selection and then instead of adding those items, it will remove them from your currently selected group.  Very handy in those right areas where you have a lot of vertices.

Note that your X-axis is red and your y-axis is green.  Sometimes you can get turned around on your scene and not know which way you are looking.  Use these colours on the grid to help you.  There is also a small 3-way axis down at the bottom left of your scene which includes the Z-axis in blue.  Handy.

PART 2: Changing Your View Direction

Your number pad controls which direction we view our scene from.  At the top left of the scene it will show you what the view is.  "User" camera angle indicates that you've rotated the scene away from a default viewpoint.  Pressing one of the below commands will change it to:

  1: Changes your view to the front of the scene
  CTRL-1: Changes your view to the back of the scene
  2,4,6,8: Rotate your view.  Acts in the same manner as holding down your mouse  wheel except that it moves in set increments.
  3: Changes your view to the right side of the scene
  CTRL-3: Changes your view to the right side of the scene
  7: Changes your view to the top
  CTRL-7: Changes your view to the bottom

The other part is changing between a perspective and orthographic view.  We usually want to work in orthographic, since this is how Simutrans graphics are drawn.

  5: Changes between perspective and orthographic view.

Press 5 on your numpad and set it to orthographic view at this point.  The top left of your working area will now say "Ortho" as well as the current view direction, Top, Front, User, etc.

The last view option is:

  0: Camera view

This allows you to see what the camera sees.

PART 3: Setting Up Our Basic Starting Scene

F12 is used to render your scene.  Press F12 now and you will see your wonderful cube shaded at the top and side.  The front is dark as there is no light currently hitting it.

Press ESC to close the render view and return to your scene.

The sunlight in Simutrans for most paksets is from the south.  For many paksets, the sun is located at a 60 degrees angle in the sky (which incidentally is about the sun angle around 50 degrees latitude at midday in summer).  The camera is located to the south-east (225°) and looks down across the scene.

Now, let's change the lamp and camera so that we're properly set up for Simutrans.  Do note that some paksets have different lighting configurations.  We will set our scene up for pak128; this setting is used for most other paksets.

First, select the lamp with a right click.

Now, look over at the right side of your screen.  There is more information here than we could possibly digest in a lifetime.  Ignore most of it for now, it will start to make sense and become useful as you progress with blender.  What we are looking for right now is the selection to change the lamp settings.  There is a line of menu buttons that select all sorts of different functions.  Scene settings, etc.  Scan across for the one with the lamp symbol, a yellow sun image with four yellow arrows pointing out.

First, change your Lamp type from Point to Sun.  A Sun Lamp allows us to position a light source that emits light rays in a parallel fashion (just like the sun) and the light intensity does not diminish over distance.  If you moved our Sun lamp really far away from our object it would still enjoy the same amount of light cast on it.  Other light sources are different, like moving a light bulb further away, light diminishes over distance.

In the Energy slider, change this amount to 1.5.  You can either use the slider with your mouse or you can click this box and type in the value, 1.5.

You can change the colour of the sun with the colour box just above "Energy".  I just use a straight white sun colour but you can change it if you wish.

Now render your image with F12.  Notice that the light intensity has increased and that if you set the Sun to an off-white colour, this colour has been imparted to the surface of our cube.

Next, we need to move our sun to the proper Simutrans location.  Press ESC to close the render view and return to the 3D viewport.  Right click our Sun lamp to activate it as our active object.  Now press the N key (make sure your mouse is in the main 3D window area when you press N-it won't work if you're hovering over the menus instead).  This will open up a new menu with a whole host of objects that we can employ to manipulate our currently selected object.  Pressing N again will toggle this window open and closed.  Under Rotation (you may need to scroll the menu up a bit, it's near the top of the new box you opened with N), set the values to:

X: 30°, Y: 0°, Z: 0°

Now press F12 to render.  The shading changed... but how?  Our sun lamp is on the other side.  It is because it doesn't actually matter where our Sun lamp is.  We can put it anywhere on the screen.  What matters is the angle the light shines at, not its location.

Now that we've set up our lighting for a proper Simutrans sun, we still have a problem: one side of our cube is still dark.

In the real world, objects are not just illuminated by direct sunlight.  They receive reflected sunlight off of objects in the environment.

We can simulate this in blender by using Environment Lighting.

Click on the World options.  You'll find it two selections over from where we selected our Lamp options.

Select the box beside Environment Lighting.  Change the Energy to 0.5.

Now render your cube again using F12.  Aha!  There is now light on the other side.  And you'll also notice the front and top of your cube are brighter too.  The light from the sun and environment add together.

You can play with the amount of light from both your sun and the environment to get the effect you want.  I generally use 1.5 for the Sun and 0.5 for the environment and it gives a nice amount of shading to the non-sun sides and good shadows.  It matches the pak128 light style fairly well.

Good, now we've made our light correct for Simutrans.  Next we need to fix our camera.

Right click your camera to select it.  Where the menu option was for Lamp settings when you had your lamp selected you will now see Camera settings instead.

Change your Camera from Perspective to Orthographic.  Below you will see a slider for "Orthographic Scale".  This scales the size of the camera.  Change this to 28.65.

Next use your Transform functions, by pressing N (again, make sure the mouse is hovering over the main 3D window or N won't open/close the menu), to change the Camera location.  This is the same as you did when you changed the rotation of your Sun lamp.

To set our orthographic camera to the proper location, under Location change to:

X: 20, Y: -20, Z: 24.65

This places our Camera at the proper location.  The odd Z location will become apparent shortly.

Next, we need to rotate the Camera.  Under Rotation, change to:

X: 60°, Y: 0°, Z: 45°

This rotates the Camera so that it is looking in the right area.

Select the Render options.  It is the camera symbol in the same menu where we set our Camera and Lamp settings.

Under Resolution, change X to 128, Y to 128 and change the percentage to 100%.  If you're doing a render for a pak64 size, you'd obviously set 64 for X and 64 for Y.

Under Anti-Aliasing, change the anti-aliasing method from Mitchell-Netravali to Catmull-Rom.  I find this anti-aliasing method makes a crisper looking image that matches better with existing hand-drawn graphics in most paksets.  You can experiment with the different methods.  Use Catmull-Rom for now, I have optimized camera location for this method.

Under the Shading section, change Alpha from Sky to Transparent.

Now F12 render your image again.  You will now have a checkboard alpha channel background behind your cube.

At the bottom of your screen is an option to turn off the alpha channel and see your render with a black background instead.  Any pixel with alpha in it will be shown at 100% in this mode.

This is sometimes useful to see a crisper delineation of your edges while doing test renders.

New let's make a nice base plate to build on top of.

It is useful to use the scale in blender as a basis for designing our objects for Simutrans.  Depending on the scale of your pakset, you can configure your blender camera to nicely frame your scale area.

Let's start by removing our cube.

Right click your cube and then press X.  This will ask you if you want to Delete your object.  Confirm.

Now press SHIFT-A.  This brings up the "Add Object" menu.  Under Mesh, select Plane.  A plane is a 4 sided object with no depth (no Z axis).

Let's place this plane in the right spot and make it the correct size.  Using the Transform options, on the menu we can open using N (make sure your mouse is over the active 3D viewport to open this and also ensure that your plane that you just created is selected).  Set X, Y and Z Location to 0.  The puts our plane in the centre of the grid.  In the Dimensions section, change X and Y to 20 instead of 2.  This creates a plane that is 20x20, which is the scale for pak128 (20 metresx20 metres).  Other paksets have a different base scale (pak128.Britain is 25x25).

That said, you can certainly create a 25mx25m object using this default 20x20 setup.  Just remember that if you are using coordinate measurements in blender, everything will be skewed slightly by the scale (ie: 1m at 20x20 is 1.25m at 25x25).  I find it nice to keep it at scale since many things that I build I can refer back to their real life sizes while building it (a standard residential door is 2m high, for example).  You can certainly design and draw everything by using your visual judgement (does that look properly scaled?) but I find it easier to just do it to actual measured sizes.

Now render with F12.  Look at that!  Your plane is perfectly lined up, ready for use in Simutrans graphics.  If we were looking for a bright white square tile, you'd already be done!  The astute amongst you may notice that there is an extra pixel on the top two segments.  These are easily removed in a post-rendering step.  It's the closest I've been able to get to having a "clean" render ready for Simutrans.  Depending on the complexity of what you are building you may not even need to strip those pixels as a building will take up most or all of the vertical space on your object.

Now that we've done all this work to set up a starting scene, let's save this so that we can use this as a template for future projects.  Click on File at the top left, then Save.  Give it a nice name, like "Blank 1x1 pak128 Tile.blend" or something fancy and easily recognizable when you want to load it for your next project.  I would also suggest saving a second version, just in case you accidentally save over your template in the future.  Though, after using blender for a while, you will be able to quickly follow these steps to make a new template in a couple of quick minutes.

PART 4: Making Something - Materials and Textures

Alright, let's get in to the meat and potatoes of this tutorial.  Let's make something!

Using our created template, let's File-->Save As and give this a new project name, like "My First Render.blend".

We already have a pak128 base plate in our scene, so let's give this a texture instead of being bright white.

Right click the plane to select it.

First we need to create something called a Material.  This gives the object certain properties that will also affect the texture that we put on the object.  Think of it like putting a primer coat on the object.  It gets it ready for painting the texture.

You will spend a lot of time using these two functions while texturing.  It's a bit daunting at first and I spent a lot of time learning how to use these.  Hopefully this tutorial will save you countless hours of frustration.  Learning to do textures efficiently will make your life much easier.

Click on the Material button.  Now click on the New button below.  This will create a new Material for you to use.  To gives it a default name of "Material.001".  Let's rename this to "Grass".  It is useful to name your materials and textures as you can later import them to new projects.  It is also handy when you have 15 or 20 of them and you want to quickly add one to a new object and can select by name.

There are plenty of options here.  Most of which you won't use any time soon, if ever.

Under Specular, change Intensity to 0.  Specularity is how reflective/shiny your material is.  Not like a mirror reflective (there are other settings for this) but it will create a lighter spot where the light would bounce off your object.  Grass isn't really shiny so we'll set it to 0.

The rest of these settings are for future experimentation.  Diffuse can set the intensity of the colour for the object.  Under Shading -> Translucency you can make your object semi or fully transparent to light.  Transparency is to make the actual object partially or fully transparent in appearance.  Mirror can create, you guessed it, mirror effects.  Most of these are of limited use at such a small scale as we are creating.

Now click on the Texture option tab at the top (see my previous picture, above).  This is where we can apply the actual texture to our object.  Again, click New.  This will create a texture called "Texture".  Rename this to "Grass".

The default setup for your texture is an awful cloudy pink/white concoction.  It's awful.  Go ahead and render it to see just how awful it is.  I warned you.

Under Type, change it to Image or Movie.  This allows us to use an actual image instead of an auto-generated texture.

We will use this image as our lawn texture.  Save As... this image and put it someplace where you can find it in a moment.

Back to blender, the Texture area.  In the section named "Image", select "Open".  Now navigate to the folder where the image is saved and select it.  Use the folder selections on the left side to navigate to the correct folder.

You will now see your lawn texture in the texture display box.  Do a test render, F12, and see how it looks.  It looks like a field of mint rather than a lawn.

Let's tweak the colours of our texture a bit.

In the Colors section, make the following changes:

In RGB Multiple, change G: to 0.9, B: to 0.9, in Adjust, change Brightness to 0.9, Contrast to 0.9 and Saturation to 0.9.  Feel free to play with these settings to see how it alters the appearance of your lawn.

Now run the render again, F12.  That's a bit better.

Want snow?  Change Brightness to 1.4 and Saturation to 0.  Render again.  Instant snow!  More on this in a later chapter.

Change Brightness back to 0.9 and Saturation to 0.9.  Let's carry on.

Now to build a small, simple house.

PART 5: Making Something - Our First House

In the 3D world view (press ESC from the render view if you are still there), press A once or twice to unselect any currently selected objects.  Everything should have a black outline, not yellow/orange.

Let's remove the shading effect on our object and move to something called Wireframe Mode.  Press "Z" and the shading on our plane will disappear.  We are now in Wireframe Mode.

SHIFT-A for Add, select Mesh --> Cube.  This places a cube at coordinates 0,0,0.

Notice that in our Transform menu (open it with N if it isn't open) that the coordinates are set at 0,0,0 for X,Y,Z.  If Location is not these values, change them now.  These are the coordinates of the CENTRE of our object.  If you move around you will see that the cube extends equally above and below our grass plane.

Let us now change the size of our cube to make our house.

Under Dimensions, change X: to 6, Y: to 10, Z: to 3.  This will make a box 6 units wide, 10 units long and 3 units high.  Since we designed our grass plane to be 20x20 metres, we can call this box 6m by 10m by 3m high.

Now we just need to lift it up so that it is sitting on the surface of the grass, not halfway underground.

Change Location: Z: to 1.5.  1.5 is half of 3.0 and this will nicely place our box on the surface of our grass plane.


Now we are going to use something called Edit Mode.  All this time we have been in Object Mode.  Press the TAB key and it will change to Edit Mode.  In this mode we are able to manipulate the object on a finer level.

Objects have three features: Edges, which are all of the lines defining the edges of our object (our cube has 12 edges), Faces, which are all of the faces defined by our edges (our cube has 6 faces) and Vertices, which are all of the connection points for all of our edges (we have 8 vertices on our cube).

You can see the selection buttons to change between vertices, edges and faces modes.  Go ahead and flip between them to get an understanding of how they each look.

Just like with objects, you can right click each of the vertices, edges or faces that you want to select.  You can also use SHIFT-right click to select more than one.  Further, the "B"-key, which we learned earlier, can be used to box-select several at once.  "A" will select all and deselect all.

Notice that we cannot select the components of any other object except our cube.  When we enter Edit Mode, we are only editing the currently selected object from Object Mode.  This is useful when we have an area with many objects close together.

Now, let's create the roof of our house and learn a few powerful commands.

First, change to Vertices Mode.  This will put a small clickable box at each of the 8 vertices on our cube (we will call this object our "house" now).

On your numpad, press "1" to move to the Front View.  Now we are looking straight-on at our house.  If there are any vertices selected (they will be yellow) press "A" to deselect everything.

Using the box-select function, by pressing "B", select the top vertices of our house.  It will appear as if you have selected two vertices but you have actually selected all four of them.  How do we know this?  Look:

It tells us what we have selected at the top.  We have selected all 4 top vertices of our house even though we only see two selected.  Why?  Because the back two are directly in line with the front two in this view and we cannot see them.

With these 4 vertices selected, let's use a new, very powerful function called Extrude.  Press the "E" key.  Now move the mouse around and you will see that you have created a new set of 4 vertices and that you can move these up and down.  Also notice that your movement is constrained to the Z-axis: you can only move your new vertices up and down.  What Extrude is doing is extending a new set of vertices along the same direction that the previous set was pointing in.

While still moving your new vertices up and down, press the "Z" key.  This unlocks the Z-axis constraint and allows you to move your new set of vertices in any direction you desire.  Now press the "X" key.  This constrains our movement to just the X-axis.  Press the "Y" key and you will be constrained to just the Y-axis.  You won't see any Y-axis movement because we are looking from the front of the image, right along the Y-axis.  Any movement on the Y-axis would be directly toward or away from us and we can't see it from this viewing angle.

Press the "Z" key again to constrain to the Z-axis and move our new set of vertices up above the other ones just a tiny, tiny bit.  Use your mouse wheel to zoom in a bit and get it nice and close.  Press ENTER or click your left mouse button to confirm when you're done.

That should do it.  It doesn't have to look exactly like this.

If you make a mistake, just press CTRL-Z to undo and do it over again.

With our 4 new vertices still selected (re-select them if you cleared it already by using the Box Select tool, "B") press the "7" key on your numpad to change to Top View.  Now we are looking directly down on our object.

Let's learn our second powerful tool, Scale.  Press the "S" key.  Now move your mouse and see that you are able to rescale your 4 new vertices that you created earlier.  Now press the "X" key to constrain to the X-axis.  This works just like it did for Extrude, we can now scale just in the X-axis direction.  Pressing "Y" will constrain to the Y-axis and yes, "Z" will constrain to the Z-axis, though we cannot see it because it is moving up and down toward our current view direction from the top.

With our 4 vertices still selected, let's build the bottom of our roofline.  Press "X" to constrain to the X-axis.  You will know you have the X-axis locked because it will only move left and right and also the X-axis on the grid, which is red, will be highlighted.  We can either move this to the right location by sight or we can actually move it a specific amount.  Type "1.1" on your keyboard.  This will scale our 4 vertices to be 10% larger on the X-axis.  In summary, the key-strokes to achieve this is "S (scale), X (x-axis constraint, 1.1 (amount)".  "SX1.1".  Press ENTER or left click to confirm.  Moving it a set amount is handy for this next step:

We've now extended the sides of our roof out, but we still haven't extended the other sides of our roof.  We just type "SY1.1" right?  Well, almost.  Try it.  It works but it doesn't scale the sides to the same length as the x-axis.  Undo with CTRL-Z.  Why didn't it scale the same as the X-axis scale did?  It's because our house isn't the same width and length.  When we scale in the Y direction by 1.1, we're scaling it to be +10% over the Y-length of our object.  Since our Y-length is different than our X-length, we need to scale by a different factor.
Our house is 10 in the Y-axis and 6 in the X-axis.  Thus, we need to move the Y-axis only 60% (6/10) of what we moved the X-axis.  So, type "SY1.06" and move it by 6%.  Left click or ENTER to confirm.
That looks much better!

Press "A" and unselect your vertices.  Move around and take a look at your new accomplishment using Extrude and Scale.

Now press "1" on your numpad to move to Front View.

Well on our way to making the roof!  But notice that funny angle?  Aren't rooflines straight across on the bottom lip?

We can either ignore this, because the isographic camera angle will never see under that part of the roof when rendering, or we can fix it because it bothers us and we're perfectionists.  I'm a perfectionist, so let's fix it and learn a new command in the process!

With Front View selected ("1" on numpad) select the top 4 vertices of the roofline using the Box Select ("B") tool.  Check the top of the screen make sure you have 4 vertices selected.

Now use the Grab tool by pressing "G".  This allows us to move our selected vertices around the screen.  Guess what happens when you press "X", "Y" or "Z"?  Good guess.

Press "Z" to constrain to the Z-axis and let's lower our roofline in line with the top of our house.

It doesn't have to be perfectly in line.  In fact you can skip this step and it doesn't matter.  It won't affect the final render at all.  But it was a good chance to learn the Grab tool.

Now, let's form our roof.  With those same 4 vertices still selected (re-select them if you cleared it using the Box Select ("B") tool).

Press "E" for Extrude.  It will default to the Z-axis constrainst, no need to press Z.  Now type "0.2" to extrude it 0.2 units up.  Left click or hit ENTER to confirm.

Do it again.  "E" to Extrude.  Again it defaults to Z-axis constraint.  Now type "2" to extrude it 2 units up.  Left click or ENTER to confirm.

You should see this:

Move around and view the beginnings of your roof.

There is just one step left.

Move to a good viewing angle so that you can see all 4 vertices making the top part of our square roof.  Select two vertices by right clicking one, then SHIFT-right clicking the next on one side of the roof, like this:

We will now use a function called Merge.  This will allow us to merge our two selected vertices in to one single vertex.  Press ALT-M to activate Merge and then select "At Center" as our method.  One instant roof line!

Now select the other two vertices on the other side and repeat the same procedure: ALT-M to Merge, "At Center".

What Merge does is take two or more selected vertices and combine them together.  If you select At Center, it will merge the vertices at the average of the X, Y and Z values for all vertices.  Since our roof points were on the same Y-axis and Z-axis, it only averaged out the X-axis amounts which conveniently happened to be the exact middle point of our house.  The Collapse selection will accomplish the same task in this instance.  There are other Merge options, First, which merges all vertices at the location of your first selected vertex and Last which merges at the last selected vertex.  At Cursor will merge them at the cursor location.

Now we have our roofline made.  Let's make a door.

If we were making a very detailed model, we would have to make our house walls the right thickness and cut the doors and windows out of it.  Fortunately, we aren't.  We're looking at this house from 500 feet in the sky.

We can cheat a bit and just put the door on the front of the house.

Press SHIFT-A for "Add" and select Cube.  Notice that we had a lot less options this time.  This is because we're still in Edit Mode and are adding a component to our selected object.

With our Transform menu (shortcut "N" if you closed it), you will see that Location is gone and instead we have Median.  This the location in relation to our current object - the house.

Change X: to 0.5, Y: to -1.0 and Z: to -0.33

This moves it to the front of house.  Now let's shape it to make a door.

With our new cube selected (all 8 vertices) press:

"SX0.5" to scale 50% in the X direction.  "SY0.1" to scale 10% in the Y direction. 

That's good enough for now.

Let's move on to the next stage.  Texturing.

PART 6: The Art of Texturing

Texturing is probably the most important part of making an object.  You can learn how to construct complex buildings fairly quickly using the tools we learned above, but turning them from a big white box to something beautiful takes some time and practice.

First, let's download a texture that will help us out.  Right click this image below and Save As on your system.  Remember where you save this, you will need it later:

Make sure you are still in Edit Mode.  Now let's move to Face Select mode:

Now let's add the bricks texture to our walls.

Click on the Materials menu option on the right side.  It was here:

Click on New and then rename it to "Brick Wall".  Set the Specular Intensity to 0.  All other settings can stay as default here.

Click "Assign" which is located right below your list of materials.  This will assign the "Roof" material to your selected roof panels.

Now click on the Textures menu option.  It's beside the Materials button that you just clicked.

Click on New and then rename it to "Brick Wall".  In Type, change it to "Image or Movie".

Under Image, select Open, and find your bricks picture that you downloaded above.

Now press F12 to render your house.

Yike!  This doesn't quite look right.  Well, at least it has a brick colouration...

We need to fix this brick problem.

Press ESC and go back to 3D view.

Select just the two roof panels now.  Clear your selection with A if you have any current faces selected.  SHIFT-right click one roof panel and then the other.  You should see this:

Now click on Materials again and let's make a second material.  You'll see your Brick Wall there already in the menu.  Now click the plus + sign to the right and you can add another material by clicking "New".  Rename this to "Roof".  Turn Specular Intensity to 0.

Now click on Textures and click New.  Change Type to Image or Movie, then in Image click Open.  Open the same brick texture you used a moment ago.  In Colors, change R: to 0.5, Brightness to 0.7, Contrast to 1.2 and Saturation to 0.0.

Press F12 to render again.  Small improvement!  Now we need to fix those pesky bricks on the house.  (notice how we used the same brick texture for both the roof and walls?)

We are going to learn one of the most important and powerful functions in blender for texturing.  UV mapping.  This took me weeks to learn.  I'm still not very good at it.  Hopefully you will learn the basics in an hour.

Blender can have several viewports open at the same time.  It's a bit tricky to learn how to do this at first, but you'll get the hang of it.  Right now we need to open up a second viewport so that we can do our UV mapping to properly line up our brick texture.

Now for... the Magic Button.

Left click and drag on this little feature here and you will be able to open up a second, identical window.  Move it about halfway across the screen.

Now click down at the bottom of your new viewport on this button to change the editor type.  Change it to UV/Image Editor.

You will see your rendered house in all its glory.  But this isn't what we want.  We want the UV editor.  Click on the X here to close our render view:

Now we have a boring grid with nothing on it.  Move your move over to the 3D viewport (where your wireframe house is) and deselect everything with "A".

Click on Materials again on your right side menu.  Select the Brick Wall material that you made earlier.  Now click on Select right below it.  Aha!  It selected all of the faces that currently have the Brick Wall material type applied to them.  Your two roof panels were not selected because they have the Roof material applied.

With your mouse over the 3D View section (the one on the left) now click "U".  This will open the UV Unwrap menu.  There are several methods to automate the texturing process.  Sometimes they work well, sometimes they don't.

Select Smart UV Project and click OK.

Notice a bunch of shapes on the other viewport, the UV/Image Editor one?  Let's do something to make it make a bit more sense.

Recall that button we had to remember from the picture above?  Now let's click it.  Select your bricks texture.

Aha!  Now it has put the brick texture there and all our little boxes and triangles are on top.

What the UV editor is doing is putting each of the objects on the house that we used the Unwrap function on and placing them nicely over top of different sections of our brick texture.

Now we have to tell our texture to actually use the UV mapping that we just made.  Click on Textures at the right and scroll down to the Mapping section.  In the Coordinates menu change it to UV.  This tells blender that we want to use our UV map for this texture.

Click "A" on the 3D viewport to deselect everything.  Now select each face on the house individually and notice its placement on the brick texture in the UV editor window.  Each face has taken its own part of the brick texture as its own.  When we render the image, this is what each face on the house will get for its texture.

Render your house using F12.  It looks a bit better now though it still isn't perfect.  Notice also that your render appeared in your 3D View window, not the UV editor window.  Press ESC (when your mouse is over this window) to go back to the 3D View.

Now select just one face on the house, one of the sides perhaps.  See its outline on the UV mapping as a square over the brick texture.  But our wall isn't square!  It's rectangular.

Here's where it can get interesting.  There are many ways to work on your UV map to get it more exact.  Do remember that we're building a small scale model so the texture doesn't have to be perfect.  Also know that with the small scale we use often your textures need to be a bit larger than what would look proper at a large scale.  Bricks at scale just show up as a big red blob at our distance.  Often you want your textures to be much larger than they'd normally be so that we can see the variation in the texture.

Since we have a small model, we can actually use the Rendered viewport option to fix our textures in real-time.  With a larger model this might be difficult (depending on how fast your computer is).  Click here:

Oooo!  There's our house.  And yike, our ugly textures.  It looked nicer at 128x128 didn't it?

Press "A" until you don't see any selections over your UV map.  Now select one of the long sides of the house.  See its map on the UV mapping editor?  Now let's change it.

You can edit the vertices on the UV map just like you did in the 3D world.  In fact, many of the same tools work here.  Press "B" and Box Select all 4 vertices for your wall section.  Now press "S" to Scale your object and press either X or Y to constrain it to a single axis.  Watch the effect that your actions have on the rendered image to the right.  Play around with it until you get something that looks nicer.  Remember, you don't want the bricks to be too small or you won't be able to see them in the small render we're making.

Now select the front of the house.  Notice the brick texture is the wrong way?  These bricks are going up/down and should be side to side.  We need to rotate this.

Select the 4 vertices in the UV editor (either individually with SHIFT-right click, with A for All or with the Box Select (B) tool).

Now press "R" and type "90".  This rotates our UV texture box 90 degrees.  Much better!  Now scale it using S, X and Y to make it look how you want it.

Let's move on to the triangle at the front of the roof.  This is really wonky!  Notice how it's rotated at a weird angle on the texture in the UV mapper.

Press "R" for Rotate.  Instead of pressing "90" like before just rotate it with your mouse until the triangle is positioned correctly.  Watch the effect on the texture in the rendered viewport.  Much better!  Now scale it with S and X/Y until it looks nice.

Rotate is an important new tool to remember.  This also works in the 3D Viewport and is very handy.  Just like Scale, Grab and Extrude, you can constrain your Rotate function to the X, Y or Z axes.  When you type in a number it will rotate that many degrees.

Repeat for the other sides until you get nice looking brick walls on your house.

The edge of the roof doesn't look right with red bricks.  I selected them and changed them to use the Roof material.  Go ahead and right click one of the roof edges and change it to the Roof material type in the Material editor.  Click Roof and then Assign.  With the Rendered viewport it may be hard to see if you have the roof edge or not.  Switch back to Wireframe mode (press "Z"), it's easier to know what you've selected.

Now you have something similar to this:

Let's finish up the door now.  Switch back to Wireframe (press "Z") mode if you haven't already.

Select the outside door face.  We don't care about the inside one (we could actually just delete it if we wanted).

In Materials, add a new Material with the "+" button.  Click on New and then change the name to "Door".  Change Specular Intensity to 0.  Click on "Assign" to assign this material to your selected door face.

Under Diffuse, let's change the color of our door.  Right above the Intensity slider you'll see a white box.  Click on this and it will open the color editor.  Change the color here to something that you think you'd like your door to look like.  A nice brown for wood, or grey, or bright red.  You're the artist, you choose!

Now F12 and render your image.  Much nicer now isn't it?

Notice that we didn't have to do anything for the roof texture.  Because it was just two big rectangular boxes, the default "Generated" texture mapping style did a fine job for us.  If you were so inclined, you can change this to a UV map as well, follow the above instructions.

Now we've learned the basics of UV mapping!

You have learned enough about blender now to be dangerous make some basic models.  Your skill and speed will increase exponentially with practice.

PART 7: Creating Multiple Cameras

We have 4 different rotations for our Simutrans buildings.  Right now we just have a camera and sun lamp that works for the South-East viewpoint.

Setting up the 3 other cameras and lights is easy:

In Object Mode (press TAB if you are in Edit mode) and select your camera.

Use the Duplicate function, pressing SHIFT-D.  This creates a duplicate of the object you have selected.  You can move it around with the mouse and left click to set it down.  Like with Grab, you can constrain to the X, Y and Z axis.  This tool is very handy for other objects as well.

Change the coordinates of your new camera in the Transform (menu opens with "N" if it's closed) menu under Location.  Set X to -20, Y to -20 and Z to 24.65.  Change Rotation for Z to -45°.  Done!

To make this your active camera, click on the Scene menu option.  Under Scene-Camera, change the camera to Camera.001.  Now you're viewing from your new camera.  Press F12 to see the effect.  We'll change the lighting later.

Now SHIFT-D and Duplicate your camera again.  Set this new camera to Location X: -20, Y:20, Z: 24.65.  Set Rotation to Z: 225°.  Now it's looking from the north west.

SHIFT-D and Duplicate one more time.  Set this one to Location X: 20, Y: 20, Z: 24.65.  Rotation Z: 135°.  This is our north east camera.

Having all 4 cameras in our view might be a little distracting while we're working with our objects.  You can hide these.  Select each camera and press "H" to Hide.  Or you can select all 4 together using Box Select or SHIFT-right click each one and press "H" to Hide.

Your 4 cameras are still there, you just can't see them anymore.  You can still select them with the Scene section at the right.

Now let's change the light.  Right click the lamp.

For each camera type, you want to set your light (your sun lamp) accordingly:

"Camera" (default, SE view): Rotation X: 30°, Y: 0°
"Camera.001" (SW view): Rotation X: 0°, Y: -30°
"Camera.002" (NW view): Rotation X: -30°, Y: 0°
"Camera.003" (NE view): Rotation X: 0°, Y: 30°

I'm sure there is a faster way to do this but it's not a big deal to change the lamp for each rotation when you're finished your object and are ready to export it.

When you want to produce your 4 rotations, it's easy.  Go to Scene, select the camera you want, change the sun lamp to the settings above and it's ready to export.  Which is the next section.

PART 8: Exporting Our Render

There are lots of different ways to export your images out of blender.  I've tried a few different methods with varying success.  I'm sure you will find your own personal method that works best for you.

Here is what I do:

When you've rendered your image and you're happy with how it looks (at least, thusfar), while in the render view, press F3.  This brings up the image export save window.  You can type in a file name to save your render as and it will save it there.  Now you can load your render with your favorite paint editor (GIMP, etc) and finish your work.  Remember: The better your render quality and style the easier the end work is.  You want as little post processing as possible; you may have to go back and forth many times to get it to look exactly how you want it.  A long post processing phase will really drag you down.

If you want to export the alpha channel along with your image, you can do this.  In the Render settings in blender (the first option with the camera symbol) if you go to the Output section you will find an option to select RGB or RGBA.  Click on RGBA and it will then export the alpha channel along with the .PNG file that you export when you press F3.

Working on your image in post processing and getting it in to Simutrans are whole different tutorials in themselves.  Perhaps some other day...

PART 9: Tips For Making Snowy Renders

<tutorial writing in progress>
« Last Edit: October 14, 2013, 05:40:50 PM by Sarlock »
Current projects: Pak128 Trees, blender graphics

Offline Sarlock

Re: Using Blender to Create Simutrans Graphics
« Reply #1 on: October 12, 2013, 02:13:18 AM »
Please note that this tutorial is brand new and probably has a few errors.  If anyone is so inclined, please test it out following the instructions and let me know if you find any problems.

I will be working on some of the formatting over the next few days to make it look nicer.

Also, if someone could kindly make this stickied in this forum, I would appreciate it.  I will be adding more to this as time progresses.
Current projects: Pak128 Trees, blender graphics

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2506
  • Total likes: 261
  • Helpful: 88
  • D'oh
    • by An_dz
  • Languages: PT, EN, (it, de)
Re: Using Blender to Create Simutrans Graphics
« Reply #2 on: October 13, 2013, 07:06:08 PM »
This is an incredible work. Just made a quick read and I can see it's a pretty full tutorial, even explaining how to work with Blender and with 3D.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4510
  • Total likes: 153
  • Helpful: 106
  • Languages: EN, NO
Re: Using Blender to Create Simutrans Graphics
« Reply #3 on: October 13, 2013, 07:27:20 PM »
I don't have the impression there are many written Blender tutorials these days. Everybody is making video tutorials it seems. Although I don't need this particular tutorial, as I, based on just a quick glance, have passed this point twice (first with the old GUI years ago, then with the new), I just want to give my gratitude for making tutorials one can follow at one's own pace and without having to turn the sound on.

Offline Max-Max

Re: Using Blender to Create Simutrans Graphics
« Reply #4 on: October 13, 2013, 08:22:33 PM »
I use one camera and rotate it and the sun 90 degrees in 4 animation frames. I have two scenes, one with summer settings and one with winter settings.  Summer and winter is done with compositing and Ambient occlusion. The Simutrans "transparent" colour is automatically set as the background so they can be used directly as they are.

To render all 8 images (4x2) for each .blend file I use a command script:

Code: [Select]
FOR /R %%A IN (*.blend) DO (
  ECHO - %%~nA-s-##.png
  CALL Blender -b "%%A" -S Summer -o "//../%%~nA-s-##.png" -a > NUL
  ECHO - %%~nA-w-##.png
  CALL Blender -b "%%A" -S Winter -o "//../%%~nA-w-##.png" -a > NUL

The rendered images will end up in the parent folder of the found blender project file. So if the script is executed in the project root, it will recursively render all .blend files.
- My code doesn't have bugs. It develops random features...

Offline IgorEliezer

  • Devotee
  • Administrator
  • *
  • Posts: 3913
  • Total likes: 117
  • Helpful: 68
  • Minister of Silly Posts
    • Igor Eliezer Architect and Urban Planner/Arquiteto e Urbanista
  • Languages: PT, EN, AutoLISP, Python
Re: Using Blender to Create Simutrans Graphics
« Reply #5 on: October 13, 2013, 08:24:15 PM »
Just wanted to leave this here:

Offline Sarlock

Re: Using Blender to Create Simutrans Graphics
« Reply #6 on: October 14, 2013, 12:25:20 AM »
Thanks for the positive feedback, ideas (thanks for the script, Max!) and posting it on the blog.

I agree: while video tutorials are nice I find myself often frustrated by having to pause/play the video over and over to try and catch some small component of the tutorial that the author glanced over assuming you know what they just did.  Having it written out certainly has certain advantages, it's much easier for follow for sure.
Current projects: Pak128 Trees, blender graphics

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2506
  • Total likes: 261
  • Helpful: 88
  • D'oh
    • by An_dz
  • Languages: PT, EN, (it, de)
Re: Using Blender to Create Simutrans Graphics
« Reply #7 on: October 14, 2013, 12:33:36 PM »
And it's 1 billion times smaller, and you can save as a .mht or even as text file for offline read.

Offline mEGa

  • 2D painter
  • Devotee
  • *
  • Posts: 1041
  • Total likes: 1
  • Helpful: 35
  • Pak128 graphics
    • mEGa_Simutrans
  • Languages: FR, EN, ru
Re: Using Blender to Create Simutrans Graphics
« Reply #8 on: October 14, 2013, 12:46:14 PM »
@Sarlock: thank you very much for this excellent tutorial. A good beginning to become in 3D designing IMHO (2D painter speaking ;-) ) .
Current projects in progress : improvements of few designed french paks

Offline Zeno

  • ENASSA Designer
  • Devotee
  • *
  • Posts: 1996
  • Total likes: 1
  • Helpful: 30
    • Zeno's Simutrans Creations
  • Languages: ES, EN, CAT
Re: Using Blender to Create Simutrans Graphics
« Reply #9 on: October 14, 2013, 02:16:47 PM »
Hey Sarlock, a very complete tutorial with all key stuff very well explained. I'm looking forward reading chapter 9, it's always a hard part for me the snowy thing... :)

Btw, you might want to take a look at a couple of short tutorials on modelling techniques that I wrote long ago; feel free to reuse any stuff that can be helpful, if any.

Edit: Also, you can find scripts for taking different views in the forum, in the tools section IIRC. They mostly place light and camera in the right place, then takes a shot and saves it with a suffix indicating the direction. The pak128.britain guys did upgrade my script so their version is probably much more usable than mine.

Offline Sarlock

Re: Using Blender to Create Simutrans Graphics
« Reply #10 on: October 14, 2013, 05:36:32 PM »
Thanks, Zeno.  Your tutorials helped me with a few things when I was first learning blender -- I'll add a link to your tutorials.

I haven't done any scripting in blender yet, the whole idea has scared me up until now  ;D  But I think I'm ready...
Current projects: Pak128 Trees, blender graphics

Offline Zeno

  • ENASSA Designer
  • Devotee
  • *
  • Posts: 1996
  • Total likes: 1
  • Helpful: 30
    • Zeno's Simutrans Creations
  • Languages: ES, EN, CAT
Re: Using Blender to Create Simutrans Graphics
« Reply #11 on: October 14, 2013, 08:06:44 PM »
Thanks, Zeno.  Your tutorials helped me with a few things when I was first learning blender -- I'll add a link to your tutorials.
No need for linking, I just thought it might be useful.
About scripting... well, a little python doesn't hurt ;D But browse those scripts, I'm sure they can help to make your own version if that's your goal.

Offline Miziiik

Re: Using Blender to Create Simutrans Graphics
« Reply #12 on: December 08, 2013, 01:42:19 PM »
Sarlock: What is the status of making snowy renders? :) Můj web o hře Simutrans - Moje addons, návody, odkazy, apod.

Offline MilwaukeeXpress

Re: Using Blender to Create Simutrans Graphics
« Reply #13 on: January 08, 2014, 07:47:31 PM »
In my opinion, Simutrans should be fully 3D  ;)

Offline dc_ae

Re: Using Blender to Create Simutrans Graphics
« Reply #14 on: April 09, 2014, 02:29:00 AM »
Great tutorial, made the decision to finally make some graphics a lot easier. Although you covered a lot in the tutorial I noticed you might want to add to small details in the "navigating the scene" section, since it took me a while to find out how it works.
To move the camera (not the camera in the scene) but your point of view, click SHIFT-Mousewheel, and to zoom in CTRL-Mousewheel.
(if you already have in the tutorial and I missed it, ignore it)