Jump to content

  • Log In with Google      Sign In   
  • Create Account

Beginners: Fixed-Function vs. Shaders


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 rob_hays   Members   -  Reputation: 112

Like
0Likes
Like

Posted 08 July 2012 - 09:49 PM

Hello,

I'm currently going to college for computer science. Although I do plan on utilizing an existing engine at some point to create a small game, my aim right now is towards learning the fundamentals: namely, 3D programming. I've already done some research regarding the choice between DirectX and OpenGL, and the general sentiment that came out of that was that whether you choose OpenGL or DirectX as your training-wheels platform, a lot of the knowledge is transferrable to the other platform. Therefore, since OpenGL is supported by more systems (probably a silly reason to choose what to learn), I decided that I'm going to learn OpenGL first.
After I made this decision to learn OpenGL, I did some more research and found out about a dichotomy that I was somehow unaware of all this time: fixed-function OpenGL vs. modern programmable shader-based OpenGL. At first, I thought it was an obvious choice that I should choose to learn shader-based OpenGL since that's what's most commonly used in the industry today. However, I then stumbled upon the very popular Learning Modern 3D Graphics Programming by Jason L. McKesson, located here: http://www.arcsynthesis.org/gltut/
I read through the introductory bits, and in the "About This Book" section, the author states:

"First, much of what is learned with this approach must be inevitably abandoned when the user encounters a graphics problem that must be solved with programmability. Programmability wipes out almost all of the fixed function pipeline, so the knowledge does not easily transfer."


yet at the same time also makes the case that fixed-functionality provides an easier, more immediate learning curve for beginners by stating:

"It is generally considered easiest to teach neophyte graphics programmers using the fixed function pipeline."



Naturally, you can see why I might be conflicted about which paradigm to learn: Do I spend a lot of time learning (and then later unlearning) the ways of fixed-functionality, or do I choose to start out with shaders? My primary concern is that modern programmable shaders somehow require the programmer to already understand the fixed-function pipeline, but I doubt that's the case.
TL;DR = As an aspiring game graphics programmer, is it in my best interest to learn 3D programming through fixed-functionality or modern shader-based programming?

Edited by rob_hays, 08 July 2012 - 09:51 PM.


Sponsor:

#2 MJP   Moderators   -  Reputation: 11352

Like
7Likes
Like

Posted 08 July 2012 - 10:49 PM

Going for fixed-function first might make things initially a bit easier, but personally I think it would mostly be a waste of time. The fixed-function pipeline just has too much old cruft and too many quirks that are the product of old hardware that no longer exists. I think the better path would be start with really simple shaders, and start building up functionality in the context of a shader-based framework. This will ensure that you start out learning how modern GPU's actually work, instead of getting coming to false conclusions due to using a severely outdated abstraction of graphics hardware.

Edited by MJP, 09 July 2012 - 11:56 AM.


#3 rnlf   Members   -  Reputation: 1123

Like
1Likes
Like

Posted 09 July 2012 - 12:22 AM

In general I'd concur with MJP in that you learn a lot of useless (and by today's standards extremely inefficient) stuff if you go the fixed-function pipeline way.

BUT if you are not yet familiar with vector maths or your programming language of choice (C or C++ is suppose), you might have a hard time getting your first triangle to render using modern OpenGL. Using the fixed function glTranslate/Rotate and glBegin and glEnd is only a few lines of source code while setting up a vertex and fragment shader, vertex buffers and matrices may (!) be a huge demotivator. If you only want to learn OpenGL for the very basics, I personally think it is fine to use old-school GL.

If you think you have the stamina to fight your way through some setbacks and maybe want to write production quality OpenGL code anytime in the future, go the shader way. If you are still building your coding skills or just want to learn the math behind 3D programming, go the fixed function way, but keep in mind that you will have to re-learn a lot of things if you ever decide to write your own serious GL code.

my blog (German)


#4 scniton   Members   -  Reputation: 252

Like
2Likes
Like

Posted 09 July 2012 - 02:44 PM

I think rnlf makes the shader route sound more daunting than it really is. There is no need to try to create a pure opengl 3.0 non-deprecated demo on the first try.

There is a natural progression you can take to go from pure fixed pipeline to pure non-deprecated functionality e.g.:
  • Start with a simple opengl "Hello world" style program
  • Change it so that it uses the programmable pipeline using trivial shaders.
  • Convert it to use vertex arrays.
  • Convert it to using vertex buffer objects
  • Create your own matrix management routines along side the fixed pipeline ones (this allows you to verify your routines)
    E.g. Using glLoadMatrix to easily switch between the matrices used.
  • Modify the shader so that you upload the matrix using something like glUniformMatrix* and only use your matrices*
  • etc.
* If you are aiming for pure non-deprecated.

There are some basics you'll want to learn regardless of which route you choose: colors, normals, textures, transformations, etc.
Whether you learn these basics using the fixed function pipeline or shaders won't matter, it is a small step to go from one to the other.

This being said, once you understand the basics there is no reason to deal with the fixed function pipeline.
Beyond the basics, IMO, effects become more complicated to implement using the fixed function pipeline, and sometimes require dealing with opengl extensions (not a big deal, but more annoying than not having to do it.)
Stop twiddling your bits and use them already!

#5 rob_hays   Members   -  Reputation: 112

Like
0Likes
Like

Posted 09 July 2012 - 04:12 PM

I think rnlf makes the shader route sound more daunting than it really is. There is no need to try to create a pure opengl 3.0 non-deprecated demo on the first try.

There is a natural progression you can take to go from pure fixed pipeline to pure non-deprecated functionality e.g.:

  • Start with a simple opengl "Hello world" style program
  • Change it so that it uses the programmable pipeline using trivial shaders.
  • Convert it to use vertex arrays.
  • Convert it to using vertex buffer objects
  • Create your own matrix management routines along side the fixed pipeline ones (this allows you to verify your routines)
    E.g. Using glLoadMatrix to easily switch between the matrices used.
  • Modify the shader so that you upload the matrix using something like glUniformMatrix* and only use your matrices*
  • etc.
* If you are aiming for pure non-deprecated.

There are some basics you'll want to learn regardless of which route you choose: colors, normals, textures, transformations, etc.
Whether you learn these basics using the fixed function pipeline or shaders won't matter, it is a small step to go from one to the other.

This being said, once you understand the basics there is no reason to deal with the fixed function pipeline.
Beyond the basics, IMO, effects become more complicated to implement using the fixed function pipeline, and sometimes require dealing with opengl extensions (not a big deal, but more annoying than not having to do it.)


Thanks for the the responses everyone.

I do have a grasp on 3D vector math and basic linear algebra, but is there some intermediary skill I'm supposed to learn about before jumping into OpenGL? I guess what I mean is if I'm pretty well-versed in C++ and those maths, are there any other bodies of knowledge that would be considered prerequisite to being successful in OpenGL? I won't say I'm an expert in C++, but I do know my way around it. Should I hold off on OpenGL until I have measurable experience with C (as I understand it, GLSL is essentially C-like), or is C++ knowledge enough to get me started in OpenGL?

Thanks

#6 rnlf   Members   -  Reputation: 1123

Like
0Likes
Like

Posted 09 July 2012 - 10:57 PM

Of course scniton, you're entirely right. Being a purist myself, I totally ignored the fact, that you don't have to use core profile.

rob_hays, just start out. If you need anything you don't know yet, you will sooner or later stumble upon it. By then, you will have understood the more basic stuff and it'll be easier to learn whatever you need then. Especially with the fixed function pipeline-parts you need (at first) almost no knowledge of vector maths.

my blog (German)





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS