Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon

13. January 2016

 

Welcome to the final part of our three part series on level creation using Blender.  In the first part of the tutorial we created a skybox for our world.  In the second we used a height map to create some terrain.  Today we are going to look at applying multiple textures to that terrain.

 

We are going to pick up where we left off, we have a large plane distorted to create our landscape.  If you haven’t already, apply the Displace modifier to make it permanent.  You should have already UV Unwrapped the plane object before we applied the displace modifier, giving us a nice even UV grid to work with.

 

Next we are going to need some textures to paint with.  Seamless textures work best as they can be tiled without creating a noticeable seam.  For this example however, I just downloaded a couple textures from TextureLib, a grass, rock and water texture.  Use whatever textures you wish to use.  Now that you have your textures, we need to import them into Blender.  I find the easiest way is to just add them as textures to the plane object and name them appropriately, like so:

image

No need to setup mapping coordinates or anything else, as we arent going to be using these textures directly, they just needed to be made available for Blender.

 

Now with your Plane selected, make sure there is a Material, and if there isn’t, create a new one.

image

 

Now switch over to the texture tab and add a new texture of type Image or Movie, then click the New button:

image

 

Call in GroundTexture or something similar:

image

 

You may find 1024x1024 is too low res for a large terrain, so you might want to try 2048x2048.  Now it’s time to start painting our texture.  Configure your Blender windows so you have a 3D view on one side and the UV/Image Editor on the other, and switch the 3D view to Texture Paint mode, like so:

image

 

Now in the UV editor, make sure that your GroundTexture is active:

image

 

In the 3D view, in the Tools (T) sidebar, we now set the texture we want to paint with.  Locate the texture area, click the thumbnail icon and select one of your textures, like so:

GIF

 

Now we can paint directly on the 3D model.  You have a ton of control over your brush, but the two most important settings are these:

image

 

These set the size of your brush and the strength of your paint tool.  Now simply paint the terrain as you desire:

GIF2

 

You will notice that the texture updated automatically the the UV/Image Editor:

image

 

If you prefer, you can edit in the UV editor window instead, simply turn Edit mode on:

image

 

The brush settings from the 3D View Tools window will be applied to the UV editor in Paint mode.  Now simply change textures and repeat the process until your texture is complete.  When you are done, you may want to export your texture for use in an external engine.  In the UV/Image Editor, select Image->Save As Image:

image

 

End result:

image

 

Not the greatest looking level, but that’s due to lack of effort, not the tool.  Not bad for 20 minutes work.  Obviously there are other tasks you’d want to perform.  You probably want a normal or displacement map on the terrain to give it small surface level imperfections, and obviously you’d want to add static meshes for trees, shrubs etc... but that is simply a matter of doing more of the same.

 

The Video

Art, Design , ,

12. January 2016

 

Corona Labs, the makers of the popular Lua based mobile game engine, just release version 1.6 of Corona Editor.  Corona Editor is a light weight IDE built as a plugin for Sublime Text that enables debugging, code snippets, code completion and more.

Details of the 1.6 release from the blog announcement:

Corona Labs is happy to announce the availability of Corona Editor 1.6. This is an update for the add-on package for Sublime Text 2 and Sublime Text 3 that provides code completion, syntax highlighting, documentation, and debugging to Corona developers.

The release of 1.6 includes the following updates:

Debugger improvements
  • Fixed an issue with a hanging after pressing Shift+F10.
  • Fixed a bug with spaces in project pathnames.
  • Current status is now displayed in the “Console” pane.
  • The “Console” output is now cleaner.
  • Generally improved reliability.
Corona Editor Project improvements
  • On OS X, Corona EditorRun Project now uses the most recent daily build in the/Applications folder by default. It will fall back to the public build if there are no daily builds.
  • Removed project “build system.” The menu command Corona EditorRun Project or the Cmd+F10(Mac) Win+F10(Windows, maybe mapped to FN+F10) key sequence is much more reliable.
  • Added Clear Build Panel command to main menu and context menu.
Editing improvements
  • Fixed indentation of elseif blocks.
  • Latest code completions are up to date to daily build 2016.2803.

Learn more about Corona Editor.

GameDev News ,

12. January 2016

 

In Part One of our level creation in Blender tutorial series, we created a skybox to define the boundaries of our game level.  In this tutorial we are going to create the terrain for our level.  You will probably be surprised by just how much we can accomplish with almost zero effort.

 

Creating a Height Map

