TerrainLighting in jME 3.1

When I create a material using Common/MatDefs/Terrain/TerrainLighting.j3md in jME 3.1, I get a slew of warnings from com.jme3.material.plugins.J3MLoader about non-existent material parameters in the GBuf technique. For the settings I use, the material looks fine, but I believe the warnings reflect bugs in the Engine itself.

Here are the specific warnings:

WARNING: In technique 'GBuf':
Define 'VERTEX_COLOR' mapped to non-existent material parameter 'UseVertexColor', ignoring.
Feb 25, 2017 12:18:52 PM com.jme3.material.plugins.J3MLoader readDefine
WARNING: In technique 'GBuf':
Define 'MATERIAL_COLORS' mapped to non-existent material parameter 'UseMaterialColors', ignoring.
Feb 25, 2017 12:18:52 PM com.jme3.material.plugins.J3MLoader readDefine
WARNING: In technique 'GBuf':
Define 'V_TANGENT' mapped to non-existent material parameter 'VTangent', ignoring.
Feb 25, 2017 12:18:52 PM com.jme3.material.plugins.J3MLoader readDefine
WARNING: In technique 'GBuf':
Define 'MINNAERT' mapped to non-existent material parameter 'Minnaert', ignoring.
Feb 25, 2017 12:18:52 PM com.jme3.material.plugins.J3MLoader readDefine
WARNING: In technique 'GBuf':
Define 'PARALLAXMAP' mapped to non-existent material parameter 'ParallaxMap', ignoring.

The warnings do not occur with 3.0.10 libraries. Apparently there were some changes between 3.0 and 3.1 that were reflected in Lighting.j3md (which is part of jme3-core library) but not in TerrainLighting.j3md (which is part of jme3-terrain library).

Comparing with Lighting.j3md, I believe the MINNAERT define should be removed from TerrainLighting.j3md and parameters UseVertexColor, UseMaterialColors, and ParallaxMap should be added to it. I’m not sure what to do with V_TANGENT, which appears in GBuf.frag and GBuf.vert but not Lighting.j3md.

Before I create a pull request, I’d appreciate it if someone who understand materials and shaders would take a look and let me know whether I’m on the right track.

Here’s my test code, for what it’s worth:

package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.light.DirectionalLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.texture.Texture;
public class Main extends SimpleApplication {
    public static void main(String[] args) {
        Main app = new Main();
        app.start();
    }
    @Override
    public void simpleInitApp() {
        Material mat = new Material(assetManager,
                "Common/MatDefs/Terrain/TerrainLighting.j3md");
        Texture grass = assetManager.loadTexture(
                "Textures/Terrain/splat/grass.jpg");
        mat.setTexture("DiffuseMap", grass);

        Box b = new Box(1f, 1f, 1f);
        Geometry geom = new Geometry("Box", b);
        geom.setMaterial(mat);
        rootNode.attachChild(geom);

        DirectionalLight lite = new DirectionalLight();
        lite.setColor(ColorRGBA.White);
        rootNode.addLight(lite);
        
        cam.setLocation(new Vector3f(-0.4f, 2f, 5f));
        cam.setRotation(new Quaternion(6.1111996E-4f, 0.9977852f, -0.065867886f, 0.009257278f));

        viewPort.setBackgroundColor(ColorRGBA.Gray);
    }
}

there has been a lot of clean up on unused params in lighting, but I didn’t do it in the terrain lighting.
Thanks for reporting.

2 Likes

I pushed a fix for this. It’ll be available in 3. 1.1
Meanwhile you can safely ignore the warnings.

5 Likes

Thank you, Rémy!