Home

3D Game programming book with focus on using Balder

Over the last 6-7 months we've been hard at work getting the Balder project up to speed, one of the motivational factors for working on the project has been a book project by Gastón C. Hillar. He started a journey on writing a 3D games development book for Silverlight and researched a few engines out there and landed on Balder to be the one for the book. His book is now being announced by Packt Publishing and will be coming out in both a paper version and an ebook version. We owe a lot of thanks to Gastón for trying out Balder at the different stages and coming with feedback during the development that has proven truely valuable. You can read more about the announcement here.

If you want to learn more about game development on the Silverlight platform, be sure to pick up a copy when it hits the market!

Currently rated 4.3 by 6 people

  • Currently 4.333333/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Categories: .net | 3D | Game Development | Silverlight | Balder
Post Information: Permalink | Comments (1) | Post RSSRSS comment feed

Balder in the news.. sort of..

We're starting to get a little bit of publicity with regards to the Balder project, which of course can hardly ever be a bad thing. :)

Gastón Hillar has just published an article on the Dr.Dobbs blog about Balder and the optimizations we've been working on the past couple of months. I think it is pretty much thanks to Gastón that Balder was revitalized earlier this year, and he has been very active with testing all the new bits we've been putting in and given us pin-pointers to were to start looking for optimizations and so on. A huge thanks to him for the article and the go-go-spirit in using Balder and giving us the kick in the behind we needed to get the engine to a more decent level.

You can find the article here.

Gastón has written a few books earlier that can be found over at Packt Publishing.

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Categories: .net | 3D | C# | Game Development | Balder
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Balder 0.8.5 release out

Update 2nd of August 2009: If you downloaded the release before 10PM Central European Time (GMT+1) on the 2nd of August 2009, please download the new binaries again. Statistics code was left in the release that caused a serious drop in performance.

We've finally got an update for Balder that contains the optimizations and new features we've been working on lately. Its still withing the Alpha stage, so we're still adding some features.

You can find it here.

 

So, whats new?

  • Support for PNG and JPEG with all features supported by Silverlight 3
  • Support for Demoniak 3D XML format - 3DSMAX plugin can be found here
  • Optimizations, multithreading - read more here
  • General bugfixing and other optimizations
  • Size reduction - no need for SharpZipLib anymore (this might come back for other reasons)

 

Currently rated 4.5 by 2 people

  • Currently 4.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Categories: .net | 3D | Game Development | Silverlight | Balder
Post Information: Permalink | Comments (1) | Post RSSRSS comment feed

Balder Silverlight 3 optimization - round 1

Working with Balder really gets me nostalgic. Nowadays, working with graphics programming one would choose OpenGL, DirectX or Xna to get real performant. Back in the days (mid 1990s), we didn't have the luxury of high-speed CPUs and dedicated 3D accelerated graphics adapters. Everything had to be done by the CPU. Balder has turned out to be just that kind of project, everything is done by the CLR and then the CPU.

Balder is now closing in on the beta stage, which means that we're getting close to the featureset we want to have for version 1 of the engine. While completing the features for the engine, we're also dabbling a little bit with optimizations. The true optimizations will happen in the final stages between beta and release, but its natural while working with features to increase performance on some parts of the engine. We've only scratched the surface of what is possible to optimize, the potential is great.

The first optimization we did was a couple of weeks ago, when getting Balder ready for Silverlight 3. Silverlight 3 introduces something called WriteableBitmap which gives access to a pixel buffer that can be manipulated pixel by pixel. After seeing the results from René Schultes speed tests, its obvious that WriteableBitmap is the right choice for the job, allthough I put quite a bit of work into the Png streamer.

Over the course of this weekend, I managed to get quite a bit of work done - focusing on optimizations. One of the focus areas we've been having is to get things running in parallel. Silverlight has great threading capabilities and are able to utilize multiple CPU cores very efficiently. In the release version of Silverlight 3, Microsoft has allowed for cross thread access to the pixels in a WriteableBitmap. This is good news for us. The previous version, the 0.8 alpha version, had one thread doing all the job. This was not exploiting the posibilities, and left the CPU pretty much doing nothing half the time. The new solution has 3 buffers and 4 threads, one thread for syncronizing all the work being done and one for each of the buffers. The buffers has special purpose; one for clearing, one for rendering and one for showing - showing being the copying of pixeldata to a WriteableBitmap. 

The flow is as follows: 


In addition to this, the rendering is no longer working on bytes for every color component, but writes an entire 32 bit int to the buffer for every pixel. These optimizations has truely paid off, on my computer with the regular teapot test (about 1000 polys), gives a framerate between 50 and 60. This is promising, considering we've hardly started optimizing at all.

A demo can be found here. It should look something like this:

Currently rated 5.0 by 4 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Categories: .net | 3D | Game Development | Silverlight | Balder
Post Information: Permalink | Comments (11) | Post RSSRSS comment feed

Balder - Silverlight 3 - RTW Support

Balder has been updated to support Silverlight 3 the release version.

