Game Graphics: Rasterization

Last time, I talked about racing the beam, a type of graphics used when memory was scarce. Now it’s time to step into the future with more memory and talk about what modern 2D games still do to this day: rasterization.

Just in time Memory

Continuing the trend set by racing the beam, rasterized graphics are also on a grid, just a much tinier one. Though not unique to rasterized, the “frame buffer” is the logical conclusion of bitmap mode fidelity: enough memory is allocated so that every pixel can have its own color. What’s different about a frame buffer is that everything is drawn before it is shown and, crucially, this doesn’t have to happen in the same order as the pixels are displayed. Rasterization draws entire shapes — triangles, lines and rectangles — into the frame buffer and the screen is typically updated all at once. Continue reading “Game Graphics: Rasterization”

a comparison of the before and after

Compensating For Your TVs Backlight

[Pekka Väänänen] has a Panasonic TV with a broken backlight that creates an uneven pink/green color. While it isn’t a huge deal for most films, black-and-white films tend to show the most effect. So, by modeling the distortion as a function, [Pekka] set out to find an inverse function that corrects the distortion before it gets to the TV.

However, the backlight doesn’t emit enough light for some colors, which means the blue and green channels need to be dimmed. As mentioned earlier, the distortion isn’t even, so the distortion needs to be captured and then calculated.

He took a few pictures with his phone, corrected the perspective, and applied a blur. The camera also has some distortion but works as a first approximation, but that isn’t something he covered here. Next, he set up a webcam and pointed it at the TV, trying to find good gain and offset values with a bit of Python.

 

Now it just becomes a problem of minimizing the per-pixel difference. Ultimately he just went for a random approach rather than an annealing or hill-climbing approach. Now that he had a function to apply, it was just a matter of adding a custom shader to his video player, which includes a live shader editor. He had to hack in support for an external texture, but he is kind enough to include the shader code and the patch in the article.

The result is excellent, and it’s a great use for an old TV. But perhaps, in some cases, it might be worth replacing the backlight entirely.

Solving Mazes With Graphics Cards

What if we told you that you are likely to have more computers than you think? And we are not talking about things that are computers while not looking like one, like most modern cars or certain lightbulbs. We are talking about the powerful machines hiding in your desktop computer called ‘graphics card’. In the ordinary gaming rig graphics cards that are much more powerful than the machine they’re built into are a common occurrence. In his tutorial [Viktor Chlumský] demonstrates how to harness your GPU’s power to solve a maze.

Software that runs on a GPU is called a shader. In this example a shader is shown that finds the way through a maze. We also get to catch a glimpse at the limitations that make this field of software special: [Viktor]’s solution has to work with only four variables, because all information is stored in the red, green, blue and alpha channels of an image. The alpha channel represents the boundaries of the maze. Red and green channels are used to broadcast waves from the beginning and end points of the maze. Where these two waves meet is the shortest solution, a value which is captured through the blue channel.

Despite having tons of cores and large memory, programming shaders feels a lot like working on microcontrollers. See for yourself in the maze solving walk through below.

Continue reading “Solving Mazes With Graphics Cards”