Showing posts with label XNA. Show all posts
Showing posts with label XNA. Show all posts

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

**Note

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.

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

Thursday, 22 July 2010

XNA-UK Refresh and exciting new look

Well it has been a while since I blogged here, but rest assured we are very much still alive and active in the XNA and 3D Design space.

One of the major piece of works we have done recently is to move and upgrade the XNA-UK site, One of the main hubs in the XNA game space and the best place to meet likeminded people to make games, share ideas and get help.

One of the other signature pieces of the site it to bring devs / artists and testers / designers together in one place.

Come and check it out here:

http://xna-uk.net/blogs/braindump/archive/2010/07/22/welcome-to-the-all-new-amp-shiny-xna-uk-site.aspx

 

Check back often for some exciting news coming soon!

Darkside

If you have missed my content, then check out my Dark Genesis blog (in case you missed the move announcement) on XNA-UK.NET

I will be returning to the 3D tutorial series, however Windows Phone 7 has pretty much consumed my life at present.

Monday, 12 January 2009

A shot in the dark

Well as all firsts post go in new blogs, I may as well explain a bit about myself.

My name is Simon, also known as Darkside in the forums and elsewhere (Only reason Darkside isn’t my gamertag is because someone beat me to it, even though I’ve had the handle since the 1980’s, grrr).

I used to a member of the IT geek squad and even achieved the unholy rank if IT Manager, that being the coveted title of Manager who still gets his/her hands dirty but unfortunately also including the supplementary title of “fix anything with a plug on it” and Yes, the Coffee Machine was first on that list every morning. I prided myself on being able to pick up anything and if I didn’t know about it already, I vowed to find out about it in short order (and the rest of it’s immediate family!)

These days I’ve stooped in to the bowels of the underworld and work more like a project manager these days (the pay being the only recompense as I can feel my IT geekness rotting everyday).

I've still got my hand in all IT goodness and took up a childhood dream of mine, to make games. Not just any game but the best a game could get with sharp pointed sticks.

This all started about 4 years ago and I decided to pickup C++ and a bit of C# and delved into the world of DirectX and MDX. Things were shaping up nicely and I was learning a fair bit until a small strangely shaped creature popped it’s head up over a hill and waved saying that it would be there soon (I assume it just had to pack some clothes and a few essentials), this lovely little beast was XNA and we’ve been friends ever since (even though some rather painful upgrade paths)

I even managed to create (I wont say finish because it never was :- ) and submit a game to one of the early competitions in XNA history, the XBOX360Homebrew contest, I even came 4th in the line up with a mention in some of the early XNA media articles by Microsoft. that was my last public release though as all my time was dragged away, although I did manage to keep active in the forums for a while before even that was stripped from me. Dark times. Sadly the old XBOX360homebrew site seems to have left us unfortunately but you can still read about the competition over at XNATutuorial.com. Shame I liked that site,

Now were into XNA V3 and things are shaping up nicely. Now ignoring last year (also known as the year from hell plus new babies and god awful work deadlines, all references to last year shall henceforth be stricken from the records), I’ve started to make plans for the year ahead. I’ve stripped down both my current workloads (the wife is disappearing off to weightwatchers and I've scaled down my work work) and have planned for 2 main tasks:

  • A 3D Modeling tutorial series, slow but sure and to cover a few apps
  • Some serious work on my XNA 3 evolved version of my old Hack-1 game, with some serious re-design and a slightly different focus for where the game is headed.

I recently also joined Dark Omen Games thanks to Charles “Randomchaos” Humphrey, so I'll be helping out from time to time with 3D modeling work and some design reviews.

All in all 2009 should shape up rather nicely. Now time for a wafer thin mint to finish this post off.