Category Archives: Coding

Coding Solutions

Exponential shadow map filtering (in log space).

It turns out that I was performing a linear filter on my shadow map depths, but I should have been doing the shadow map prefiltering in log space. Whoops. Actually, there seems to be a lot of confusion about how … Continue reading

10 Comments

Exponential shadow mapping drawbacks.

I created a model that could demonstrate some harder cases for the various shadow mapping filters that I experimented with the other day. This model (which is two copies of a sort of church-like building), casts shadows on itself (where … Continue reading

5 Comments

Cascading shadow mapping and ESM.

I implemented shadow cascades today. Below is a screenshot of the current shadows, using two cascades. Note the artifacts that I’ve highlighted with green arrows. About 1/3 of the depth range is represented by the first cascade (and 2/3 in … Continue reading

3 Comments

Shadow map filtering experimentation.

Edit: I demonstrated some harder cases for the important filters here. I also used a brighter light so that it’s easier to see the shadow edges   Over the past two weeks I’ve been working on various parts of my … Continue reading

16 Comments

HDRBlendable Xbox 360 performance and dual paraboloid point light shadow optimization.

While working on dual paraboloid point light shadows, at first I used two R32 textures for the shadow maps, one map per hemisphere of the point light. Here’s a quick glimpse at what point light shadows are currently looking like … Continue reading

190 Comments

My own physics or BEPU?

Norbo (the creator of the BEPU physics engine) dropped by the day before last to let me know that I should expect much higher performance than what I was seeing in my BEPU tests. He suggested that I should be … Continue reading

1 Comment

Physics engine integrated, and sphere-terrain collision done.

Terrain collision was a little harder than I thought it would be. This is owing to the fact that the terrain is a concave body, and many contacts are possible with a single sphere and the terrain. Contrast this with … Continue reading

3 Comments

Optimizing terrain culling.

The code that culls terrain chunks was using a 3D bounding box vs camera frustum test for each terrain chunk, which was incredibly slow. On the XBOX 360 this was taking about 4ms for ~200 intersection tests. At 60FPS you … Continue reading

6 Comments

Dozens of point lights with forward rendering.

I’ve spent the last few days working on spatial partitioning, object pooling code (and fighting with stackoverflow about it), and other necessary performance optimization code. Most AAA titles seem to support something like 5-6 dynamic lights. I’m sure you’ve noticed … Continue reading

3 Comments

Avoiding garbage collections on the compact CLR.

I haven’t posted in a few days because I’ve been working on almost purely programming related tasks, which don’t lead to pretty screenshots. I’ve been improving the efficiency of the spatial partitioning scheme, and terrain draw args sorting. Today though, … Continue reading

Posted in Coding, DBP2011, XNA | Tagged , , , | 3 Comments

Erratic development speed.

I have a priority queue of game features that need to be completed. E.g.: [-3] Pure black rolling fog to simplify fog shader. [4] Dual paraboid point light shadow map implementation [2] Terrain diffuse lighting based lightning effect. [6] Moon … Continue reading

5 Comments

The importance of assertion statements.

When implementing a complex system, where there are many variables/objects, I can’t stress enough how important it is to have some sort of assertion tests in your code. In C# we can write assertion tests that are only run when … Continue reading

Posted in Coding, DBP2011, XNA | Tagged | 6 Comments

Terrain point light progress.

I’ve built a GGR (Geographical Grid Registration) component for the terrain, which will permit better draw call arrangement and in particular, better effect state management when drawing many point lights — which is a goal. Since the terrain is arranged … Continue reading

3 Comments

Terrain lighting progress.

In order to light the terrain, normals must be generated from which we can measure the angle of a light ray’s incidence with the terrain geometry, so that we can decide how bright a terrain triangle will be. For the … Continue reading

3 Comments

Fixing up cracks in the terrain.

Since the terrain is made up of varying level of detail chunks, when two chunks of different detail levels meet, their edges do not match up perfectly. This results in gaps/cracks in the terrain. To fix this, I’ve created a … Continue reading

2 Comments

The CPU vs GPU XBOX360 speed disparity.

Today and yesterday I mostly worked on class work. Actually I mostly worked on a single assignment :/ However, I did find time to write the terrain chunk drawing loop, which implicitly builds a quadtree and tests at each recursive … Continue reading

1 Comment

Terrain started, and quadtree vs. block based LOD.

I put pathfinding on hold because when implementing a hexagonal coordinate based path finding algorithm, I realized that there would be various difficulties with dealing with constructs imposed on the world such as the terrain grid or quadtree and any … Continue reading

2 Comments

Path finding: What would Kirk do?

In my previous post about the challenge of path finding on the XBOX with XNA, my A* algorithm benchmarks were abysmally slow. Recall from my previous post that pathfinding was done in 3D, including diagonal movement, allowing 26 possible directions … Continue reading

3 Comments

Every day can’t be a game development day.

My reality is that I can’t make every single day a game development day. Today I had to catch up with class work, and run various personal errands. To maintain momentum though, I did find time to do a little … Continue reading

3 Comments

Fields vs. properties performance on the Xbox 360.

I took Sam Allen’s performance test and ran a similar test (below) on the Xbox 360 with XNA. static string _backing; // Backing store for property static string Property // Getter and setter { get { return _backing; } set … Continue reading

Posted in Coding, XNA | Tagged , , | 5 Comments

Occurences of one string in another.

The string “ABC” occurs in “ABBC” twice, if you remove any characters you wish from “ABBC”. The following algorithm finds such occurences in O(n) time given any two strings. One assumption worth noting for the O(n) time bound is that … Continue reading

Posted in Coding, Misc | Tagged , | 1 Comment

Extract Longest Non-Decreasing Sequence From Any Sequence

I wrote some python code that extracts the longest non-decreasing subsequence from any given sequence. This runs in O(n log n) time, and uses O(n) memory. ”’ An item in the final sequence, used to form a linked list. ”’ … Continue reading

Posted in Coding, Misc | Tagged , | 10 Comments

Foreach through non-primitive types creates garbage.

Time and again I have seen code like this used in XNA tutorials. effectDrawBlock.Begin(); foreach (EffectPass pass in effectDrawBlock.CurrentTechnique.Passes) { pass.Begin(); gd.DrawIndexedPrimitives(PrimitiveType.TriangleStrip, 0, 0, 35, 0, 70); pass.End(); } effectDrawBlock.End(); When you use a foreach over an array of ints … Continue reading

Posted in Coding, XNA | Tagged , | 4 Comments

ToString Garbage Creation in C#

I profiled my XNA game project today using the XNA Framework Remote Perf Monitor and discovered that I was generating about 8000 more manage objects per second than I was expecting to. It turns out that this code was generating … Continue reading

Posted in Coding, XNA | Tagged , , | 4 Comments

Convert greyscale images to Alpha8 format with a Custom Content Processor in XNA 3.1.

I noticed that at least two terrain engine examples in XNA are reading heightmap images into 4 channel textures instead of single channel textures. To create a custom content processor that will permit you to convert any Texture2D compatible input … Continue reading

Posted in Coding, XNA | Tagged , , , | 2 Comments

2D CDF 9/7 Wavelet Transform in Python

As promised, here is an implementation of the Cohen-Daubechies-Feauveau 9 tap / 7 tap wavelet transform on a 2D signal in Python. This is the same transform used in the JPEG2000 codec. ”’ 2D CDF 9/7 Wavelet Forward and Inverse Transform (lifting implementation) … Continue reading

Posted in Coding | Tagged , , , , , , | 17 Comments