The previous samples posted here now works with the release version.
You can find the samples directly here and here. And I've also created a version that just shows off that the texturemapping is very real, it can be found here. :)

We're working on new demos to truely show off Balder - its feature richness and capabilities are way beyond a rotating teapot. But focus on getting everything right in the engine has taken away energy to create a proper demo. Fear not, it will come. Stay tuned.

 

Currently rated 4.7 by 3 people

  • Currently 4.666667/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Categories: .net | 3D | Game Development | Silverlight
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Balder reaches alpha release

We're closing in a version 1.0 release of Balder, for the moment we're at Alpha and we decided to put out a release on the Balder codeplex site for everyone to start working with.

The release can be found here. In addition we've started on a getting started guide as well to get you up and running pretty quick, it is located here.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Categories: .net | 3D | C# | Game Development | Silverlight
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Balder - Silverlight 3 ++

UPDATE, 12th of February 2010, Balder 0.8.8.6 is out, take a look at the sample browser here - read more about the new features here.

We've been hard at work on Balder lately, with getting Silverlight 3 support up and running, optimizations and bugfixes.

Uptil this last week, we were focused on getting the most juice out of Silverlight2 before thinking about Silverlight 3, meaning a lot of work on the PNG streaming feature to get it just right and exploit multithreading to achieve parallelism in the pipeline. The result was a framerate boost that gave the test scene we're running a pretty steady 35 FPS. With the introduction of Silverlight 3 and its WriteableBitmap, things are looking up quite a bit for getting quite acceptable framerates. Only problem we've got now, is that the scale has tipped a bit. With SL2 we had to focus on the last part of the rendering pipeline, namely getting the pixels to the plugin from the managed buffers. With SL3 and the speed we're seeing with the usage og WriteableBitmap, we need to go back and optimize other parts of the rendering pipeline to get the framerates we want. 

The current rendering technique has a lot to be desired as for optimizations, it was "thrown" together more as a proof of concept, we're now hard at work with a new technique that will enable us to really not draw more than we need to and be able to run more complex scenes.

Silverlight 3 samples:

Only shading:

 

Environment mapped:

 

 

You'll find the samples here and here

 

Currently rated 4.8 by 4 people

  • Currently 4.75/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Categories: .net | 3D | Game Development | Silverlight
Post Information: Permalink | Comments (4) | Post RSSRSS comment feed

Balder - Silverlight 2 poll

We've just added Silverlight 3 support for Balder and at the moment we have support for both Silverlight 2 and 3. As developers we'd love to just have support for one version, but we've opened up a poll for people to cast there vote if support for Silverlight 2 is critical.

Please go here and cast your vote and also please leave a note as to why this is critical for you.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Categories: .net | 3D | Game Development | Silverlight
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Balder gets its long awaited texture support

UPDATE, July 5th 2009: read about Silverlight 3 optimizations here and the alpha release here

Ever since I started the Balder project back in 2007, the main goal has always been to get proper texturemapping support in the engine. At one point I had it all up and running by utilizing the Silverlight Matrix transformations for the brush used to make it scale and skew according to the given texture coordinates.

The problem was speed. I never really figured out what the speed issue was, but I guess the architecture of Silverlight was never built with 3D graphics in mind. 

With the new software rendering technique in place, it is a lot easier to get different drawing techniques up and running. One drawback we ran into when doing everything with "software", we can't utilize the imaging support, such as the PNG decoder that Silverlight has built in, there is no way to get hold of the pixel data. So, the first thing we needed is to have a C# decoder og image data and we started off with PNG. Looking for an existing PNG decoder entirely written in managed code (C# preferably) turned out to be quite an interesting task. After some time googling, I finally came across a project called PR2 that has something called SharpPNG. After bending the code a bit, I got it running in a more generic way and put it in the Balder repository (with all credits intact - ofcourse).

After getting the image loading in place, it was off to write the texturemapping support. With the generic implementation we have for doing triangle drawings at the moment, the task ended up being quite simple.
A snippet from the SimpleSpanRenderer as an illustration:

public void Texture(IBuffers buffer, Span span, Image image, ImageContext texture)
        {
            var spreadCount = span.XEnd - span.XStart;
            TextureInterpolator.SetPoint(0, span.ZStart, span.ZEnd);
            TextureInterpolator.SetPoint(1, span.UStart, span.UEnd);
            TextureInterpolator.SetPoint(2, span.VStart, span.VEnd);
            var yOffset = span.Y * buffer.Display.Stride;
            var rOffset = buffer.Display.RedPosition;
            var gOffset = buffer.Display.GreenPosition;
            var bOffset = buffer.Display.BluePosition;
            var aOffset = buffer.Display.AlphaPosition;
            var bufferOffset = yOffset + (span.XStart * 4);
            var depthBufferOffset = (buffer.Width * span.Y) + span.XStart;
            TextureInterpolator.Interpolate(spreadCount);
           
            for (var index = 0; index < spreadCount; index++)
            {
                var z = TextureInterpolator.Points[0].InterpolatedValues[index];
                var bufferZ = (UInt32)(z * (float)UInt32.MaxValue);


                var u = TextureInterpolator.Points[1].InterpolatedValues[index];
                var v = TextureInterpolator.Points[2].InterpolatedValues[index];

                var intu = (int)(u*image.Width)&(image.Width-1);
                var intv = (int)(v*image.Height)&(image.Height-1);

                var texel = ((intv*image.Width) + intu)*4;


                if (bufferZ < buffer.Depth[depthBufferOffset] &&
                    z >= 0f &&
                    z < 1f
                    )
                {
                    buffer.Display[bufferOffset + rOffset] = texture.Bytes[texel + 1];
                    buffer.Display[bufferOffset + gOffset] = texture.Bytes[texel + 2];
                    buffer.Display[bufferOffset + bOffset] = texture.Bytes[texel];
                    buffer.Display[bufferOffset + aOffset] = texture.Bytes[texel + 3];

                    buffer.Depth[depthBufferOffset] = bufferZ;
                }

                bufferOffset += 4;
                depthBufferOffset++;
            }
        }

