Login  Register

Re: Can't Get Lighting to Work in Ardor3D

Posted by hedgehog on Mar 19, 2014; 8:10pm
URL: https://forum.jogamp.org/Can-t-Get-Lighting-to-Work-in-Ardor3D-tp4031971p4031991.html

So, the lines without light state set shows the red colour without lighting:

materialState.setAmbient(MaterialFace.FrontAndBack, new ColorRGBA(0.1f,0.1f,0.1f,1.0f));
materialState.setDiffuse(MaterialFace.FrontAndBack, new ColorRGBA(0.9f,0.9f,0.9f,1.0f));

and thus keeps the red colour.

The lines:

materialState.setColorMaterial(ColorMaterial.AmbientAndDiffuse);
materialState.setColorMaterialFace(MaterialFace.FrontAndBack);

also keeps the red colour, with the root node light state set, but still no lighting effect like BoxExample.

If I also add the lines:

materialState.setColorMaterial(ColorMaterial.Emissive);
materialState.setColorMaterial(ColorMaterial.Specular);

I again lose the red colour and no lighting effect, even though there is no emissive or specular values set by GridExample or the parent ExampleBase.

The Mesh colours are entirely set via directly writing to the colour buffer as a flat rgba. From where is it picking up ambient/diffuse/emissive/specular components?

I understand the state engine of opengl for turning on/off light/colour states. What I don't understand is how this works in Ardor3D. I call materialState.setColorMaterial(ColorMaterial.AmbientAndDiffuse) and assign it to an object but from where does it get the ambient and diffuse values? In the materialState.setColorMaterial() version they are not assigned.

There's something going on when writing directly to the colour buffer that I don't understand.