Hot answers tagged

139

"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 concepts should be ...


64

A strong argument for using spritesheets is that the number of available textures on a graphic card can be limited. Therefore your graphics library would constantly have to remove texture and re-allocate textures on the GPU. It's much more efficient to just allocate a large texture once. Also consider that texture sizes are usually power of 2. So if you ...


62

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 ...


46

I think you will understand their purpose better with a sample. By reading the comments you will understand how VAOs are used. // BEGIN INITIALIZATION // Define some vertex data struct Vertex { GLfloat position[3]; GLfloat texcoord[2]; }; Vertex vertexdata[NUM_VERTS] = { ... }; GLubyte indexdata[NUM_INDICES] = { 0, 1, 2, ... }; // Create and bind a ...


40

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 ...


37

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 ...


36

I'd say the arguement to use would be the ability to render multiple things in a single draw call. Take for example font rendering, without a spritesheet you'd need to render each character with a separate texture swap followed by a draw call. Throw them into a spritesheet and you can render entire sentences with a single draw call (the difference characters ...


33

A wide-angle lens should not behave differently than other regular lens models. They just have a larger FOV (in the D3DXMatrixPerspectiveFovLH sense -- I'm assuming you use DirectX), or larger left/right and bottom/top values (in the OpenGL glFrustum sense). I believe the really interesting part lies in modeling the fisheye lens. There's Fisheye Quake that ...


33

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 ...


28

The number of textures that can be bound to OpenGL is not 32 or 16. It is not what you get with glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &texture_units);. That function retrieves the number of textures that can be accessed by the fragment shader. See, each shader has its own limit of the number of textures it can use. However, there is also a total ...


28

I don't buy the argument that it's easier to start with the fixed-function stuff. It might be the case that the fixed-function lets you do certain things with less code - in fixed-function OpenGL, for instance, you can get some very basic lighting/shading going by doing glEnable(GL_LIGHTING) and a few other calls. The trouble is that as soon as you want ...


27

The simplest way to achieve the effect is to draw a bunch of particles in Additive mode, so when they are superimposed their color values are added up, becoming brighter. Some samples: http://www.youtube.com/watch?v=_sx0KDO-ZbA http://www.youtube.com/watch?v=-OZOdQHLiiI


24

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 ...


23

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, ...


22

Everything, really. The only benefit to object-space normals is simplicity. They're easier to use. Tangent-space normals require a tangent-space basis, but offer: The ability to use the same texture for different surfaces. Object-space normal maps can only ever be used on the surface for which they were created. By regularizing normals in tangent-space, ...


21

My answer is always the same: if you haven't written one before, write a raytracer. You'll have to deal with optimization structures, numerical precision, and all sorts of other issues, but you'll also work directly with the mathematics of light in a way that you rarely do when dealing with all the hacks and approximations that make up a production real-...


19

I'm going to say yes, to your question as phrased, but with important caveats. Yes, you need to know how to sort things in programming game development. There's lots of sorting goes on, in a wide variety of situations. No, you don't need to know the details of how all (or even many) the various sorting algorithms work, it's almost always sufficient to look ...


18

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

My friend is working on a side-scrolling shooter in XNA that uses similar effects (here's a video of an early test). He wrote a blog post about the technique that you might find helpful. He's also usually hanging out in the #graphicschat IRC channel on irc.afternet.org (name's Drilian) and could probably help you out.


16

This effect is particularly common in games that make use of cel shading effects, but is actually something that can be applied independently of the cel shading style. What you are describing is called "feature edge rendering," and is in general process of highlighting the various contours and outlines of a model. There are many techniques available and ...


15

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 ...


14

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 / ...


13

It depends if you want to produce finished games or just learn. If you actually want to make a game, making your own game engine from scratch just isn't feasible in any real timeframe unless you have an very narrow, simplified game and even then your still looking at quite a while. Making a 3D game engine from scratch is a huge undertaking. They have heaps ...


12

GPUs generally process a number of pixels in parallel these days, so I expect that it can make good use of all these units even with simple shaders.


12

There's really no need to store memory for every particle and animate each particle separately. You can do it procedurally by reconstructing the particle position during drawing by using the classic physics equation. s = ut + 1/2.a.t^2 A simple example (without constant acceleration of particles): void drawExplosion(ExplosionParameters& s) { Random rng; ...


12

If you are using OpenGL, the OpenGL FAQ section 9: Transformations covers exactly how to do this. And no, it doesn't involve raytracing, as that's understandably a very inefficient (but high quality) way to accomplish this. 9.170 How do I render a mirror? Here is essentially what the FAQ entry says, and the example code demonstrates: Set up a reflected ...


12

In my OpenGL ES 2.X engine, i compute the MVP matrix (Model View Projection) on CPU Side and inject it in vertex shader. The Orthogonal projection is a 4*4 matrix. When i have the MVP, i inject it in the vertex shader with: mMvpLoc = getUniformLocation("uMvp"); glUniformMatrix4fv(mMvpLoc, 1, false, mMvp.pointer()); The mMvp is my matrix 4*4 on CPU side....



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