First we need a height map.  A height map is a remarkably simple concept that has been around for ages.  Essentially you are defining the height of a grid of terrain using a simple gray scale image.  You can create this image a couple of different ways.  First you can simply fire up any image editor, even MS Paint, and draw the texture.  The blacker the pixels, the lower the corresponding terrain, while a white pixel is as high as possible.  In addition to painting by hand there are several applications free and commercial that are capable of exporting a height map for you.  Examples include Terragen, Bryce and Geovox although there are many more.

 

For this example I’m simply going to use Paint.Net, but any image editing program would work fine.  Create a new image, while not a requirement, power of 2 ( 512x512, 1024x512, etc ) textures generally perform best.  Next set the base colour to 128/128/128 RBG, like so:

image 

Use the bucket fill tool to fill the entire image with this color.  This will be the neutral value, the resulting terrain will neither be elevated nor depressed.

 

You can then vary the grayscale by either raising/lowering all RGB values ( aka 43,43,43 or 250,250,250 ) or by sliding the V slider under HSV.  Remember, darker the colour, lower the terrain, lighter the colour, higher the terrain. 

 

In the end, I painted this rather simplistic height map.

heightmap

 

This will result in a high border around a pit of utter and complete dispair... muhahahaha.

 

Displacement in Blender

 

Now that we have a height map, it’s time to put it to use.  The good news is, this process is remarkably simple.  First we need something to apply the height map.  A height map needs an underlying mesh to apply to and if there aren’t sufficient vertices to be displaced by the height map, your results aren’t going to be very good.  This means we need a large flat surface with a decent amount of detail...  We need a plane.

I’m building on our scene from Part 1.  Set the 3d cursor to the origin, then create a new Plane via Add->Mesh->Plane.

image

 

Your scene should now look something like this:

image

 

Now we simply want to scale the Plane to the appropriate size, which is going to be entirely dependent on your skybox dimensions.  I personally scaled by a factor of 10.  After scaling it, we need to add details.  To do so, in edit mode, simply apply a subdivision (W->Subdivide)

image

 

Each time you perform this, you will double the mesh density.  I preformed it about a half a dozen times, resulting in a mesh with 32K triangles, which seems about appropriate.

image

While you are here you might as well UV unwrap your plane (U->U).  Also switch to Smooth shading:

image

Or your terrain is going to look VERY edgy and not at all organic.

 

Ok, now that we have our plane to deform, we need to load in our height map.  It doesn’t really matter where you add the texture, but I will go ahead and attach it to our plane.  Switch over to the textures tab, add a new image texture and load our heightmap.  It might make sense to rename it heightmap so it doesn’t get confusing, but you don’t have to:

image

 

Don’t bother setting UV coordinates, we aren’t going to be displaying this texture.

 

Now, in Object mode, with your Plane selected add a Displace modifier:

image

 

Now select your image in the texture field, change Texture Coordinates to UV, then select the UVMap.  If you don’t have the option, you didn’t UV Unwrap earlier!

image

 

Our height map will now be applied to our terrain:

image

 

Now we can use the Strength value of the Displace modifier to determine the strength of the height map on the displacement:

HeightMapInBlender

 

The Video

 

Back To Part One  ||  On To Part Three

Art, Design

12. January 2016

 

This tutorial covers the basics of creating game levels in Blender.  There are a set of companion videos on YouTube that cover the same topics.  We will be looking first at creating a skybox to define the boundaries and skyline of our game.  Next we create the terrain of the game using a displacement map and a height map texture.  Finally we show how to paint the terrain using multiple textures.  I assume you have prior experience using Blender.  If you do not, this text based or this video based Blender tutorial series will teach you everything you need to know to follow along here.

 

Creating a Skybox

A skybox is pretty much exactly what it sounds like, a box flipped inside out with a 360 degree sky texture applied to it.  That said, it is quite common to remove one side of the box (the floor) as it is generally never seen.   There are two approaches to the texture map used to texture the inside of the skybox.  First we can use a single texture in the shape of a lower case T.  Or we can use a separate texture for each face of the box.  The advantages of the first approach are a) it’s easier b) it uses less texture memory.  The advantage of the second approach is much higher quality textures.  We will take the first approach in this example, but if there is enough demand I can do a tutorial covering the second method.

 

So first we need a skybox texture or textures.  Generally theses are a sequence of seamless textures representing the front, back, left, right, top and optionally bottom textures in the scene.  For this example I am actually using a cool procedural galaxy skybox generator available here.  Play with the random seed until you get a value you like.  To have it generate a t-shaped texture, make sure that Unified Texture is selected:

image

 

The end result I am working with looks like this:

skybox

 

Ok, now that we have our skybox texture, let’s fire up Blender.  The default scene is surprisingly EXACTLY what we want.  All we need is a simple cube, like so:

