Todd's profileTodd's spacePhotosBlogListsMore Tools Help

Blog


    June 14

    Game engine update #3

    This is a video I made using FRAPS of the game engine I've been working on.

    This is not actually my game, nor does it look like or have any resemblance to the game I'm developing - it's just a demonstration of the game engine.

    So far, highlights of the game engine supports:

    1. Double precision for all displacements/positions
    2. Normal mapping, ambient occlusion mapping (self shadowing) for objects
    3. Full range Quaternion camera control
    4. Real physics based objects (all objects are tied to a physics object for smooth, realistic motion)
    5. Octree/Frustum culling

    There's more, but I'll leave it at that as the demo doesn't show a lot of the other things.  I just wanted to update this blog that has been sitting here.

    In the meantime, almost 90% of my time is going into the server-side (scalable massively multiplayer) development.  In a few months time, I expect to have a very very primitive implementation of an alpha test client.

    Although the video appears grainy and jumpy at times, the actual image is extremely smooth and clear.  It's the codec compression/decompression of this video that makes it look poor quality.

    Anyways, this very short video is a demo of what I'm currently working on:

     

    More to come soon!

    -Todd

    March 08

    Game engine update #2: Asteroid Belt!

    Well it's been a while since I've last updated my blog - and really have nothing interesting to report in my life (well, ok, maybe something soon :), but for now, these are some of the lastest pics of my game graphic engine. 

    Not really much new, except that I'm very close to completing a custom importer from 3DS Max to a custom model format that my game uses.

    Those using XNA may ask, why "Yet Another Custom Format" ?

    Well, I need the flexibility of using multiple vertex streams, the ability to reduce complexity of models that are far away, normal mapping importing with some advanced lighting as well...

    Anyway, here are a few pics of some asteroids that I created in 3DS Max and imported into my game - the importer creates the DDS files automatically and the C# code as well - all I need to do is copy/paste to Visual Studio 2008 and I'm all set.

     

    2000 Polygon count asteroids:

     

    Asteroid1

     

    Asteroid2

     

    100 Polygon count asteroids:

     

    Asteroid_100Polys

     

    The first two screen shots contain asteroids that are actually medium polygon objects (<2000 polygons per asteroid).  They are 'normal mapped' which basically means that there is a 'picture' that covers each asteroid that gives it lighting instructions that give it the great detail you see. 

    In the last screen shot (just above), the asteroids are low polygon objects (only using 100 polygons per asteroid), yet they look almost as well defined.  (Can you see the differences?)

    Thanks to 'Normal Mapping', very low polygon objects can still look highly detailed.

    Low polygon models are important in games because the less polygons you have per model, the faster your game will render!  Which means you can have more explosions, ships, etc.

    These renderings of an asteroid are my first attempt at creating a model in 3DS Max, and as you can see, it isn't too bad.  I'll be hiring a professional modeler to do the 'real' game objects when I am ready for that.

    The importer program I am writing looks like this:

    image

    And the exporter:

    image

    Well, that's it for now.

    Back to work for me!

    Also, just want to say 'hi' to the guys in #XNA on EFNet.

    -Todd

    February 15

    Game engine progress...

    Haven't made much progress lately, but I did manage to implement normal mapping and true specular lighting using the Phong shading model for specular highlighting.  This does not use the Phong-Blinn utilizing the half vector for faster calculations, it uses the more accurate Phong model.

    The Phong-Blinn makes assumptions that the viewer and light source are at infinite distances.  Getting in close to the cubes produced a far different specular image when I compared the two, and I wanted accuracy over getting a 3% performance improvement.  Besides, by the time I ever get something released, the GeForce 10000 will be out :)

    Currently, I'm working on creating simple GUI controls in XNA such as buttons, labels, etc.

    Hopefully will have something soon.

    This image depicts about 3000 cubes rotating around the 'center' of the scene.  Currently getting 62FPS in debug mode... in Release, it's coming to about 120FPS so far. 

    -Todd

    image

    December 16

    64 Bit code really is faster than 32 bit. Really.

    Ok, so I haven't updated my blog in a while, and I needed a topic.  So this is it.

    Now, granted, I *was* going to write about quaternions and their use in 3D graphics and how handy they are.  But I'm going to save that topic for another time because I'm looking at some old code using quaternions and frankly speaking I just don't know how the @!^&$ it worked before.  I mean it shouldn't...

    So, 64 bits.  There are a lot of myths about 64 bits.  So what are some of the advantages of using a 64-bit OS?

    1. Increased overall memory capacity.  Today's operating systems (OSes) are limited to 4 gigabytes of physical RAM.  This is a processor limitation, not an OS limitation.  The reason we say '32-bits' or '64-bits' for OSes is the actual physical count of 'address' lines on the hardware address bus.  So, if you have 32 individual address lines, you can address up to 2^32 individual memory locations.  That comes out to: 4,294,967,296 bytes of memory, or 4 gigabytes (4GB).

      Theoretically, a 64-bit OS can address up to 2^64 bytes of memory.  That's 18,446,744,073,709,551,616 bytes of memory, or ummm well a hell of a lot of memory which I assure you at 2007 prices would be quite expensive. :)  I'm not even sure that amount of RAM exists.  Anyway, you can see why 64-bit OSes will be around for a while.  I won't be alive when 128 bit OSes become necessary. 

      You might think that 4GB is a lot and that OSes are so bloated now and Microsoft is just producing bloated code, blah blah blah... (insert more whines here and evil Microsoft monopoly comments and how people are forced to use Windows, etc. etc.)

      The facts are quite different.  Just take a standard high resolution image from a camera these days.  An image can easily take up megabytes of memory, and a video can take up 100's of megabytes or gigabytes.  Video editing applications, photo editing applications and the like require enormous amounts of RAM just to function smoothly.  You complain that Vista requires a gigabyte of RAM just to function?  Consider that Vista is doing many things in the background.  *One* application that edits photos or videos can easily require more than one gigabyte to function smoothly.  Anyway, I've digressed :)

      Oh, and if you are thinking "Well Linux takes up just x amount of RAM to function, therefore Vista is bloated"... well, consider my CALCULATOR takes less than a megabyte of RAM and boots up INSTANTLY.  That does NOT mean my calculator is more functional that Vista simply because it uses less RAM and boots up faster.  'Nuff said.

      Some 32 bit OSes deal with this 4GB limitation better than others.  But the bottom line is, if you put 4 gigabytes in your computer, you will only be able to use anywhere from 2GB-4GB of this. 

      Using 64-bit Vista Ultimate, you can use 128+ gigabytes of memory.  This should be future proof for a while :)  I say '128+' because as 128 gigabytes becomes the norm, Microsoft can easily increase this limit up to the physical limitations of a 64-bit processor (2^64 bytes - see above).
    2. Increased memory for applications (processes). 

      Did you know that each application on a 32-bit Windows OS can access a MAXIMUM of only 2 gigabytes of memory no matter how much memory you have installed on your computer? 

      With a 64-bit OS, this limitation is no longer present.  Serious server applications and games will really benefit from being able to access more memory.  For example, "Supreme Commander" uses upwards of 4 gigabytes on large skirmish maps... a 64-bit OS is becoming a necessity for gamers.

      Photo and video editing applications can now request as much memory as they need.  There are tons of other examples, but this blog listing will be a book by the time I'm finished.
    3. Performance increases.

      Yes, it's true.  64-bit applications for the most part will run FASTER than 32-bit applications on the same hardware. 

      Want a 5-20% increase in performance?  Install a 64-bit OS.

      What's the reason for this?  Well, here are a few:
      1. More internal 'registers' on the CPU allows the code to be smaller, lighter, and faster using the internal CPU registers instead of accessing physical memory (very very slow), or cache memory (somewhat slow).
      2. Guaranteed access to SSE(2) and other stuff.  Compilers 'know' that if you are compiling to 64-bit, then the processor will have minimum capabilities.  One of these is SSE which allows super fast floating point operations.  This benefits scientific applications, anything that does calculations (spreadsheets), 3D code and games :)  And a LOT more.
      3. Microsoft has changed the way that functions in code are called now.  Before, 'arguments' to functions were passed on the stack.  64-bit code passes the first three arguments using CPU registers (see #1) - so code that calls lots of functions benefits tremendously.  It takes less memory and less execution time to call functions in 64-bit code now.

    This post is way too long now.  I'm going to leave you with some thoughts.  I've been using Vista Ultimate 64-bit version for about 6 months now and have not encountered any piece of new hardware or application that doesn't function just fine on 64-bit Vista.  In fact, you won't even be able to tell you are running 64-bits... everything looks and feels *exactly* the same.  The only difference is that things may perform a bit faster... :) 

    Why not try it out?  If you buy Vista Ultimate, you get *two* DVDs in the box; one 32-bit DVD and one 64-bit DVD.  You can try out the 64-bit first (you do NOT need to enter a serial number or activate any version of Vista for an entire month).  So give the 64-bit version a try... you can always go 'back' to the 32-bit version of for some reason the 64-bit version doesn't work out.

    Finally, I've been writing a game engine for a while now, and when I compile to 64-bits (I don't need to change any code!), the 64-bit version is running about 20% faster.  Amazing considering I didn't have to change anything.  I just get a 20% performance increase simply by running 64-bit Vista.

    Keep in mind that you need a 64-bit processor :)  Most computers sold today have 64-bit capability.

    There are actually a lot more benefits specific to 64-bit Vista.  Most of these center on security.  But that's a different topic.

    Hope you learned something, this blog entry is definitely not complete with regards to the benefits of using a 64-bit OS. 

    -Todd

    November 16

    Font to Texture application

    I've been working on a game in XNA, and one of the things I need to create is a very flexible control library (labels, textbox, buttons, etc.).  The first of these must be the label so I can display some text.

    Although XNA comes with text output functions, I needed more precision, performance and flexibility for text output.

    The first step is to decide how to display text.  Do you convert font glyphs to triangles and render the text as true 3D?  What about creating a vector font? I decided that what I needed for most applications was high performance '2D' text that I could use for my upcoming control library - and that meant at the very basic level: using 'Quads' for each character and texturing the quads. 

    Later on, in the control library, I can use many performance enhancements to render the labels.  For example, if the text doesn't change, we can render the text once using multiple quads, then render that to the label's 'panel'.  This way, we can simply use one quad for any string of static text.  Anyway, there are many ways to do it with various tradeoffs.

    This is a screen shot of the application I am writing in Windows Forms (.Net 3.5 on Visual Studio 2008):

    image

    This application gives you many text output options, which I won't go into here :)  But I'm designing it such that it is very flexible.

    Here is a directory listing in Vista that shows some of the characters generated:

    FontToTexture2

    I've got a few things to add yet and of course, the obligatory code cleanup and stuff that you always put off at the very end :D

    Looking forward to getting some text into my game.  But first, I've got to write a text library, a control library, then... ummm well I better get back to work.

    Enjoy :)

    -Todd

    November 11

    My new Condo in Singapore!

    Well, due to the quickly rising rents in Singapore, I decided I needed to buy a place before the property prices became so high that they would become unaffordable.  Since most property was already above S$1000 PSF (Per Square Foot), I was forced to look in 'other' areas in Singapore.  One of those areas is called "Geylang" popular for being a legal red light district (yes, that's right, I said LEGAL in SINGAPORE) :)  Geylang is also famous for its multitude of food cafes everywhere - and the food is just excellent.  Geylang comes alive after 8PM and doesn't stop until early morning (I'm talking about the crowds in the food cafes).

    Anyway, my most excellent real estate agent found me a most excellent condo in the heart of Geylang (in the family area, away from all of the girls).  It was going for 444 PSF, occupied the entire floor of the building (no neighbors on the sides), has a terrific draft (windy), and just so much more.  So I sprung for it.  After about a month of renovation, here are the final pictures of what it looks like inside:

    Main living room: (the floors are teak wood with dark walnut semi-gloss finish.  Walls are painted with 'dune white' paint.  Ceiling is plain white.  The blinds throughout the place are semi-see through, except in the bedrooms where they are opaque.)

    Living areaLiving area

    Living area: TV Living area towards rooms

    Kitchen (I had this completely refurbished since the former owner completely 'destroyed' it due to some reason I can't mention here.  Suffice to say, the kitchen is all new.  I put in 3 independent stove units.  Notice the grill in the middle :)  All of the stuff is Ariston, the sales lady loved me.  New fridge, stove, oven, sink, hob, etc.  Espresso maker is Krups.)  Oh, the kitchen is VERY breezy which is great in Singapore because it's usually pretty hot and humid.  So you always get a great breeze when you are cooking.

    Camera 11 NOV 2007 086 Camera 11 NOV 2007 089

     Camera 11 NOV 2007 088 Camera 11 NOV 2007 109  

    Bedroom 1 & 3 (Guest/weight room, entrance to Master)

    Camera 11 NOV 2007 094 Camera 11 NOV 2007 097

    Bedroom 2 (Computer room running Windows Vista 64-bit dual monitor and Ubuntu Gutsy.  Once Windows Server 2008 ships, I'll be setting up a server rack for testing my game in progress - watch for a future blog on that :)

    Camera 11 NOV 2007 075  Camera 11 NOV 2007 077

    Nuclear bomb shelter room - notice the 1 foot thick concrete walls, the 5 lock pins in the door, and the two air ports covered by a 1/4" steel blast shield (air gets through on the side of the blast plate).  Ok, so it's not a nuclear bomb shelter, but it is a "civilian defense shelter".  It has full cable/ethernet/power/lighting inside.  Could make a great server room...

     Camera 11 NOV 2007 116 Camera 11 NOV 2007 117

    View from master bedroom and the living area balcony.  Pool is awesome and it's not used much.  There is a BBQ pit down there too.  The best thing about this place (besides being in the middle of night life) is the VENDING machine down there which carries your favorite soda which is essential when you need to get some coding done and you're all out of something to drink.

    Camera 11 NOV 2007 096 Camera 11 NOV 2007 103 Camera 11 NOV 2007 104

    Well that's it for now on the new place.

    So far, I'm VERY much enjoying it here.  It's nice to own your own place and not pay sky high rent.  My mortgage payments are less than half of what I was paying in rent.  Not bad :)  Oh, and this place is larger than the place I was renting and is on the 5th floor vs. being stuck on the ground floor.

    There is still more I want to renovate, but I'll get to it later.

    Hope you enjoyed the tour!

    -Todd

    November 09

    LED Lighting

    On my living room table:

    My regulated power supply with my Fluke scope on top, soldering iron to the far lower right, breadboard with ‘old’ LEDs (for comparison with the power LEDs on the instruction manual in lower center of image.).

    The LED packaging is just to the right of my cell phone – contains 5 LEDs per strip that I bought. 

    clip_image002

    Power LEDs up close and mounted on an oversized heat sink (notice how very small they are… less than 3mm x 5mm package size!!!) and they put out 100 lumens of light each (compared to about 1700 lumens for a 100 watt incandescent bulb).

    So you’d need around 17 of these super small LEDs to make the same amount of light as a 100 watt ‘normal’ light bulb.  Each of these LEDs uses about a watt of power each, so 17 x 1 watt is 17watts for the equivalent light output of a 100 watt bulb.

    Notice the Singapore ‘dime’ near the mounted LEDs on the heatsink for a size comparison.  The wire I used to attach was very small gauge bell (magnet) wire I think of 24 gauge or something… (it looks big in the picture but was the only size small enough that I had that would solder to the extremely small solder pads on the LEDs).

    I mounted the LEDs using an epoxy + accelerant.  The backside of the LEDs contain a non-electric copper patch for heat transfer (you can actually pump up to an amp through each LED if you so choose – they run normally on 350ma).  In tests, even when running an amp through each LED, the heatsink wouldn’t even get warm… and the LEDs didn’t get warm either… so these are some efficient LEDs!!

    clip_image004

    Ok, and now a picture with all other lights out of the picture:  I didn’t use any flash on the picture, and used normal exposure.  So the room is being lit by only the power LEDs using a total of about 4 watts (3 white + 1 red power LED).  Normally I wouldn’t use the red, but just wanted to see what it looked like :)

    So really, you could do this with 3 watts of power.

    clip_image006

    To get an idea of how small these really are, take a look at the packaging next to my cell phone in comparison:  there are 4 of these LEDs still left in the packaging tape (used for automated surface mount).  Each power LED (Luxeon Rebel Lumiled) costs about US$6.60 in small quantities for the ‘cool white’ color, about $4.40 in larger (250+) quantities.  And by the way, ‘cool’ here doesn’t mean ‘cool’ as in me, it refers to the color temperature of light, such as cool, neutral, or warm light.

    So you get about 100 lumens of light for about $4.40.  Multiply by 17 to get a normal 100 bulb light output (of around 1700 lumens), and you come up with about $75 dollars for just the LEDs… never mind the current regulation systems and such.

    Of course, you will only be using about 17 watts instead of 100 watts, and if you live in a hot climate where air-conditioning is used a lot, that is an additional savings because air-conditioners don’t have to compensate for added heat generated by the ‘waste’ heat of a normal incandescent output.

    So you save money on energy in two ways:  the cost of the energy to power the bulb (17 vs. 100 watts) and the less amount of energy to power the air-conditioner (in the day-time).

    Of course, you could also choose to light rooms more brilliantly and cut energy instead… for example you could triple the light in a given room and still save on energy costs.

    clip_image008

    It was a long day and night to get all of this working.  Had to go buy a regulated power supply (and other electronics related stuff :) so I could adjust current in small steps, and the guy that had the only (high quality) one didn’t accept credit cards (don’t even ask), so I had to go walk to an MRT station to find an HSBC ATM because my stupid HSBC ATM card can ONLY be used in HSBC ATMs (grrr) in the pouring rain using a cheap china-made umbrella that broke halfway through and cut me and my hand got cut in various places and started to bleed and then I was cursing china-made products all the way back to his shop.  But I kept it to myself – sort of.

    Needless to say, I MADE him give me a 15% discount for all of my troubles.

    And since he was so nice, I bought a LUX meter from him too :) It’s pictured in the very first picture in this email in the sort of upper left of the image (it looks like a remote control with a while ball stuck in it at the top).  LUX meters measure light output which let me measure the efficiency of LEDs at various power levels.

    Interestingly, the lower the power you give them, the more efficient they become… which is exactly the opposite of what happens when you lower the power (or dim) an incandescent bulb – they get even LESS efficient – turning less than 5% of the power you give them to light… the rest gets wasted as heat.  In low power situations, the LEDs were giving me almost 130 lumens per watt, and ‘normal’ lights about 5 lumens per watt – it’s that different.  The absolute best fluorescent lights are about 100 luments/watt – however, typically used fluorescent lights only give out about 40-65 lumens/watt.

    Well that’s it for now, hope this was interesting.  Now you know what keeps me up late at night (besides installing the latest Microsoft betas).  Next step is to get a PCB board fabricated that has about 10 of these in a circular patter (so that I can use a lens over them) and package them easily.

    -Todd

    XNA cube renderings

    Well, just fooling around with XNA and took this screenshot:

    For the folks on IRC EFNet #xna :)  We were talking about BOX wars with cubes and... errr...  ummm never mind.

     xna - Copy

    This is a screen shot from a game engine I'm putting together.  This rendering is of 500,000 cubes at a 120 degree angle camera view.  Normal viewing angles are typically less than that. The 120 angled view gives a sort of 'fish eye' view and is responsible for the cubes at the edges looking 'warped'.

    You can notice the 'fake HDR' or the bloom on the letters and lines on the textured cubes giving them sort of a 'glow' look.

    I wasn't really going for FPS, I was after the ratio of CPU usage vs. GPU usage of the rendering engine.  For example, how many objects can I instance vs. the amount of complexity for each object (# of polygons, pixel shader complexity, etc.).

    Anyway, this was simply a snapshot of some of the work I was doing.  I've since made some progress of which I'll post soon.

    -Todd

    November 08

    My first Spaces post

    Well, this is my first post to Spaces.  Just downloaded the new "Live" messenger, and it was actually an installer package for the entire Microsoft Live 'suite'.  It included some nice applications, and this one "Live Writer' was one of them.

    Being an employee and placing all of my trust in Microsoft :)  I just decided to download all of them since they were free.

    I am quite amazed at the level of quality of this software and the integration to the Internet that they all have (hence the 'Live' terminology).  It set up my 'Spaces' account automatically, and now I can write blogs quite easier, or so I will find out.

    If you want to try out this stuff, which so far I can recommend even though I haven't played around with it for that long :), the link is here: http://get.live.com

    It's also easy to uninstall and doesn't seem to leave many remnants behind as other 'uninstallers' do!

    Well... OK... here goes... going to hit the "Publish" button and see what happens... I guess if you see this on Spaces it worked!  3...2...1... PUBLISH!!!!