[Solved] Objects with UseMaterialColors are not illuminated by an AmbientLight

In my application, I have scene objects that I would like to fade in and out, like a ghost. I am able to achieve this effect. (Note I am writing in Kotlin, so the syntax is slightly different.)

it.material.setColor("Diffuse", ColorRGBA(1f, 1f, 1f, 0.5f)) // TODO: Drive opacity via state
it.material.additionalRenderState.blendMode = RenderState.BlendMode.Alpha
it.queueBucket = RenderQueue.Bucket.Transparent
it.material.setBoolean("UseMaterialColors", true)

However, this makes objects appear darker. Here is what the scene looks like before the effect is applied:

And after (Ignore that some objects are still fully opaque—their material is being reset after I apply the effect, and it’s too cumbersome to refactor for the sake of this post):

This almost looks correct, but when the opacity is brought up to 100%, objects appear darker:

Upon further inspection, it seems as though setting UseMaterialColors to true causes those objects to ignore any lighting from an AmbientLight. When DirectionalLights are removed and only an AmbientLight is present in the scene, the effect is visible (again, some objects are having their material reset after the effect is applied):

So my question is: Why does setting UseMaterialColors to true cause objects to not be affected by an AmbientLight? And what is the fix?

I looked at [SOLVED] Lighting Issues or wrong understanding?, but I can’t discern what the solution is, other than the lighting color? Here’s how I apply the lights in my scene (Kotlin):

object LightingSetup {
    fun setupLights(rootNode: Node): DirectionalLight {
        val shadowsOnly = createDirectionalLight(rootNode, ColorRGBA.Black, Vector3f(0.1f, -1f, -0.1f))
        createDirectionalLight(rootNode, ColorRGBA(0.9f, 0.9f, 0.9f, 1f), Vector3f(0f, -1f, -1f)) // Main light
        createDirectionalLight(rootNode, ColorRGBA(0.1f, 0.1f, 0.3f, 1f), Vector3f(0f, 1f, 1f)) // Backlight
        createAmbientLight(rootNode, ColorRGBA(0.5f, 0.5f, 0.5f, 1f)) // Ambience

        return shadowsOnly // For a DirectionalLightShadowFilter

    private fun createDirectionalLight(rootNode: Node, colorRGBA: ColorRGBA, direction: Vector3f): DirectionalLight {
        return DirectionalLight().apply {
            color = colorRGBA
            this.direction = direction

    private fun createAmbientLight(rootNode: Node, colorRGBA: ColorRGBA): AmbientLight {
        return AmbientLight().apply {
            color = colorRGBA

I apologize for my general lack of knowledge when it comes to these sorts of shading things—I appreciate any help!

Because you are saying “use material colors” but you never set an ambient color so the ambient color is black.

JME is doing what you told it to… rendering with black ambient color.

Ah… I didn’t think to check if Ambient was a color on the material. Thank you!

1 Like