August 2005 - Posts

Xilath - Asteroids game update

Update to the game I am busy working on. It's a simple 3d space shooter. Screenshot.

Posted by pieterg | with no comments
Filed under:

Xilath - ShaderManager (Nearing completion)

Today I spent about 6 - 7 hours working on my shader manager for my engine. The conclusion is that I still need to spend alot more time on it before it will function the way I want it to. Before you go away. Here is a little sample of how the shader manager works. I just give an entity a name of the shader I want it to be rendered with and off it goes and sets all the constants ;) cool huh?

Here are some screenshots
Without the Shader

With the Shader


Model by Mornè Gouws
Posted by pieterg | 22 comment(s)
Filed under:

Xilath - Base update

For those who don't know. I am always on the prowl of getting a simple engine running for new comers to DirectX, I think this weekend has been very prosperous and I think I have finally come to that point. The goal was simplicity and readability.
So without further a due. Here is the base.
Xilath Base
Also I will be using this UML for a tutorial that I'll be writing on simpe game design.

PS: a engine is never complete
Posted by pieterg | with no comments
Filed under:

Tests and The Big Mission

And so it goes when you are studying, I am currently writing tests. I will start working on my tutorials as soon as my tests are over, I am writing my last one tommorow. I will update my tutorials this weekend and add some more screenshots.

The Big Mission I am also thinking of starting a project that will stretch over 5 - 10 months depending on the amount of time I have on my hands. Where I will be designing and logging the engine that I am writing. I will also place links to the various resources I use and the knowledge that I gained from using these resources. At the end of every part I will put the source up for download where users can use it and also comment on the engine and then update it and the changes will be noted on my site... This will give users the ability to shape the engine into a huge community project. Please drop me a feedback and tell me what you think. Take care. Over and out.
Posted by pieterg | with no comments

Xilath - Game Engine (BSP Loader)

Once again, a very prosperous weekend as I got to do some stenciling and finally get half of what is to be a decent BSPLoader class going. For those who want to mess around with it I am releasing the source as is. Very ugly still but should give some of you a base to work from.
C# Managed DirectX BSP Loader (Beta) - Source
What does it do? Well it loads Quake/Doom maps :)
Posted by pieterg | 2 comment(s)
Filed under:

Xilath - Game Engine (Shadowing)

Once again another update this weekend on shadowing. I have continued to improve on the previous mentioned stenciling techniques and combined them to create a stencilled shadows. Obviously there is a screenshot :)
Posted by pieterg | 1 comment(s)
Filed under:

Xilath - Game Engine (Mirrors)

Yet another interesting evening went flying by as I sat and read about the more indepth functions of stenciling and decided that I should code a demo showing off mirroring in C# and Managed DirectX and so here it is.
Posted by pieterg | with no comments
Filed under:

Xilath - Game Engine update

The Game engine (Xilath) that I have been working on is forming nicely. I have managed to put together a small demo of what I have done so far.
C# and Managed DirectX
Contents of the Demo:

- 4 Lights (Shown by spheres)
- 6 Entities (The asteroids and the floor)

That's it for now, I got to get coding.
Posted by pieterg | with no comments
Filed under:

Game Engine design

In the next few weeks I am going to look at game engine design and implement "Tom Miller's Resource friendly game loop" I have found an elegant way to implement it. I am just playing around with some ideas. Once I have something concrete I will release the source. Other than that. This weekend has been very profitable. Got to play with the CLR Profiler and the Pix tool release with the DirectX SDK. Alot of coding got done which makes me happy.
Posted by pieterg | with no comments
Filed under:

What a fantastic evening - SaDeveloper Durban Event

DirectX Talk/Presentation Conclusion. What a fantastic evening, I am glad to have met some of the amazing people who attended. The talk went fine and you could see the DirectX enthusiasm going, It was a bit interactive which I totally liked. The pictures are up on my gallery, although a bit bad on the quality side. It was a fantastic event. Thank you once again to Derivco for the venue and to the SaDeveloper members who pitched up.
Posted by pieterg | 2 comment(s)
Filed under:

Tommorow is the big day.

Yet another day has passed. Today was quite fun, spent some time with my parents, not as much as I would've hoped too. It was alot of fun. I have finished preparing for tommorow which is going to be my talk at Derivco as I have mentioned on my blog. I will hopefully have pictures of my talk up here after the talk. Other than that. I have been hogging the Gamedev forums like a mad man trying to help out with some questions. Otherwise i'm doing well. I will be starting uploading more tutorials as this week was a bit crazy with preparations for items that needed sorting out.
Posted by pieterg | with no comments

Tutorial 7 - Render to Texture

[Download the source]
Have you ever seen water reflecting the environment? This can be done with a technique called render to texture. Let's look at what it involves.
What is render to texture?
Render to texture describes the operation of "saving/capturing" a render target (surface)to a texture.

Let's take an example:

The top left hand corner is a sprite rendered with the textured that we have "saved/captured" from a render target (surface).
The steps to follow the render to a texture.
The easiest way of capturing a render target (surface) to a texture is by taking the following steps.
1) Declare a Texture to capture to.
2) Declare a Surface that will be your new render target
3) Get the surface of the texture
4) Save the original back buffer (color buffer) in a temporary surface
5) Set the render target of the device to a
6 ) Render the objects that you want to save into the texture
7) Set the render target to the original render target.

7 easy steps to remember (I hope).

The code
Declaring your objects.

texture = new Texture(window.D3DDevice, 128, 128, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default);
surface = texture.GetSurfaceLevel(0);

Your RenderToTexture method that will render the scene that you want saved/captured into your texture
private void RenderToTexture()
{
    Viewport view = new Viewport();
    view.Width = 128;
    view.Height = 128;
    view.MaxZ = 1.0f;

    //Save the current render target so that we can reset it after use.
    Surface oldRenderTarget = window.D3DDevice.GetRenderTarget(0);
    //Set the render target to the surface we created
    window.D3DDevice.SetRenderTarget(0, surface);
    //Clear the render target (our surface and our depth buffer of the surface)
    window.D3DDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black.ToArgb(), 1.0f, 0);
    window.D3DDevice.BeginScene();
    //Set the material and the world transform and render the cube
    window.D3DDevice.Material = material;
    window.D3DDevice.Transform.World = matWorld;
    cube.DrawSubset(0);
    window.D3DDevice.EndScene();
    //Reset the render target.
    window.D3DDevice.SetRenderTarget(0, oldRenderTarget);
}
Render your scene.
private void Render()
{
    //Invoke our method for Rendering to the texture
    RenderToTexture();
    //Set the material and the world transform and render the cube
    window.BeginRender(Color.Black);
    window.D3DDevice.Material = material;
    window.D3DDevice.Transform.World = matWorld;
    cube.DrawSubset(0);
    //Use the sprite class to easily render the texture that we saved/captured from our render target (surface)
    using(Sprite s = new Sprite(window.D3DDevice))
    {
        s.Begin(SpriteFlags.None);
        s.Draw(texture, new Rectangle(0, 0, 128, 128), new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.0f, 0.0f), Color.White);
        s.End();
    }
    window.FinishRender();
}
Posted by pieterg | 3 comment(s)
Filed under:

Tutorial 6 - Alpha Blending

[Download the source]
Today we are going to discuss a very interesting topic, Alpha blending.
What is alpha blending?
"The real world is composed of transparent, translucent, and opaque objects. Alpha blending is a technique for adding transparency information for translucent objects. It is implemented by rendering polygons through a stipple mask whose on-off density is proportional to the transparency of the object. The resultant color of a pixel is a combination of the foreground and background color. Typically, alpha has a normalized value of 0 to 1 for each color pixel. new pixel = (alpha)(pixel A color) + (1 - alpha)(pixel B color)"

Let's take an example:

Looks cool doesn't it? This is called alpha blending, where you have a alpha component for each pixel.
How does it work?
Pretty boring stuff
Let's take 2 pixels. One is already in the back buffer (Color buffer) and one is being sent to the back buffer (Color buffer).
Source's Pixel Color (The pixel on the triangle) = (127, 255, 0,    0); //This being an alpha value of 127 (50%) and Red (255), Green(0), Blue(0)
Destination's Pixel Color (The pixel in the back buffer) = (127,    0, 0, 255); //This being an alpha value of 127 (50%) and Red (0), Green(0), Blue(255)

New Pixel Color = Source*Alpha/max_Alpha + Destination*(max_Alpha-Alpha)/max_Alpha
New Pixel Color = 255 * 127/255 + 255 * (255 - 127) / 127
New Pixel Color = 50% Red + 100% Blue (I might be off with the calculation though)
This means the 2 pixels get blended and placed in the back buffer (Color buffer)

How do I make it work?
The interesting stuff
We use the simple set of render states that DirectX so happily offers us.

deviceRenderState.SourceBlend = Blend.SourceAlpha; //set the source to be the source's alpha
device.RenderState.DestinationBlend = Blend.InvSourceAlpha; //set the destination to be the inverse of the source's alpha
device.RenderState.AlphaBlendEnable = true; //enable
Is that all? Yep that's it. Now all you do is render your primitives :)
Posted by pieterg | 1 comment(s)
Filed under:

Xilath - The Class Diagram

Right now it's relatively small but it's functional. I am hoping to extend it further today, like my engine in c++ with collision detection, a state manager, etc...
Posted by pieterg | 3 comment(s)
Filed under:

Managed DirectX and C# - Temple Demo

I rewrote my c++ and DirectX shader demo to C# and Managed DX tonight and here it is in all it's splendour. I am going to play with some more techniques now that it's completed. The framework needs a little work though. This will be the base of my shader development.
Posted by pieterg | with no comments
Filed under:
More Posts Next page »