Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm starting to learn OpenGL by creating a pure 2D game.

I have to decide on the format of the Vertices. Do I need a normal component? Or is this for a 2d component not needed?

My gut feeling says I won't need it since everything is flat. But perhaps I need it for some shader or other thing I don't see yet.

share|improve this question
add comment

6 Answers

Does one need normals for a 2D game? No. You don't even need normals for a 3D game if you're not going to bother with lighting. However, normals and lighting very much can apply to 2D games. You just go about it in a different way. Rather than explicitly defining a 3D normal vector that aligns with your vertex, you can define a normal map that lines up with your 2D graphics. This lets you have incredibly epic lighting even in a 2D game.

share|improve this answer
add comment

Strictly speaking, the normal component will be ignored if you've turned off lighting. If you're able to write your own shaders in whatever language/toolkit you're using then you can make absolutely sure they're not used.

share|improve this answer
    
If I turn off lighting, I still can use colors on my vertices right? –  user6073 Mar 13 '11 at 16:02
    
You should be able to do that yes, as long as you've enabled glEnableClientState(GL_COLOR_ARRAY) (remember to disable GL_NORMAL_ARRAY) –  Luther Mar 13 '11 at 16:38
add comment

You don't need normals unless you're doing lighting simulations. They're fairly trivial to add in once you need them, compared to the actual difficulty of writing lighting shaders.

share|improve this answer
add comment

If you are drawing your triangles in a 3D space, and then viewing everything from the side to make it look 2D (which is what you should be doing), then you'll need normals in order to be able to draw lights over top of your quads.

If you don't light anything, then you won't need normals.

My recommendation since you're asking this question, is to omit normals for now, regardless of what your plans are later. It won't be hard to add them later if you need them.

share|improve this answer
add comment

Only you know whether you'll need normals in a 2d game. They may make sense - DOOM, for instance, had normals even though it was a 2d game (yes yes, it looked pretty 3d, but technically it was still a 2d game).

One good reason for having normals in a 2d game would be to be able to check whether you're inside or outside some shape. It may also accelerate wall collision response (knowing the direction to push objects out of the wall).

There's no reason to give the normals to OpenGL or whatever rendering package you use if it doesn't need it for anything (like the lighting pretty much everyone else has pointed out).

share|improve this answer
add comment

What sort of game is it? If you have a top-down perspective, normals might come in handy for strafing movement of your characters (you know, shifting position along the normal of the direction the character is facing)

Normals are also useful for quite a range of steering behaviours. But a link says more than thousand words: http://www.red3d.com/cwr/steer

share|improve this answer
    
Pretty sure the OP is specifically asking about normals for the verts. Not talking about velocity vectors and that kind of thing. –  Tetrad Mar 15 '11 at 14:07
    
Pretty sure the OP is specifically asking about normals for the verts or (quote start) other thing I don't see yet (quote end) ... –  Jan Mar 15 '11 at 16:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.