Showing posts with label Ambient Occlusion. Show all posts
Showing posts with label Ambient Occlusion. Show all posts

Tuesday, 25 December 2012

Sci-Fi Alien Weapons

As usual with modelling it has taken me a about three weekends to create one model.

I drew the concept on the 10th of December and put the final touches to the finished weapon and added it to the game on Christmas Eve.



It's inspired by, in fact deliberately similar to, the alien style weapons pack I purchased from Garage Games



That set only includes 3 models and I needed an additional larger support weapon for the aliens.


I am getting the hang of 3D modelling and the basic untextured model only took a day.  What takes all the time is the UV unwrapping and then the texturing.

I always start by creating the Ambient Occlusion layer for my texture.



It does not help that I have to do some bits twice because I forget to set some parts of the model as smooth before creating the Ambient Occlusion (AO).


Without using the smooth option on parts of the model that are curved, the AO shading is banded instead of continuous.



I always like the model with the AO texture.  Shame I can't leave it that way.  I have seen a game where that was the style of the game.  It looked very good but not what I want for Diabolical: The Shooter.

If my artistic skills were better I would be able to create the texture quicker.  I have to put most of it togther from parts.  More like contruction than drawing.  I go through each part, as split by the UV unwrapping, and add details as separate components and blended in to the base colour.  Layer after layer after layer.



I am starting to learn some of the techniques but it takes me time.

For some reason it ended up grey but for this model I wanted it a more silver colour to match the others.  I used a bit of brightness but mainly I adjusted the gamma correction curve to get something more silver.



The in game lighting adds a bit more shine to the surfaces.



Merry Christmas to all.  25 Dec. 2012.

Friday, 7 October 2011

That Hut Again

I have another screenshot for you showing the same hut that I created a few weeks ago.  The point this time is to demonstrate the improved shading of the texturing.  At least I think it looks better.  Feel free to comment.


I used the ambient occlusion (AO), described a couple of days ago, baked in to the texture of the model. 

Now I have AO pre-calculated I have removed the awkward and artifact prone self shadowing from the models.  For that purpose I am using ID based shadow maps.

There was surprisingly little information easily available on the Internet.  Perhaps I searched for the wrong key words.  Anyway, most of the ID shadow code is based on one of the many other shadow and filter methods I have tried up to now.

The difference being that instead of comparing the stored shadow depth it simply checks if the thing closest to the light is it'self or not using a unique index number for each model.

The tricky bit I found with ID shadow maps was converting a signed integer to a float in Shader Model 3.  In the newer Shader Model 4 there are loads of built in methods to do that and I could have used an unsigned int which would have been even easier.  None of that was available for the Xbox shader though!  I used the following simple code:



// Consistently convert a signed integer32 to a float
// in the range 0.0f to 1.0f
float IntToFloat(int inputID)
{
    // The maximum value for a signed 32 bit integer
    return (float)inputID / 2147483647.0f;
}




Once everything was a float it was easy to compare.

==

Unrelated to any of the above I have just exceeded the free 200M capacity of the Subversion (SVN) hosting service I have been using.  The project including documentation is 128M and the rest must be the change history.  I have become used to using source control and would miss it if it was not there so I have decided to pay for more capacity rather than mess about chopping up the project in to smaller chunks or trying to manage my own server.  I am trying out a couple of the lower cost SVN hosts to decide which I will use going forwards.

Tuesday, 4 October 2011

Ambient Occlusion Baked In

I've had a busy time working on the shadows and failing to make the results of my shaders quite as pretty as I would like and still get them to run on the Xbox.  That has made me realise I am unlikely to get enough spare GPU resources to add Screen Space Ambient Occlusion (SSAO) as a post process to make things look even prettier.

That led me back to some thoughts I had in the back of my mind that I should be baking more in to the textures at design time so I am doing less work at runtime.  I write code so I prefer a technical solution to problems rather than a pure artistic however there comes a time when even I have to admit defeat.



Bake
This is the term used to describe fixing a machine calculated effect in to a static texture. The modeling or graphics programme calculates some pattern which can be changed and tweaked by the artist until they are happy with the result. Once they have the final version it has to be merged in to the product, usually a texture, so that it can be viewed or used outside of the programme that generated it.

It only took me two minutes of searching to find instructions and tutorials for Blender to create the Ambient Occlusion (AO) effect and to bake it in to the UV wrapped texture.

There were loads of links here are just a couple:
http://www.katsbits.com/tutorials/blender/blender-2.5-baking-ambient-occlusion.php

I used some bits of the tutorial to do the following:


The process was very simple:
  • Create the model
  • UV wrap the model and manually position the UV's so they do not overlap.
  • Select the model in Object Mode
  • Find the Bake panel at the end of the Render section (little camera icon)
  • Select Ambient Occlusion... 
  • Tick (check), Normalise and Clear.
  • Press the Bake button.
It might take a minute or two depending on the complexity of the model and how fast your computer is.



The result a model showing just the shaded areas.  Now I need that and the diffuse texture together.


  • Save the new UV texture, which is just the shading.
  • Use that texture as a layer in GIMP or Photoshop.  Set the layer type to Multiply so the white areas use more of the underlying colour and the black areas use less of that colour.  (Initially I was converting the white areas transparent, Color to Alpha in the layer menu and change the white colour to transparent.  That works just as well but had one more step.)




  • Save it as a PNG
  • Reload it in to Blender.


Now I have a textured model with shading.

  

  
Just what I was after.

The advantage of using AO is that it is independent of the lighting in a scene.  It is actually completely fake, it is an artistic effect, there is no such thing in the real world.  It makes things look more 3D.

I will be using this on many of the models in the game.