Finally we had to add support for materials in the ASE file loader, I ended up spending too much time trying to figure out a good way to do it with regular expression, ending up with also adding a project by Joshua Flanagan called Readable Regular Expressions in combination with LINQ to RegEx by Roy Osherove. Both projects are now part of the Balder repository as well. The reason for adding them to the repository is for maintenance purposes, seeing that we're targeting Balder for multiple platforms. The better way would probably be to contribute to the projects so they had the modifications or support we need to have for Balder. 

With all this in place, it was texturemania going on:

 

There is also experimental code in the Balder repository for doing spherical environment mapping. This will be part of the material system, so one does not have to think about it in the code.

 

 

You can see both demos in realtime here and here.

Currently rated 5.0 by 3 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Categories: .net | 3D | C# | Game Development | Silverlight
Post Information: Permalink | Comments (3) | Post RSSRSS comment feed

"Software" rendering in Balder

UPDATE: 19th of may 2009 - Texture support is now added, read more here.

We've been hard at work the last couple of weeks to bring Balder to a point where it can be useful, not only a proof of concept for prooving that 3D can be done in Silverlight.

Our main challenge is to get a proper framerate in Silverlight. The reason for this is due to the architecture of Silverlight, there is a big cost in marshalling data between the CLR and the rendering/Xaml engine, so one has to try to limit this. Our initial plan was to generate all the polygon data needed in a 3D scene during initialization and then just turn the visibility on and off and modify the coordinates and color/brush information dynamically. Since a polygon is a dependency object and the properties we needed to modify was dependency properties, this sounded like a good plan, and it was. My previous post showed a version using this technique, and we could get a decent framerate, but it was only flat shaded - no shading nor texturemapping.

Our next goal was then to include what is known as gouraud shading, here we ran in to a bunch of issues. First of all, how could one simulate the effect of gouraud shading in Silverlight 2, when there is no brush that has this implemented. The brushes available in Silverlight are SolidBrush, LinearGradientBrush and RadialGradientBrush. After some experiments, I ended up getting a solution working using the RadialGradientBrush. The technique I used was to have 3 polygons representing every triangle, all with different radial brushes. The brushes hotspot/origin was then set to be on the 3 points representing the triangle and then have some magical calculation for generating the correct color values and alpha values for the gradients. The result was kinda nice, allthough not entirely correct rendering.

 

I then started to implement it for the engine itself, but never finished it, the result before finishing it was this:

 

The reason for not finishing it was plain and simply speed. The FPS dropped from a solid 30 FPS to 5. We decided then that in order for this project to survive, we needed to do something dramatic. I started then to look at how we could draw using "software" - pixeldrawing in C#. In Silverlight 3, this would be a walk in the park, seeing that there is an ImageSource called WritableBitmap, in Silverlight 2, which is still our main goal, it is not all that straight forward to do. I remembered that I had seen samples of water effects, mandelbrot and such for Silverlight 2, and the technique being used is to generate a RAW PNG file on the fly every frame and streaming this into the BitmapImage source. Joe Stegman has an excellent implementation for this here. But, being in a optimization mode, I found there was a couple of things in his solution that generated quite a bit of overhead.

First of all, there is an EditableImage class holding the buffer one can draw to, this is then encoded into a new buffer. Another thing I found to be an overhead, was the usage of two different memorystreams during the encoding. Long story short, during the weekend I decided to create what I called a RawPngStream. It is a somewhat highly optimized stream that holds a buffer one can write to. The listing of the source is to big for this post, and to much details to go into - but you'll find it over at CodePlex in the Balder.Silverlight project.

What we have done now is to introduce a general software rendering component, that is not targetting specifically Silverlight - in fact, we created it for Windows Forms first - seeing that it was easier to get things up and running there first. The last thing we've done is to implement the Silverlight specifics, with the framebuffer handling and all. The result, with a few inaccuracies in the polygon routine for now, is as follows.

A demo can be found here.


Currently rated 5.0 by 3 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Categories: .net | 3D | C# | Game Development | Silverlight
Post Information: Permalink | Comments (4) | Post RSSRSS comment feed