Shawn Hargreaves' Blog

Game programming with the XNA Framework
0 comments
9 followers
101 entries
Advertisement
shawnhar
May 03, 2011
Antialiasing source textures
This is almost too obvious to be worth pointing out, but no amount of clever tricks like bilinear filtering and mipmapping will help if your input data is itself already aliased!

Yet the example texture used in my previous post had nasty pixelization along the diagonal black lines:



I can im…
757 views
shawnhar
April 29, 2011
Texture aliasing
Aliasing can occur any time you resample a texture, for instance to scale it, rotate it, or map it onto a 3D model. Thanks to our friend the Nyquist threshold, the resulting problems get worse the lower a frequency you sample at, ie. the smaller you shrink it.

Check out this awesome 32x32 test ima…
972 views
shawnhar
April 27, 2011
Multisampling
Multisampling is a compromise for people who really want to use supersampling, but can't afford it.

The idea is simple: instead of increasing the resolution for all rendering, what if we do triangle rasterization and depth/stencil tests at the higher resolution, but leave pixel shading and texture l…
1,092 views
shawnhar
April 27, 2011
Supersampling
Supersampling is the simple, brute force approach to antialiasing computer graphics.

In order to avoid aliasing, the Nyquist theorem says we must take at least twice as many samples as the highest frequency detail in our input signal. So how about we just render our scene at a really, really high …
1,213 views
shawnhar
April 21, 2011
How to resample a signal without aliasing
My previous post described how resampling a signal can cause aliasing problems. The worst problems occur when dramatically reducing the number of samples used to represent a signal, or when the source includes lots of high frequency detail. Specifically, there is a magic value called the Nyquist fr…
659 views
shawnhar
April 21, 2011
Why sampling a signal causes aliasing
The math behind digital sampling and filtering is fascinating, complex, and full of arcane terms like Nyquist frequency. But I'm barely a good enough mathematician to understand it, let alone try to explain it here! This post is my attempt to describe aliasing as it applies to computer graphics via…
839 views
shawnhar
April 20, 2011
Antialiasing
I've been meaning to write about antialiasing for a while, but now I sit down to do that I realize I have too much to say for a single article. So this post is the introduction to a series.

Antialiasing is one of the most important yet least widely understood areas of computer graphics. If I had a…
740 views
shawnhar
April 14, 2011
"Code" is a four letter word
"Source code"

"Bedroom coder"

"Can someone explain why this code isn't working?"

"He's such a natural, he thinks directly in code"

These are dirty, dirty phrases...

code (kohd) noun
A system used for brevity or secrecy of communication, in which arbitrarily chosen words, letters, or sy…
685 views
shawnhar
April 05, 2011
Visitor and multiple dispatch via C# 'dynamic'
There is a somewhat convincing argument that software design patterns are really just an attempt to emulate missing language features.

Eric Lippert recently wrote a series of articles exploring how one might attempt to implement the "virtual method pattern", if that was not already built in to C#. …
874 views
shawnhar
April 01, 2011
Keyboard macros
I'm sure you've all watched someone who doesn't know keyboard shortcuts struggling to edit a document. It can be frustrating how long even simple things take, and hard not to start shouting advice: ctrl+shift+right, ctrl+x, end, ctrl+v!

But I occasionally see even master programmers, the kind with…
610 views
shawnhar
April 01, 2011
What's with all the hating on Comic Sans?
[font="Comic Sans MS"][size="2"]Google's April Fool joke[/font][font="Comic Sans MS"][size="2"] got me reading about [/font][font="Comic Sans MS"][size="2"]why graphic designers hate Comic Sans[/font][font="Comic Sans MS"][size="2"] so much.[/font]

[font="Comic Sans MS"][size="2"]I can't help bein…
600 views
shawnhar
March 25, 2011
Technical term that should exist: "black pit of despair"
Phrase: "the black pit of despair"

Definition: When fixed timestep catch up logic fails to keep up with the target time.

Usage: "Yesterday the framerate was bad, but today it got so much worse that we fell into the black pit of despair."

Etymology:

Fixed timestep game logic works by calling …
781 views
shawnhar
March 25, 2011
Technical term that should exist: "raiding"
Noun: "raiding"

Definition: Manually editing per-vertex color values to approximate static lighting or increase the perception of texture variety.

Usage: "Have you finished raiding level 3 yet?"

Etymology:

'twas long before shaders.

'twas long before realtime lighting.

'twas before even st…
678 views
shawnhar
March 25, 2011
Technical term that should exist: "scrottox"
Noun: "scrottox"

Definition: The opposite of a detail texture. Like a detail texture, scrottox is a monochrome image drawn using modulate2X blend mode, but where a detail texture is tiled more heavily than the base texture so as to provide fine detail when zoomed in close, a scrottox layer is til…
803 views
shawnhar
March 25, 2011
Technical term that should exist: "fruited"
Verb: "fruited"

