I'm doint this:
gl_FrontColor = gl_FrontLightModelProduct.sceneColor +
                   ambient * gl_FrontMaterial.ambient +
                   diffuse * gl_FrontMaterial.diffuse; 

Won't this have the same performance with a scene that has 100 materials as
opposed to one that has 1 material?  It is difficult for me to do that
benchmark.  I'm just trying to decide if I have to tell modelers to keep the
number of materials down.


Zach

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paul Martz
Sent: Thursday, January 04, 2007 18:17
To: 'osg users'
Subject: RE: [osg-users] Materials with shaders

If your shader is picking up the values set by your glMaterial commands,
then you still have the overhead of calling glMaterial to change the
material parameters. glMaterial is complex, and is more expensive to process
than most other state commands. This is why glColorMaterial was created, so
that apps could change material properties with the comparatively
inexpensive glColor command.

I advise benchmarking it to see if the cost is so great as to be
prohibitive.

Paul Martz
Skew Matrix Software LLC
http://www.skew-matrix.com
303 859 9466



> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Zach 
> Deedler
> Sent: Thursday, January 04, 2007 4:03 PM
> To: 'osg users'
> Subject: RE: [osg-users] Materials with shaders
> 
> Hi Robert,
> 
> Yes, materials in the contexts of shaders.  I'm not changing uniforms 
> or anything.  Just one shader shades pretty much everything.  The 
> shader uses the material properties.  For example it uses the specular 
> color and shades appropriately.
> 
> Would having 100 materials with different specular colors perform any 
> less than having 1 material when using one shader?  I can't see why it 
> would.
> 
> 
> Zach
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Robert 
> Osfield
> Sent: Thursday, January 04, 2007 11:14
> To: osg users
> Subject: Re: [osg-users] Materials with shaders
> 
> Hi Zach,
> 
> What do you exactly mean by materials in the contexts of shaders?
> GLSL exposes the glMaterial parameters in the form of built in 
> uniforms but doesn't actually implement any lighting for you so the 
> parameters are irrelevant unless you directly use them yourself.
> 
> If you are using the built in uniforms then you are likely you should 
> ask yourself whether you should be using custom uniforms instead, 
> custom uniforms would allow you to pass in just the data you require
> so might be of benefit.   Updating uniforms may force a driver
> internal relink of the program and reload of of it to the GPU along 
> with associate flush of the GPU pipelines.  This means that change 
> uniforms can be quite heavy, just like fixed function glMaterial is 
> not something you want to change regularly.
> 
> Robert.
> 
> On 1/4/07, Zach Deedler <[EMAIL PROTECTED]> wrote:
> > QUICK QUESTION
> > Is it bad to have many different materials if you are using shaders?
> >
> > THOUGHTS
> > I mean with fixed-functionality shading, I was under the impression 
> > that many different materials causes many state changes.
> >
> > With shaders though, it seems as though all my materials
> can be shaded
> > using the same shader, and thus there will be no state changes.  Is 
> > this
> true?
> > Will I be able to have a bunch of materials without
> performance decay
> > when using one shader?
> >
> >
> > Zach
> >
> > _______________________________________________
> > osg-users mailing list
> > [email protected]
> > http://openscenegraph.net/mailman/listinfo/osg-users
> > http://www.openscenegraph.org/
> >
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://openscenegraph.net/mailman/listinfo/osg-users
> http://www.openscenegraph.org/
> 
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://openscenegraph.net/mailman/listinfo/osg-users
> http://www.openscenegraph.org/

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to