Materialstate headaches


I'm trying to get a Quad to accept the Materialstate I apply to it, but it keeps staying white. I've looked around the forum and have double checked whether my lighting is on and it is. Other object with TextureState are showing the correct textures, but the Material State just doesn't want to work.

'this' in the code is a Node. Debugging shows the color object to be Blue.

public void select( Vector3f point, final ColorRGBA color ) {
         SharedNode tile = new SharedNode( "", baseTile );
         tile.getLocalTranslation().y = point.y;
         tile.getLocalTranslation().z += point.z;
         tile.getLocalTranslation().x += point.x;
         tile.updateGeometricState(0, false);
         MaterialState ms = DisplaySystem.getDisplaySystem().getRenderer().createMaterialState();
         ms.setDiffuse( color );
         ms.setEmissive( color );
         ms.setAmbient( color );;
         ms.setColorMaterial( MaterialState.CM_DIFFUSE );
         ms.setEnabled( true );
         tile.setRenderState( ms );
         this.attachChild( tile );

Please help me out.


Yes I do, if this is what turns the lighting on:

      PointLight light = new PointLight();
      light.setDiffuse(new ColorRGBA(0.75f, 0.75f, 0.75f, 0.75f));
      light.setAmbient(new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f));
      light.setLocation(new Vector3f(0.0f, 250f, 0.0f));

      lightState = renderer.createLightState();

Is the object with the material state attached to root somewhere other than in simpleSetup (or similar)  and if so, are you remembering to call update renderstate on it after you attach it?

Second basic question, what is your emmissive color? Emmisive can VERY EASILY saturate the object and make it look like a solid color. Try not setting emmissive as a test.

The emmisive color is hard blue (0x0000FF) and the quad shows up as white. This stays the same with emissive not set.

material Shininess can also cause the light color to overcome the material diffuse color.  You might try playing around with that.

First basic question, you have lighting turned on, right?

No, that doesn't change the behaviour either.

I've got another issue too now. I've got a scene tree set up like so:


Try changing the diffuse color or ambient color of your light.  if that does not affect what you are seeing, then you don't have a lightstate on that Quad.  Also, trying calling tile.setSolidColor(  If your tile turns red and your material state wasn't setup to use vert colors, you definitely are not getting light.

It's funny, I tried to assign a ColorMaterial to a quad and had the same result. Swapping the quad for a sphere showed the correct color…


Ok, i never looked at the other side of the quads…  next time i'm culling back faces by default :slight_smile: