Saturday, 9 April 2011

SunBurn Snippets #4 – Blender to SunBurn basics – Multi-Material mapping

Due to popular request here’s yet another snippet for the Blender to SunBurn series.

Here I cover how to setup materials in Blender for use in the SunBurn Game Engine and it’s editor (this links up the training video for materials and assigning textures on the Synapse site)

The basic instructions are as follows:

  1. Get your model and Unwrap the UV's how you wish, both Main Text UV and the lightmap (using smart project and create lightmap with new channel respectively), remembering this has to be done in "Edit Mode" (if any of this is already done in your model, ignore that part)
  2. Go to the Materials panel and set up the materials you want to use (be careful what you call your materials as they need to be uniquely recognisable)
  3. Next, whilst still in Edit mode, un-select all parts of the model
  4. Change to your specific selection mode (Vertices, Edges or Faces) and select the items you want to assign to a NEW material (by default all entities of a model are mapped to the default model)
  5. Next Select your new material and click on Assign. (this will move the selected items from the default to your new material, they are automatically unassigned from the default)
  6. Repeat this for the rest of you materials
  7. Save file (Important or it doesn't export correctly!)
  8. Export using the exporter of your choice

If you are using multiple models in a scene you can either just have one material per model, or separate the visible portions of the model from the hidden and only texture the visible to save on rendering. (as shown in the video on the Synapse Gaming site)

Right I'm outta here, lots to see and people to do. Wait reverse that!!.

One last thing!!!

I’m now using the latest version of Blender (2.7RC2) now but when I tried opening the “User Settings” screen Blender would crash, lots of troubleshooting later no fix, even reverting to old versions of the 2.5 series did now help.

Eventually found a fix which you should know about and it seems it’s just one of those gotcha’s when using Blender.

Blender needs the AREO theme enabled in Windows 7

Don’t fully know why but using a basic theme (which I did for doing the webcasts) seems to disable some 3D stuff which blender then doesn’t re-enable it for use (or depends on something to be there). The Blender team are now aware and are looking in to it, which will either produce a fix or an update to the documentation.

Just thought I’d let you know Smile

Wednesday, 6 April 2011

SunBurn Snippets #3 - Troubleshooting overly bright models in the editor

Following on again after the last snippet on Light maps, here’s another common issue you can sometimes face, usually with simpler models but also with any model setup incorrectly for lighting.

Some models when imported into blender take on a glowing type effect where they are not casting shadows, all faces or most faces are just bright as if lit from all angles, this is actually not far from the truth.

What the engine needs is a lightmap (Second UV Channel) to be completely UNIQUELY mapped, meaning each and every face must have it’s own area on the lightmap texture channel.

For a cube this is the difference between:

image image
A single faces UV texture that would map to all faces
and This
A uniquely mapped UV texture with each face having it’s own area

If you have your UV channel setup like the view on the left, then when SunBurn calculates the lighting for each face of the model it will multiply this data solely on this one area for each face ad for each light.  OVERBURN Winking smile

So simply re-project your UV map in your tool of choice and off you go.

Right that’s the last of the snippets I have for now, if you are having any problems or issue you are facing, then drop in to the SunBurn forums, I'll be keeping an eye in there and do another snippet for troublesome issues with getting models working.

Alternatively, drop a comment here and i’ll see what I can do.

Now it’s time to add a little more Flux to my Generator, gotta get back.

SunBurn Snippets #2 - Troubleshooting Lightmaps

Troubleshooting the disabled LightMap option in the SunBurn Editor

So following on from my last post on how to use Blender to get models into the SunBurn Engine, here’s Snippet number 2.

This video basically walks through how to solve one of the issues I faced when starting out with the SunBurn Game Engine, Lightmaps.

As mentioned in the full video previously, in order to use a Model in the SunBurn engine, especially for Windows Phone XNA Games, you need a second uniquely mapped UV channel, the SunBurn engine then used this to store the Light data generated by the engine for display.

With most models bought off the shelf or even created in your favourite tool, you will most likely find that this is not currently available, so you either have to contact the artists to get this added or use a 3D modelling tool, like Blender to add it.

You could of course hack it in your self into the model file as well, but without a tool you will not know which UV data to place into the second layer, so this process of trial and error could take a lot longer (or you could be fantastic with the FBX file format and just fly through it)

The end result is the same, you need that second channel added to your models in order to enable the “Light Mapping” option in the editor and use the model in your game.


Blender has limited support for IMPORTING model formats, there is currently I know of no importer for the FBX format (even with Autodesk tools such as 3DS Max or Maya) without using complex conversion tools.  SO when you are getting or buying models for use with SunBurn games, make sure you can have access to a source model format you can edit e.g. Collada, Blend, 3DS, Obj.  Basically check first. (Although there are a variety of add-on scripts available for importing other formats, but no FBX as yet)

All Done, enjoy the video and happy motoring

Right I'm back off to the Batcave using my Phones SatNav to get there, which may take a while… Hot smile

Tuesday, 5 April 2011

Blender to Sunburn – Step by step

Following on from my SunBurn session for the TechDays event in march, I am following up with a few short snippets for how to get started and troubleshooting.

Feel free to add comments to this post for further suggestions in the use of tools as an input to Blender.

if you want to learn more about SunBurn or the SunBurn editor, i suggest you visit their site and even check out the excellent video series about the editor.  Also there is the YouTube channel you can subscribe to for more of the editor tutorial videos.

Anyway enough of this preamble and on with the show, I’ve decided to do this one in two flavours the video here and the write of it below:

SunBurn snippets Video #1–Blender to SunBurn

So the video above shows you all the steps, here’s a bit more.

Requirements for SunBurn

In getting started with any modelling tool when you are using SunBurn you just need to work out what it is you need populated in the model in order to make it work, this also depends on which platforms you intend to deploy on:

  • Windows & XBOX
      • Properly rigged objects
      • Named Materials (useful in editor)
      • UV Mapped textures (or just a base UV map if you are texturing in SunBurn)
      • Animation (if required)
  • Windows Phone
      • Everything for Windows / XBOX – plus
      • Second uniquely mapped UV Channel

I’m not going to cover all the different permutations of these, were just going to keep it basic for this example.


It’s noted on the latest release of the SunBurn engine that in future we not need a second lightmap channel for models, so for now this second UV channel technique is needed.

It’s not clear however yet if this will be the case for the Phone in the future, time will tell

Getting set-up

So for the basic example (as shown in the video) we are going to take the most basic object (a cube), texture it, UV map it and then export it for use in SunBurn, then to finish off we will import it into the SunBurn editor.

So after starting Blender you should be presented with the default scene:


Now to make our lives easier (and take advantage of one of the new features in the new blender) we are going to split our main viewport so we can see both the model and the texture/UV mapping we are going to use.

Simply drag left from the top right hand corner of the main viewport.
This will create a second viewport we can use for the separate view
image Next we are going to change the view type to “UV/Image” to show the UV Image editor

Just click on the Selector box in the bottom left hand corner of the new viewport and select the “U/V Image Editor” option

So now you should have a two pane view, model on the left and image area to the right:


Next we’ll generate the texture you wish to use on our model (as stated before you could simply use an existing texture like a crate design or such), In the UV Image window simply click on the “+ New” button and give it some detail and select a colour, then click “OK”:


Before we continue, it is recommended to save both the current model and the texture we just created in their respective folders, Model to one folder and the Texture to a separate “Texture” folder under the same structure, thus:


Getting to the meaty bit

So now whisking through (beating the eggs as it were, not that I have anything against eggs of course Hot smile), we need to define the UV map of the object and assign a texture to it.

I will point out that I am just creating a basic texture through Blender, you could of course use a more complicated texture from elsewhere or even use several textures mapped around the object.

So first switch to “Edit mode” using the selector toward the lower left portion of the screen (A) and then use the “Mesh” menu (if you do not see Mesh it is because you have not selected “Edit mode” to select “UV Unwrap –> Smart Project” (B).


Now you should see a box like map in the UV Editor window like this –>

What you see is a square for each face of the cube.

Try repeating the exercise with the other UV Unwrap modes to see what they do, each affect how a texture would display on an object


Note that our texture has now disappeared, this is simply because we have created a new UV layer, we just need to state which texture the layer is intending to use. 

Because we selected it earlier, by clicking on the picture icon next to the image name you will see a list of known textures to pick from, just select ours.

If you are using an existing image and skipped the texture creation / selection section earlier, you can just select “Image –> Open” at this point to assign it as well.  Note if your image is a single face, then simply use a different UV Unwrap mode to paint your object properly.  This will not affect the next steps.

That done and you should now see your image with the UV Overlay.  So now we need to take this and assign the texture to the model.

In the properties window, select the “Texture” tab (A)

Select the “Type” as “Image or Movie” (B)

Change the preview type to “Material” (C) (just one of those things that works?)

And then Open up the existing Image you saved/used earlier (D).

Note, would not recommend using the “New” option here as the results usually end up different from what you expect, might be a bug or I’m just using it wrong, but hay ho

image With that done you also need to change the Mapping type by extending the “Mapping” section lower in the texture properties and changing the “Coordinates” option to UV.
You can experiment with different types to see the effect but this seems to give the best results here.

So now our texture is mapped to our model, next we need to check and change the material properties, mainly so it is represented correctly in SunBurn.

Swap to the “Material” tab in the properties window:


Making sure you have the correct material selected (if you have multiple materials) then change the name of the material to something a bit more meaningful and hit “enter”, this is what you will see in the SunBurn Editor should you wish to apply different materials to objects there (you might have a generic Box model and several crate textures for example)

I also find it useful to also click on the “Assign” button here, it just affirms that the selected material is applied to the model.

Now for the important bit

So far we have done everything as normal as you would do if you are just using models for XNA, now we need to enhance our model so that we can use light maps against it in SunBurn.

First switch to the “Object Data” tab in the properties window

Here you will see the UV Texture section towards the bottom of the screen.
We already have one UV texture assigned because of the UV mapping we did earlier for the display texture.

Now we need a second texture for our Lightmap.
Just click the “+” icon to the right of the list, give it a more descriptive name like “Lightmap” just so we can identify it.
Then with this new UV map selected repeat the option to Unwrap the model, this time however you do not need to select a separate texture, just leave it un-textured.

Now you should have two UV maps for your model, one textured and one not, just click on each to see the effect.

With that done Save everything (just to be sure), once done we just need to export the model.

Now I mention the “XNA FBX Exporter” script in the video, reason being this script is incompatible with SunBurn, it is useful for normal XNA projects (it sets up a load of defaults specific to XNA like bounding volumes and a few other settings used by the content pipeline, it even now comes as default with the latest Blender builds, no need to install it separately) but SunBurn doesn’t like it.  So just use the Normal “Autodesk FBX” exporter to save your model (into the models folder) and you are done.

Where to go from here

I’m not going to detail here how to import a model in to the SunBurn engine, it’s covered in the video for completeness, but you are better heading over to the Official training videos on the SunBurn site, specifically this one if you need to know now.


Right I'm done for now, I am going to follow up with two other snippets, but just as videos this time to show some common troubleshooting tips for issues I found common when learning all this stuff, namely:

    Why is the Lightmap option Disabled in the Editor
    Why is my lighting not working correctly, it’s all white

These took a little while and a few questions in the Forums to solve, which is the best place to go to get help by the way (Just search first!!!)

Ta ta

Comments and queries welcome