Jump to content
  • Advertisement
Sign in to follow this  
AndreiVictor

OpenGL Fixed Function vs. Shaders

This topic is 4111 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all. I'm a noob in 3D graphics programming and I'm just a beginner in OpenGL. I'm in the point of making an engine for a game that I'll make. People say that I should abandon fixed functions and proceed with shaders. Especially now that they say when we use fixed functions, in the background it generates shaders anyway. But, my question is, how do I determine if something is fixed function or shader-based? Again, I am a beginner and I've been using simple OpenGL functions like glBegin, glVertex**, glColor, glLighting, etc. So I can't differentiate what fixed function really is and I've just read about GLSL. Thanks for your help.

Share this post


Link to post
Share on other sites
Advertisement
That's like asking what the difference is between C++ and Basic...

FF effects are done using API commands. Shaders are special programs written in a shading language and compiled seperately from app code (usually at runtime). Normally they are stored in individual text files.

Share this post


Link to post
Share on other sites
Quote:
Original post by AndreiVictor
But, my question is, how do I determine if something is fixed function or shader-based? Again, I am a beginner and I've been using simple OpenGL functions like glBegin, glVertex**, glColor, glLighting, etc. So I can't differentiate what fixed function really is and I've just read about GLSL.

Shaders can replace pretty much all of the processing done on individual vertices and pixels
  • as they're actually drawn. This replaces the fixed function stuff like lighting, shading, fog, texture blend modes, texture sampling, and the transformation of vertices.

    Things common to both are resource creation (eg. texture creation) and geometry submission (how you actually send the vertices to be drawn, eg. glBegin, glDrawArrays).

    If you're a beginner, then theres no reason why not to continue using the fixed function - you can get a lot done with it without worrying too much about the exact implementation of some of the lower levels, and switching to shaders once you've got a good grasp of the basics isn't too hard.

  • Ok, the correct term is 'fragments' but lets not confuse the issue.

    Share this post


    Link to post
    Share on other sites
    I'd strongly suggest you get yourself acquainted with the Computer Graphics Pipeline. IMHO, the graphics pipeline is the second most important topic every graphics programmer must master (mathematics being the first although you don't need a PHD in math to get started). There are some good books written on the topic.

    I agree with OrangyTang that continuing with the fixed function pipeline is probably a better choice if you're new to computer graphics. It can save you a lot of unnecessary trouble. You won't be able to get much out of shaders without a firm background anyway. It's a good idea not to rush. If I were you, I'd spend more time on the theoretical part at this point and only worry about shaders when I had a firm theoretical background. If you insist to move on to shaders though, check this and this. Scroll down the page and you'd find some tutorials on shaders.

    Share this post


    Link to post
    Share on other sites
    Although frankly the fixed func commands, particulary in D3D are non-intuitive and probably more confusing than a simple shader. Texture Stages states and so on are among the most arcane API inventions ever developed.

    Share this post


    Link to post
    Share on other sites
    Just to note: shaders can be very beneficial to those beginning to learn about 3D graphics because they can help to enforce the mathematical concepts and to visualize them in code. Most graphics algorithms can be directly translated into shader code in a clearer manner that the fixed-function pipe, on top of being more flexible.

    Share this post


    Link to post
    Share on other sites
    In theory, fixed function is simpler and teaches good concepts. In practice, they're obfuscated and crufty with lots of legacy scariness to worry about, and they don't teach anything because they hide all the theory.

    At least with shaders, you know exactly what's going on. Sadly, I don't know any good tutorials that say "here's how to get started with the 3D pipeline with shaders" - otherwise I'd recommend that.

    Share this post


    Link to post
    Share on other sites
    I'm a beginner with opengl as well (well, I began a few years ago, but never spent much time on it). I don't know if you should begin with shaders or with ff, what I can tell you is that:
    -shaders are much more flexible, but you need to handle the details, as the lighting equation and texture composition. If you already know the math behind it (a simple phong model would be enaugh, i think) then go with shaders.
    -FF is easy to use, but no longer used. It really depends upon what you plan to do with the engine.
    Furthermore, I think that there is another thing to add: AFAIK the FF will be removed by the upcoming OpenGL 3.0, so you may be forced to switch to shaders soon anyway. I don't know the current state of OpenGL ES.

    I'm not in the position to give you suggestions against those given by more experienced people, but there is another possibility: starting with shaders, but using a couple of simple ones taken from internet. This way you learn how to interact with shaders, without having to learn how to program them (at the moment).
    Using FF requires you to learn a lot of extensions that might be no longer useful in a couple of months.
    Ignoring FF doesn't mean that you can ignore all the stuff about the rendering pipeline, of course...

    These are just opinions though.

    EDIT: I've just read the latest posts, and I agree that FF is simpler that shader on sonething, but shaders are easier on others. In fact, I remember that texture stages were not so easy to manage :-)

    EDIT 2: I strongly suggest you to wait for the first tutorials and books about OGL 3 to appear before designing your engine...

    Share this post


    Link to post
    Share on other sites
    Thank you all for the input.

    The reason I asked this is because I also heard about that same news that there's a big transition on OpenGL 3.0 that deprecates Fixed Functions (FF). So, as a beginner in Computer Graphics and theories on graphics pipeline, I am trying to make sure of what path I should take.

    But first, I want to make sure I'm picturing right what Fixed Function (FF) and Shaders are through this analogy: Say if Computer Graphics is a "game", then FF is all hard-coded game commands, while Shaders are like compiled game script files that are loaded by the program at runtime. Am I picturing it right?

    Share this post


    Link to post
    Share on other sites
    Quote:
    Original post by AndreiVictor
    But first, I want to make sure I'm picturing right what Fixed Function (FF) and Shaders are through this analogy: Say if Computer Graphics is a "game", then FF is all hard-coded game commands, while Shaders are like compiled game script files that are loaded by the program at runtime. Am I picturing it right?



    It seems to me that you quite got it. The best I can describe them is that FF offers a limited number of function that you can call with parameters. These functions covers lighting, texturing, transformations, buffers and so on (there are a lot of extensions).
    Shaders, on the other side, give you the access to a much low level enviroment. Not only you can choose how do you want OGL to compute the lighting at the vertices (flat? Gouraud?) but you can write the very lighting code (down to reproduce custom BRDFs). You can decide pretty much everithing with lights, textures and now geometry with DX10 (thought I don't know the geometry shader).

    Another analogy is the following: FF is what you can do with an application (say 3dsmax). Shaders is what you can do with its SDK (thousand of plugins and so on).

    Share this post


    Link to post
    Share on other sites
    Sign in to follow this  

    • Advertisement
    ×

    Important Information

    By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

    GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

    Sign me up!