Definition: When an application is suspended due to a system timeout such as a screensaver, or because the user locks their phone.

Usage: "Be sure to pause the music if you get fruited."

Etymology: In the early days of Windows Phone development, long before someone coined the…
625 views
shawnhar
March 25, 2011
Technical term that should exist: "parakeet"
A common side effect of developing new technology is the invention of new terminology. At its best, this can be both fun and useful, providing a concise shorthand for what would otherwise be awkward or ambiguous concepts. These shorthands are often unique to a company or project, and different team…
682 views
shawnhar
February 22, 2011
Programming languages as literary style
As proof of how focused and impossible to distract the XNA team is, this is where we ended up five emails into a thread that started with me asking for a code review. Drawing parallels between programming languages and the styles of famous authors, I suggested:

James Joyce = Lisp. Why limit yo…
572 views
shawnhar
February 10, 2011
Doing the right thing: resume, rewind, or skip ahead?
My second example of a problem where "just do the right thing" turns out to be surprisingly complicated is a feature that does not exist, but ought to.

Being a luddite who has not yet cottoned on to this newfangled MP3 player fad, I like to listen to CDs in my car. My daily commute takes around h…
771 views
shawnhar
February 09, 2011
Random shuffle
I am fascinated by problems that are easy to describe, and which appear simple when solved correctly, but where the implementation must contain surprising complexity in order to do what people expect.

Example: play a list of songs in a random order.

When I had to implement this feature for MotoGP…
782 views
shawnhar
January 21, 2011
XNA Notes from George Clingerman
Not content with his role as the undoubtedly nicest and mostest politest of all XNA MVPs, George has started what looks to be a weekly roundup of news from the XNA community:

540 views
shawnhar
January 13, 2011
SpriteBatch billboards in a 3D world
A while ago I wrote about how to use SpriteBatch with a custom vertex shader, but didn't go into detail about how to set up matrices for drawing sprites in 3D.

The fundamentals are simple:

  • SpriteBatch generates vertex data containing Vector3 positions (plus texture coordinates and tint colors)…
924 views
shawnhar
January 04, 2011
XNA 3.1 to 4.0 cheat sheet
Nelxon Studio has a nice article about XNA version upgrade: http://www.nelxon.com/blog/xna-3-1-to-xna-4-0-cheatsheet/



Source
865 views
shawnhar
December 30, 2010
LCD response time
Regardless of whether you are developing for PC, Xbox 360, or Windows Phone, your game will most likely be viewed on some kind of LCD screen. An important characteristic of LCD technology is the response time, which measures how long pixels take to change color from black to white and then back to …
553 views
shawnhar
December 22, 2010
Why does ContentManager.Load or TitleContainer.OpenStream say file not found?
The simple answer is that the file you are trying to load must not actually exist in the location you are trying to load it from!

And yet people sometimes get stuck on this error, unable to open their file and with no idea how to figure out why this is failing. I suspect this is a side effect of t…
1,200 views
shawnhar
December 19, 2010
XNA book by my colleagues Tom and Dean
I have no idea how they managed to find time to do this at the same time as finishing up XNA Game Studio 4.0, but my colleagues Tom and Dean have written a most excellent book with the pithy title XNA Game Studio 4.0 Programming: Developing for Windows Phone and Xbox Live. Now in stock at Amazon, s…
598 views
shawnhar
December 16, 2010
Isolated storage, Windows, and ClickOnce
You want to implement save games.

You've decided to do this using isolated storage (perhaps because you are targeting Windows Phone, or because you want something simpler than the Xbox StorageContainer APIs).

But since XNA is so awesomely portable, you are also making a Windows version of your …
1,254 views
shawnhar
December 09, 2010
Reading files in XNA Game Studio 4.0
The XNA Framework provides no less than three different APIs for reading data out of files. This table attempts to explain the differences, and thus help you understand which to choose:

Title Container Isolated Storage Storage Container Purpose …
1,005 views
shawnhar
December 06, 2010
When WinForms met Game Loop
WinForms and XNA have quite different ideas about how a program should run.

XNA assumes that games are always in motion, moving and animating. It constantly cycles around the game loop, calling your Update and Draw methods. This is convenient for most games, but wasteful if the program reaches a s…
1,340 views
shawnhar
November 22, 2010
WinForms and the big red 'X' of doom
You are making a WinForms app. All is going well, until one day your custom control disappears. In its place you just see a big red cross:



What gives?

Let us back up to remind ourselves how exceptions work:

  • If your code does something wrong (such as dereferencing a null object or passin…
1,968 views
Advertisement

Popular Blogs

shawnhar
Generalist
101 Entries
9 Followers
15 Entries
10 Followers
johnhattan
Programmer
1,277 Entries
47 Followers
ApochPiQ
Generalist
628 Entries
44 Followers
dgreen02
Generalist
338 Entries
56 Followers
Advertisement