image

 

With the cube selected, switch into Edit mode and in the tools (T) panel select Shading/UVs then Flip Direction.

image

This reverses the normals of each face in our cube, effectively turning it inside out.

 

Now we need to mark edges to unwrap the UVs.  Switch to Edge select mode and select the following edges:

image

 

Then, still under Shading/UVs, click the Mark Seam button.

image

 

Next select the entire object (A) then click Unwrap.  In the UV/Image Editor, it should look like:

image

 

Perfect, now we just need to import our texture.  In the Material tab of the Properties panel, we first want to enable Shadeless:

image

 

Shadeless prevents the lighting of the scene from interacting with the material, which for a skybox is exactly what we want, otherwise it would be far too dark and unevenly lit.

Now switch over to the textures tab, add an image texture, load our generated skybox texture, then make sure mapping is set to UV, like so:

image

 

In the UV Image editor, with all of the faces of our cube still selected, make our texture active, then using a combination of rotation and scaling, align the UVs to the texture map:

image

 

That’s it, your skybox is now complete.  Of course you probably want to scale it up to a huge size so it envelops your entire scene.

image

 

If you have any unsightly seams, your UV maps is probably off the texture ever so slightly.

 

The Video Version


 

On To Part Two – Terrain

Art, Design

11. January 2016

 

Out of the box Unreal Engine 4 has support for C++ and Blueprints.  This leaves a bit of a gap for people that want more of a scripting experience but don’t want to work in a visual language like Blueprints.  Of course we have full source code access and Unreal Engine has solid plugin support so it was only natural for a few third party languages to pop up.  What follows is the list of external programming language options for developing in Unreal Engine.

 

JavaScript

Probably the best supported language alternative, there are two major implementations of JavaScript for UE4:

 

Unreal.JS

Released by NCSoft, the folks behind the popular Guild Wars RPG series, this plugin adds JavaScript support via the V8 engine.  Impressive in it’s scope, it includes CommonJS module support, .d.ts files for Intellisense support, a Jade like templating engine, live reload as well as access to the entire Unreal SDK.

 

Flathead

Another implementation of JavaScript via the V8 engine.  Older, small in scope and less supported, so probably best to go with Unreal.JS.

 

C#/.NET

This one is a bit tricky.  There was an early leader in an implementation by Xamarin, until licensing differences killed that project.  The only other alternative is currently Windows only.

 

Mono for Unreal Engine

Sadly no longer under development because of licensing issues, this version is outdated, requiring Unreal Engine 4.4 and a Xamarin license to deploy.

 

Klawr

Currently the best bet for C# development using the Unreal Engine but sadly confined to Windows only.  In the authors own words “This project is still highly experimental, and not very useful (though it's getting there)”.  It’s open source and hosted on Github if you wanted to contribute.

 

Haxe

There is one project looking to add Haxe language support to Unreal Engine.  Fortunately it’s pretty far along.

 

Unreal.hx

Fully supporting subclassing UActor and Blueprints, the Haxe code compiles directly to C++ code leaving minimal overhead.  This implemetnation gives access to the entire Unreal Engine API.

 

Other

 

Rust

Slightly different than the other languages on the list, this project implements a simple plugin enables you to link a 3rd party Rust library to C++ in Unreal Engine.

 

SkookumScript

A custom scripting language for Unreal Engine (and other game engine) development, SkookumScript is in their own words “SkookumScript is a text-based programming language for creating performance-critical, real-time gameplay. It is now available as a free turn-key plugin for Unreal Engine 4 (UE4)”.  SkookumScript was used to create the game Sleeping Dogs.

 

 

No doubt there are languages I’ve missed, so if you know of one at is in at least a runnable state, please leave a comment below and I will add it.  I am somewhat shocked that I couldn’t find a Lua plugin at this point! 

Programming , ,

Month List

Popular Comments

Doom 3 source finally available
Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon


22. November 2011

 

 

Continuing the long standing ( and very cool ) tradition of releasing id source code a number of years after being released to market, the Doom3 engine/game source code has been made available on GitHub.

 

 

I have only had the chance to peruse it briefly, but I have to say what I saw was very clean, and shockingly enough C++!  After seeing prior id code, I simply figured it would be straight C for some reason.

 

 

Anyways, I highly recommend you check it out.  Clean, complete, professional quality source code isn’t made available every day, and Carmack really is one of our day’s brilliant minds.  I know I will be doing so in more detail shortly!

 

 

Now I cant wait for someone to port Doom 3 to my toaster…

Programming

blog comments powered by Disqus

Month List

Popular Comments