Tag Info

Hot answers tagged

113

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


61

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


34

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


34

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


30

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


28

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


25

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


25

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


18

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

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


17

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


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.


14

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


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

It's probably a bad idea to create new classes for each type of geometry you're going to support. It's not very scalable or maintainable. Additionally, the class design you appear to want now seems to conflate the tasks of managing the geometry itself and the instance data for that geometry. Here's an approach you can take: Create two classes, Mesh and ...


12

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


11

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


11

Each draw call has a certain amount of overhead. By using sprite sheets you can batch the drawing of things that aren't using the same frame of an animation (or more generally, everything that's on the same material) greatly enhancing performance. This may not matter too much for modern PCs depending on your game, but it definitely matters on, say, the ...


11

Draw your entire scene, except highlighted objects. Draw the objects you want to highlight, in pure color, sorted from back to front, and with a small scale applied (1.05f - 1.1f). Draw the final objects, again, from back to front. For extra eye-candy, try drawing the contour pass to a separate render target and apply a small blur, then blend this texture ...


11

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


10

In such highly dynamic environment, such as computer game scene is, what is the point of using VBOs, if the VBOs would need to be constructed on per-frame basis anyway? If you are reconstructing the vertex data for every object every frame, you're doing it wrong. Or at least, you're probably doing it inefficiently. Moving objects in a scene ...


10

Most "shader effects" like filtering and normal mapping have very little in common that could be considered building blocks between effects. 2D filtering and normal mapping aren't any more difficult or advanced than each other, for example, and the same is true of many effects with only a few notable exceptions (the various flavors of shadow mapping come to ...


10

Short answer: No. You can "be" an indie game developer without knowing anything about graphics. More practically, it depends on the kind of graphics you want in your game. If you want "fancy" graphics, meaning graphics that require whatever knowledge you're referring to, then someone has to know it. You either know it yourself and write the code, or you ...


9

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


9

I think of this as Constructive-Solid-Geometry (CSG). Hopefully you can find some help here. http://www.alsprogrammingresource.com/csg.html http://createuniverses.blogspot.com/2009/09/qtcsg-constructive-solid-geometry.html http://www.nigels.com/research/ Also search google for Constructive Solid Geometry as a start. HTH


9

Difficult to tell from the video exactly what you mean, but the simplest method of doing a sprite-based motion blur would just be to render the sprite several times, with some form of translucency. You could buffer the previous positions for use as the trail, or you could use a small time-step in the animation to render sub-frames. From the video in ...


9

FastLSM is sorta like what you're after. Alec has also made 2D game engine based on deforming lattice (instead of voxels as in FastLSM). It's called Physical. Look at the demo asteroids style game to see what can be done and the performance. Alec also built a full game using physical called Sopwith IV. I never played Sopwith IV, but I spent plenty of ...



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