Blender object not using ambient light

[Summary]
I want to take a Blender textured object and use it in my scene with ambient lighting. I find that a JME3-created Box() will not use ambient lighting until I set UseMaterialColors to false. However, I cannot find a setting to get a Blender textured object to use ambient lighting.

[Setup]
JME3 SDK using 3.4.0-stable. Blender 2.93.4.
I setup a scene with JME3 Box()s making a “room” (of 5 Box()s 4x4x0.1) with an open side. I place a PointLight in the “room” with a radius of 100. I used the Blender default box (1x1x1) and wrapped the JME3 Pong.jpg and Pond_normal.jpg around it, exported it as gLTF 2.0, converted it to j3o, and loadModel()'d it. The run appears as:

[Objects]
I used SceneGraphVisitorAdapter on a JME3 Box “edge” and on the Blender j3o object. The results are:
jme3-box Material BackfaceShadows is false
jme3-box Material ParallaxHeight is 0.05
jme3-box Material Shininess is 1.0
jme3-box Texture DiffuseMap is Flip WrapRepeat_S WrapRepeat_T “Textures/Terrain/Pond/Pond.jpg”
jme3-box Texture NormalMap is Flip WrapRepeat_S WrapRepeat_T “Textures/Terrain/Pond/Pond_normal.png”
jme3-box Material UseMaterialColors is false
jme3-box Material Diffuse is 1.0 1.0 1.0 1.0
jme3-box Material Specular is 1.0 1.0 1.0 1.0

Blender-box Material EmissivePower is 3.0
Blender-box Material BackfaceShadows is false
Blender-box Material Roughness is 0.4
Blender-box Material EmissiveIntensity is 2.0
Blender-box Material Glossiness is 1.0
Blender-box Material BaseColor is 1.0 1.0 1.0 1.0
Blender-box Material ParallaxHeight is 0.05
Blender-box Material Metallic is 0.0
Blender-box Material NormalType is 1.0
Blender-box Material Emissive is 0.0 0.0 0.0 1.0
Blender-box Texture NormalMap is WrapRepeat_S WrapRepeat_T MinTrilinear “Models/Pond_normal.png”
Blender-box Texture BaseColorMap is WrapRepeat_S WrapRepeat_T MinTrilinear “Models/Pond.jpg”
Blender-box Material Specular is 1.0 1.0 1.0 1.0

[Independent Tests]

  • I ran as above and the scene is as shown in the image above.
  • On the Blender object, I tried a SceneGraphVisitorAdapter to do geom.getMaterial().setColor("Ambient", ColorRGBA.White); resulting in an IllegalArgumentException: Material parameter is not defined: Ambient
  • On the Blender object, I tried a SceneGraphVisitorAdapter to do geom.getMaterial().setBoolean("UseMaterialColors", false); resulting in an IllegalArgumentException: Material parameter is not defined: UseMaterialColors
  • With
    final MatParamOverride overrideAmbient
        = new MatParamOverride(VarType.Vector4, "Ambient", ColorRGBA.White);
  
    final MatParamOverride overrideUseMaterialColors
        = new MatParamOverride(VarType.Boolean, "UseMaterialColors", false);

I tried

        rootNode.addMatParamOverride(overrideAmbient);
        rootNode.addMatParamOverride(overrideUseMaterialColors);

both at the start of simpleInitApp(), then at the end. No errors occurred, but the result is the same image as seen above.

  • I tried exporting from Blender after being sure I saw the object in the Render view. I was reading Forum thread https://hub.jmonkeyengine.org/t/ambient-lighting-and-blender-imports/33754/21 and it suggested I make sure the Blender object is rendered before exporting so that the World Ambient Light setting is incorporated into the export. Perhaps I did that incorrectly.

[Conclusion]
I can’t set or override material parameters that are not already part of the object’s material.

Can you think of settings I can apply, or a way I can export from Blender so that my Blender object can use ambient light?

GLTF will use the PBR material. PBR materials need a light probe if you want them to look right.

If you search the forum I think there are a couple thousands posts on this so you are bound to hit one. Search for GLTF and LightProbe.

2 Likes

@pspeed, I will research GLTF and LightProbe, thank you.

1 Like

@pspeed, searching for [GLTF LightProbe] gives me … 5 results, one being this thread. I’ll search for each separately and see what I can find.

Yeah, this thread wasn’t in the search when I checked. :slight_smile: And you get more results with “light probe” instead of “LightProbe” but I don’t know if they are better results.

You can find a default set of prebuilt LightProbe j3o files in this post:

And I posted a code snippet that will load one here:

But that whole thread may have the questions you may have about your next steps (like if you decide you want to generate a probe specific to your scene or something).

2 Likes