PDA

View Full Version : Reproducing fixed-function behaviour in a shader



Daniel Faken
08-18-2005, 10:27 AM
Hi,

Can anyone point me to a shader which reproduces the fixed-function (normal OpenGL) behaviour?

That is, transformation, clipping, culling, lighting.. ?

I'm presuming someone has done this, since it would be a great test if nothing else.

3DlabsDevRel
08-18-2005, 11:31 AM
The Developer Relations team at 3Dlabs has released a tool called ShaderGen (http://developer.3dlabs.com/downloads/shadergen/index.htm) that allows you to setup the fixed state and produces shaders on the fly to replicate it.

jide
08-18-2005, 12:34 PM
Originally posted by Daniel Faken:
Hi,

Can anyone point me to a shader which reproduces the fixed-function (normal OpenGL) behaviour?

That is, transformation, clipping, culling, lighting.. ?

I'm presuming someone has done this, since it would be a great test if nothing else.Clipping and culling are not part of the vertex shader process...

Daniel Faken
08-22-2005, 11:54 AM
Originally posted by 3DlabsDevRel:
The Developer Relations team at 3Dlabs has released a tool called ShaderGen (http://developer.3dlabs.com/downloads/shadergen/index.htm) that allows you to setup the fixed state and produces shaders on the fly to replicate it.Thanks for this tip.

I have a question, though:
How can one guarantee to reproduce the fixed-function pipeline when things like glMaterialfv() within glBegin()/glEnd() are not guaranteed to work?

(see page 64 of the OGL 2.0 spec -- its not guaranteed to update the Material-State fields (GLSL spec pg. 46) until glEnd() -- which is apparently why they are declared uniform instead of attribute.

Peter_dup1
08-22-2005, 03:07 PM
Interesting - I hadn't seen that in the spec, but I had hit that problem in practice when rendering a tristrip. The fixed functionality pipeline picked up the material changes across the tristrip, but my shaders didn't.
I guess you would have to resort to passing the material information through via your own uniforms - a bit like having to tell the shader which lights are active.

Peter

Korval
08-22-2005, 03:08 PM
How can one guarantee to reproduce the fixed-function pipeline when things like glMaterialfv() within glBegin()/glEnd() are not guaranteed to work?I'm not sure what you mean by this.

I thought glMaterialfv was flat out illegal inside a begin/end pair. And, since the spec told you that the results were not guarenteed (aka: undefined), you can't expect defined output. Ergo, don't do this.

Daniel Faken
08-22-2005, 04:12 PM
Originally posted by Korval:

How can one guarantee to reproduce the fixed-function pipeline when things like glMaterialfv() within glBegin()/glEnd() are not guaranteed to work?I'm not sure what you mean by this.

I thought glMaterialfv was flat out illegal inside a begin/end pair. And, since the spec told you that the results were not guarenteed (aka: undefined), you can't expect defined output. Ergo, don't do this.Nope; according to the OpenGL 2.0 spec, page 64, paragraph 3:

Material properties can be changed inside a Begin/End pair by calling Material. However, when a vertex shader is active such property changes are not guaranteed to update material parameters, defined in table 2.11, until the following End command.