New LightState and MaterialState features

Light State now includes the ability to set local viewer and separate specular flags (see GL specs for detailed info on those.)  These flags are very useful for specular highlights.



Material State now includes the ability to set which face the material is applied to.  More importantly, you can now use Color Materials.  If you turn this on (it’s off by default - use materialState.setColorMaterial(int)) then material colors are picked up from the Geometry object’s color buffer.  So now you can use lights and specify colors per vertex.  Sweet!  :stuck_out_tongue:



These additions (except the Material Face, which I popped in while patching) are courtesy Three Rings.

some humble comments from my side:



1

Does the "courtesy" mean that we have to pay attention on licence fees or else when using the new methods?



2

In the OpenGL red book (2.0) I read:

"You should use glColorMaterial() whenever you need to change a single material parameter for most vertices in your scene."

It also describes that calls to change in materials attributes for lighting are very expensive when done for every triangle.

Did you see any performance break downs?



3

seperate specular highlights rock - texture+highlights without any shader programs.

local viewer - never checked that "i have a candle and walk around" thing, how is it?

Ogli said:

Does the "courtesy" mean that we have to pay attention on licence fees or else when using the new methods?


It was released under the BSD licence, which puts it under the public domain. They therefor forfeit all wright's to fees and controll of the code.

As Badmi says, jME has a BSD license as does contributions made to it.



In my understanding, the red book is basically saying to use glColorMaterial in conjunction with glColor to do material changes across a mesh rather than sending a few triangles, calling glMaterial, sending a few more triangles, calling glMaterial, etc…  jME had only one call to glMaterial per mesh previously though, so this issue does not really apply.  With the change though, jME can now shift material colors across a mesh.  To your question though, performance should not be an issue.



Local viewer is about specular highlights using eye position for reflection angles rather than a fixed point along the z axis.  This means as the camera moves around, the specular highlights will be accurately calculated.  It's not really about moving lights therefore, but a moving camera.

fine.



to have new abilities is always nice. thanks for the new stuff!  :mrgreen:



for local viewer there is an image in red book, color plate 13.

the effect might be noticable when objects are very near and at the left/right border, i think.

the image also shows that there are problems with highlights + goraud-shading + low tesselation.