Noob question re light/material states

Hi



I've been trying to sort out some of the lighting in my scene, everything seemed too bright. I disabled the light in my light state, and instead of everything going black, it went grey. I assumed there was some global ambient set, so I forced it to black, but stuff is still grey. I'm using BasicGameState and VariableTimestepGame as my base classes for the framework. I thought it might be the material state on my imported models, but I've noticed that the same is true of Line objects, no material state is applied to them as I normally have them lighting disabled as they are debug information.



Can anyone thing of anything obvious I should check, or point me in the direction of the default light state that I've missed whilst hunting around?



Cheers



Endolf


Are you sure it's not defaulting to "no light" mode (where it doesn't apply darkness or lightness) because you have no lighting in the scene?

Hi



I think so. I have a toggle key for my light state, when I disable it the whole screen lights up as all the objects in the scene have materials, when lighting is disabled it goes to vertext colours, which IIRC is default of white, which then combined with the texture gives the texture colours. With my diagnostic lines, the vertext colours are red, green or blue (original huh? :)) and they turn those colours.



When the light state is reenabled (it has had global ambient set to black, and the 1 light in it is ambient, specular and diffuse all black) the objects and lines go grey, not black.



Endolf



My light state is as follows for testing this

lightState = DisplaySystem.getDisplaySystem().getRenderer().createLightState();
      
      PointLight light = new PointLight();
      //light.setAmbient(new ColorRGBA(0.3f,0.3f,0.3f,1.0f));
      //light.setDiffuse(new ColorRGBA(0.3f,0.3f,0.3f,1.0f));
      //light.setSpecular(new ColorRGBA(1.0f,1.0f,1.0f,1.0f));
      light.setAmbient(ColorRGBA.black);
      light.setDiffuse(ColorRGBA.black);
      light.setSpecular(ColorRGBA.black);
      light.setLocation( new Vector3f( 100, 100, 100 ) );
      light.setEnabled(true);      
      lightState.setGlobalAmbient(ColorRGBA.black);
      lightState.attach(light);
      
      lightState.setEnabled(true);
       rootNode.setRenderState(lightState);

Hi



Ok, this is about as simple as I can make it :slight_smile:



Take the standard TestLightState in the JME test classes. lines 117-119, comment out, so the detachAll is still there, but no lights are added. Now, to be sure, add a lightState.setGlobalAmbient(ColorRGBA.black); just after it.



Now run the test.



There should now be no lights, therefore, it should be pitch black.



So why can I still see the objects???, ok, they are dim, but they are there, and they should not be?



HTH



Endolf

http://www.jmonkeyengine.com/jmeforum/index.php?topic=4635.msg36731#msg36731

Ok, so from that thread we need to have a light state (we do) and it may have stuff in it as we are using simple game, so we must call detachAll (see my previous post)



What have I missed in that thread? because it looks to me like I'm doing the 2 important things, we must have an active light state attached otherwise everything uses vertex colours, and that light state must have detachAll run on it as SimpleGame or some other class that we derive from could have set something up



I've even tried adding an active light with ambient, specular and diffuse all set to ColorRGBA.black



It still isn't black in space :slight_smile:



Endolf

Ok, the TestLightState problem seems to have been solved by tweaking my driver settings, seems a combination of gamma/contrast settings in the nvidia conrol panel were causing it to render things that should be black, and now are.



Still hasn't fixed my scene, but at least I seem to have made some progress.



Endolf

Ok, it's sorted, it's the gamma setting on my Nvidia drivers, a setting of anything other than 0 starts adding effectivly ambient light to my scene, even when there are no lights attached to the light state.



At least it's no my code :slight_smile:

i tested it here and yes, the scene isn't totally black.

i don't know if it's the gamma but imho an unlit scene should be totally dark.

Bingo, at least I'm not the only one seeing this too.



I was begining to think I was going totally insane. I'm close already, but I hope to have a few more years before they cart me away to the funny farm :slight_smile:



Thanks for trying this.



Endolf