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.

**Update

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:

image

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
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:

image

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”:

image

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:

image


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).

image

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
image

image

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
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:

image

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.
image

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.


Done

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

5 comments:

  1. Excellent tutorial. I was wondering how to use multiple materials.

    I'm a bit disappointed and surprised that the Blender to XNA fbx exporter does not work with Sunburn. I did not know that Sunburn used their own fbx importer! What results do you get?

    Have you tried the Release Candidate version 2.57 of Blender?

    By the way, I am the author of the modified Python script but I don't use Sunburn.

    ReplyDelete
  2. I'm not sure what it is about the Blender XNA exporter that throws off the SunBurn Editor.

    But something extra in the FBX file seems to really throw off models generated by it, they become drastically reduced in size and are unmanageable by the editor.

    SO I had to resort to the native FBX exporter available.

    Perhaps a post in the SunBurn forums might sort this out so that users can get the benefits of what the Exporter gives, or possibly an extra script to use features of Blender in SunBurn. Possibilities possibilities ;-)

    As for the materials, it took some time to figure out exactly which option or setting was needed to pass through the materials through to SunBurn, but the practice is fairly simple.
    In edit mode just select the portions of the model you want to assign the material to and click assign. In the video I just selected the entire model, but you can just select certain faces (or points even in some cases) to create separate effects.

    If it would be useful, I'll do a separate video on that.

    ReplyDelete
  3. Oh and thanks for the tip for 2.57. I've been a bit out of the loop for the Blender updates recently.
    Although it's still not available from the main Blender.org site?, lol

    ReplyDelete
  4. I use Vertex groups a lot when UV unwrapping. I assume that would work well with the matrial assignment.

    A short video might be useful because it was not obvious to me as a novice that when UV unwrapping or with the materials that you can do that for individual or groups of faces. I think that gets the best results.

    Thanks

    ReplyDelete
  5. OK, I'll see what I can do for another snippet.

    Will most likely do two, one with a downloaded model and one with a crafted model to mimic what is being used in the other tutorial videos on the SunBurn site (The tunnel)

    ReplyDelete