Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Choice between color and materials

  1. #1
    Newbie Newbie
    Join Date
    Jul 2018
    Posts
    1

    Choice between color and materials

    Hello everybody:

    I am puzzled with OpenGL GLSL recently on using color or material in OpenGL Programming. The problem is : which should be used vertex color or vertex materials, or both?

    Previously, I use the color for each vertex. However, it seems that by using material properties we could get a more realistic rendering for viewing. And I realized some good reanding result by using material in my program. However, when I was reading the red book (Programming Guide), I noticed that the book is using both color and material property for rendering when consider multi-lights and multi-materials. I am wondering which is best/correct way to use? Since I have the material property why I need the color for each vertex? Or it is just an example to show that the current GLSL language is so powerful to realize whatever you want by programming ?

    Best wishes!

    Jacky

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,856
    If GL_LIGHTING is disabled, each vertex has the colour specified via glColor() or glColorPointer(); materials and lights have no effect.

    If GL_LIGHTING is enabled, each vertex' colour is calculated based upon the material and lights. Vertex colours can still be specified by glColor() or glColorPointer(), in which case they affect some of the material colours according to the glColorMaterial() setting.

    But all this is ancient history. Modern code tends to perform lighting calculations on a per-fragment basis using shaders, with material properties (at least the diffuse colour, sometimes others) stored in textures.

    Even before shaders, fixed-function lighting was never particularly useful.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •