0

If i use opengl 3.2+ with compatibility context and have a fragment shader, is it necessary to have a vertex shader? I would like to know if per vertex lighting calculation and other per vertex calculations can be done by the fixed function pipeline and i can just use the fragment shader.

Also what implications would this have for per-vertex attribute binding locations?

genpfault
  • 51,148
  • 11
  • 85
  • 139
user968049
  • 25
  • 1
  • 2
  • 8

1 Answers1

2

if per vertex lighting calculation and other per vertex calculations can be done by the fixed function pipeline

They can be done if you use fixed pipeline lights.Otherwise, part of it (like transformed normals,uv's and positions) must be computed elsewhere before being passed to the fragment shader.This "elsewhere" is called vertex shader.So yes,if you don't use fixed pipeline lightning system you must use vertex and fragment shader to process it.

Also,if you use fixed pipeline lightning you can still use shaders where you can access fixed light and material properties.But I see no point doing so unless you wish to break the defaul behavior.

Michael IV
  • 11,016
  • 12
  • 92
  • 223
  • is there any document online to support this? -thanks – user968049 Sep 30 '13 at 18:32
  • If you don't rely on what people say here then why do you ask? – Michael IV Sep 30 '13 at 19:37
  • @user968049: The definitive source for many of these questions are the specifications found at: http://www.opengl.org/registry/ - however, they are very lengthy documents and not something most people can simply skim through. I try to make a point to quote the relevant part of the specification whenever asked, but this is such a simple question that it really is not worth the time in this case (no offense). Fixed-function is provided by the compatibility profile, that is arguably its most important purpose. Take a look at http://www.opengl.org/registry/doc/glspec32.compatibility.20091207.pdf – Andon M. Coleman Oct 02 '13 at 05:31
  • @user968049 As for the location of vertex attribute bindings, when you use the fixed-function pointers (e.g. `glTexCoordPointer (...)`) you _must_ use the associated GL pre-declared variable in your vertex shader (e.g. `gl_MultiTexCoord0`). It is a violation of the specification for the fixed-function pointers (with the exception of vertex position, which is always 0) to alias to a generic vertex attribute location. NVIDIA is notorious for violating this specification, but most other vendors enforce it strictly. – Andon M. Coleman Oct 02 '13 at 05:38