154

"Memory" and "efficiency" are commonly misused terms, so I'll give you an answer for four different elements that may affect the performance of your game. I will be oversimplifying way too many things to keep it short and concise, but there are tons of inaccuracies in this text below, so take it with a pinch of salt. However, the main ...


93

Even with an engine, getting something to display on the screen the way you want it is not always trivial. There will be many instances where someone with programming knowledge is required to make the graphics display correctly. These people may be called graphics programmers in the credits (graphics programmer is not a certified or protected title, and the ...


91

GIF drawbacks: very limited color palette, typically 256 colors with ugly dithering (yes, you can have more than 256 colors in animated GIF, but this is uncommon) GPUs don't support GIF compression in hardware (means you will have to unpack them on CPU anyway) you only get to pick ONE color for transparency (unless implementing custom processing) no random ...


70

There are two types of normal maps commonly used in game development. The way you are thinking they should work is the way one type works (model-space normal maps), but most games use another type (tangent-space normal maps) which is why you associate mostly-blue textures with normal maps. With model-space normal maps, each channel encodes the precise ...


65

Game engines are like kitchens, and developers (i.e. programers) are like cooks. Game engines offer possibilities, while the programmers exploit these possibilities to the needs of the game. Thus, game companies need graphics programmers to tailor the engine's graphics possibilities to the game's needs. If the game engine were to manage everything, ...


51

Shadow mapping and stencil shadows (shadow volumes) are definitely the big two, as you've mentioned, so I'll stick to comparing the two. And since you've pointed out the most obvious shortcomings of shadow mapping and advantages of stencil shadows, I'll do the opposite. Stencil shadow shortcomings Shadows match the shape of the casting mesh. This is very ...


48

Here's a rough idea using image processing transformations to isolate the features of interest: Apply a flood fill from an ocean cell to make a mask of all ocean cells. Depending on how your rivers are set up, you might need an extra elevation or clearance criterion to keep the ocean mask from flowing inland. ;) Apply a local smoothing to the edge of this ...


47

A quick and easy way - though not 100% precise one - is to consider just the five extreme points white, black, red, green and blue. First, let's transform RGB into linear space. Officially this is usually done by this formula (assuming the source data is in sRGB, which is the default for most graphic card operations on 8-bit data and nearly every image you ...


43

First of all, consider if it is actually worth it to support more than one graphics API. Just using OpenGL will cover most platforms and will be "good enough" for all but the most graphically ambitious projects. Unless you work for a very large game studio which can afford to sink several thousand person-hours into implementing and testing multiple rendering ...


41

It's not just about speed of execution, but also about simplicity. Although the software rendering used in this example would be a lot slower than using hardware acceleration (i.e. a GPU), drawing a few bitmaps on screen is such a trivial task that you would not notice the performance drop. However, low-level activity like triangle rasterisation, depth sort ...


34

This is a facet of the math of affine transformations crammed into a single matrix. In an affine transformation you have the equation: x' = Ax + b, where x is the original vector, A is the transformation matrix, and b is the translation vector. To combine A and b into a single matrix requires some extra work. Namely, we must be sure that we can "turn off" ...


32

I don't think any of the other answers here will achieve the effect in Pokémon X/Y. I can't know exactly how it's done, but I figured out a way which seems like pretty much what they do in the game. In Pokémon X/Y, outlines are drawn both around the silhouette edges and on other non-silhouette edges (like where Raichu's ears meet his head in the following ...


32

In order to use any image file as a texture in a game, there must be a texture created on the GPU and the pixel data in the image file must be loaded to that texture. GPUs do not support many of the features that image files on CPUs support. They don't support JPG compression, they don't support PNG compression, and with particular reference to GIFs, they ...


29

The way Dragons Abound identifies bays is to walk along the coastline and find two spots on the coastline where the straight-line distance between the spots is less than the distance along the coastline between the spots. This is the sinuosity of the coastline between the two spots. By selecting a sinuosity limit and limits for the straight-line distance ...


28

Once an image is loaded off the disk and is formatted for rendering, it will use the same amount of memory regardless of whether that image was saved to disk using PNG, JPEG, or GIF. General rule of thumb: JPEG is a lossy format, and will degrade image quality in order to make the image smaller on disk. PNG, on the other hand, is a lossless image format, ...


25

My question is: why even bother using something like open gl, sfml, sdl when all you have to do is simply allocate some buffer, pass a bitmap and draw it to the screen? Short: Because its fast (OpenGL, DirectX). Long: You may think you can do this all yourself. Draw pixels to a screen. You might write a small library to draw shapes, like quads or ...


20

Broadly, the answer is "it depends." The way one would send particle updates is quite a bit different than the way you would send a series of GPU-skinned models. Vertex/Index Buffers In the general sense, though, everything these days is done with a VBO (vertex buffer object). The old immediate-mode API (glBegin/glEnd) is probably just implemented as a ...


17

That does not appear to be using any kind of specific flat-shading approach, at all. The shading is smooth, though the projected shadows are hard-edged, and the objects are not rounded. The specific lighting effect appears to be a combination of ambient occlusion (probably SSAO, "screen space ambient occlusion") which is what gives it that soft shadowing ...


16

In all the games I've worked on, the the Asset Creation Pipeline goes something like this: the concept artist (for levels/backgrounds/level models) or character artist (for models) will generate sketches for characters/levels/etc. usually multiple options are given to the creative director / lead art to decide which one they like better. The concept / ...


15

First, it helps to know that GPUs always evaluate fragment/pixel shaders on 2x2 blocks of pixels at a time. (Even if only some of those pixels ultimately need to be drawn, while others are outside the polygon or occluded - the unneeded fragments are masked out instead of being written at the end). The screenspace derivative of a variable (or expression) v ...


14

I'm currently making a game that has to run on a wide variety of display sizes and aspect ratios, and it hasn't been a very easy process. In addition, if you're making things in pixel art, and you want to keep the pixel art feeling while supporting many resolutions, you're walking into a world of pain, so be prepared. In my opinion, there are several things ...


13

GIF has a limited color palette. (255) You have to implement parsing and animating the GIF too. So there is not a advancement in time nor in format's technical aspects.


13

If we're willing to approximate the viewer as a cyclops whose single eye has a pinhole pupil (and this turns out to be a much better approximation than it sounds like - more on that later), then I'd argue that both projection methods you describe are correct. For different shapes of screen. Thinking of the problem angularly gives the correct result if the ...


11

The most contrasting color would be the color that is as far as possible from color X. It's easy to get it this way (assuming 0,0,0=black and 1,1,1=white -- floating point colors): y = rgb_color( x.r > 0.5 ? 0 : 1, x.g > 0.5 ? 0 : 1, x.b > 0.5 ? 0 : 1 ); The result is quite ugly though, so you might want to consider a few more things: ...


11

Just to distill Martin Sojka's excellent answer into something simple to apply, here's how to decide whether black or white text would have higher contrast on a given background color (R, G, B) in the sRGB color space: const float gamma = 2.2; float L = 0.2126 * pow( R, gamma ) + 0.7152 * pow( G, gamma ) + 0.0722 * pow( B, gamma ); boolean ...


11

I tried to duplicate the effect by using shader. Shader00 Center : https://www.shadertoy.com/view/XsXSz2 Shader01 Sides : https://www.shadertoy.com/view/4sXSz2 :) you could, as Byte56 said, set up three planes. A plane facing camera directly forward with Shader00, and then two plane with Shader01, perhapss as RandyGaul mentioned, top/bottom non uniformly ...


11

Here's how I would do this. First, make sure you have the object's UVs or world coords (which you can pass through from your vertex shader) available to you. If it's just a background, you could also just use fragment coords (gl_FragCoord). For instance, let's say we're using UV coords. A fragment shader with only: gl_FragColor = vec4(vec3(uv.x),1.0); will ...


Only top voted, non community-wiki answers of a minimum length are eligible