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.

In more than just 1 occasion, i read about 2 ways of doing a light's system in OpenGL:

  • normal way? i don't know how to call this one
  • with the shaders ( GLSL )

The problem is i don't get the difference in terms of rendering performance and system usage, what are the pros and cons for each one ?

Thanks.

share|improve this question
1  
Very similar question to gamedev.stackexchange.com/questions/31919/… –  Nathan Reed Aug 8 '12 at 2:49
    
the "normal" way is probably referring to the old fixed function pipeline. –  melak47 Aug 8 '12 at 11:00

2 Answers 2

up vote 4 down vote accepted

There are the fixed function and programmable shader pipelines.

This is much bigger than just lighting, chances are your learning a whole bunch of other outdated stuff. The following are some common functions that are now deprecated:

  • glBegin(...)
  • glEnd()
  • glVertex*
  • glNormal*
  • glColor*
  • glTextCoord*
  • glMultiTexCoord*
  • glLoadIdentity*
  • glMatrixMode(GL_MODELVIEW/GL_PROJECTION/...)
  • glRotate*
  • glTranslate*

If your learning the fixed function stuff your learning out of date programming techniques. They are easier but all of which would have to be unlearned. I recommend you look at how your learning OpenGL and look for some modern tutorials.

Take a look at my post on the gamedev stackexchange. It covers learning the new stuff.

Specifically for lighting. Fixed function is easier but has the following problems: * It isn't per-pixel lighting so the quality is much worse. * It's not supported at all in OpenGL ES 2.0/3.0 or WebGL * No way to do things like bump/normal mapping. Specular reflection textures (Making part of a texture shiny and reflect more light). * Your probably going to need shaders for other effects (for example shadows), once you use any shaders you loose the fixed functionality and must reimplement it anyway. * No control over the shading algorithms other than some basic properties. * It's been deprecated/removed in the new versions of OpenGL 3+. Basically it's the out of date method and should be avoided.

About the only use fixed function has now days is if you need to target OpenGL versions before 2.0 or OpenGL ES 1.x (for the older iPhones).

Programmable shaders do require more work and understanding.

  • Firstly you have to understand the OpenGL shader API. How to compile and link shaders (not to hard).

  • Also you have to understand how to communicate with them. How will you represent your lights in structures and upload them to the shaders.

  • And you have to learn the GLSL language (it's C like so not to hard).

  • Finally you have to understand the actual algorithms used in shaders.

For vertex shaders it's how a Model, View and Projection matrix combine together to turn the 3D coordinates you give vertices into the 2D coordinates you see on your flat screen.

For the fragment/pixel shaders you have to understand the shading algorithms. Blinn, Phong or whatever. How the angle of the camera combines with the normals on the surface to produce shading. Your also going to have to do stuff like texturing.

I think it's best to just start out learning the shader pipeline. You can rely on some deprecated functionality but it's best if you just use the stuff OpenGL does by default rather than actively learning old stuff.

share|improve this answer

I want to answer my own question because i think that after reading some article about it, considering the kind of hardware available on the market, there is no point that can lead me to adopt a fixed pipeline instead of a programmable pipeline based on the shaders.

So even if you are targeting an hardware that can let you choose between a fixed pipeline or a programmable pipeline you probably want to do everything with a programmable pipeline and just avoid the fixed pipeline that is something from the past and simply can't unlock all the potential of a modern GPU.

share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.