Warning from Material.checkTextureParamColorSpace()

The MoreAdvancedVehicles project (using JME 3.3.2-stable) issues a warning while loading the tank asset:

Jan 24, 2021 4:53:23 PM com.jme3.material.Material checkTextureParamColorSpace
WARNING: The texture Models/Tank/Tank_Occ_Rough_Metal.png has linear color space, but the material parameter LightMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().

Does anyone know a way to avoid this warning, short of configuring Material.logger?

An identical warning occurs in the TestPbrLighting app of jme3-examples, which is simpler and thus easier to debug.

I do not, but I would love to know the answer as I get that warning regularly as well. At one point I had investigated it and found that the texture was flagged as linear from the material, but for some reason I still get the warning.

1 Like

Can you explain what that means in this case? Flagged in code or flagged in the j3m?

1 Like

texture.getImage().getColorSpace() was equal to ColorSpace.Linear
Where texture was retrieved using:

            Material mat = geo.getMaterial();
            MaterialData mdata = new MaterialData();

            //Create unique name
            int counter2 = 0;
            do {
                String genName = modelName + "-" + geo.getName() + "-" + counter2 + "-mat";
                mdata.setName(genName);
                counter2++;
            } while (AssetDatabase.hasMaterial(mdata.getName()));

            mdata.setShader("pbr-shader");
            for (MatParam param : mat.getParams()) {
                if (param.getVarType() == VarType.Texture2D || param.getVarType() == VarType.Texture3D
                        || param.getVarType() == VarType.TextureArray || param.getVarType() == VarType.TextureCubeMap) {
                    TextureData tex = new TextureData();
                    //Create unique name
                    int counter = 0;
                    do {
                        String genName = modelName + "-" + geo.getName() + "-" + param.getName() + "-" + counter + "-tex";
                        tex.setName(genName);
                        counter++;
                    } while (AssetDatabase.hasTexture(tex.getName()));

                    //Load texture settings
                    tex.setFlipped(false);
                    if (param.getValue() instanceof Texture) {
                        if (((Texture) param.getValue()).getKey() == null) {
                            continue; //For models with textures built into the model format, the tex are NOT external files
                        }
                        if (((Texture) param.getValue()).getKey() instanceof TextureKey) {
                            tex.setFlipped(((TextureKey) ((Texture) param.getValue()).getKey()).isFlipY());
                        }
                        tex.setResource(((Texture) param.getValue()).getKey().getName());
                        switch (((TextureKey) ((Texture) param.getValue()).getKey()).getTextureTypeHint()) {
                            case CubeMap:
                                tex.setType("4d");
                                break;
                            case TwoDimensional:
                                tex.setType("2d");
                                break;
                            case ThreeDimensional:
                                tex.setType("3d");
                                break;
                            case TwoDimensionalArray:
                                tex.setType("2da");
                                break;
                            default:
                                tex.setType("");
                        }
                        tex.setAnisotropy(((TextureKey) ((Texture) param.getValue()).getKey()).getAnisotropy());
                        tex.setGenerateMips(((TextureKey) ((Texture) param.getValue()).getKey()).isGenerateMips());
                    }
                    generatedTextures.put(tex.getName(), tex);

                    mdata.getTextures().put(param.getName(), tex.getName());
                } else if (param.getValue() instanceof ColorRGBA) {
                    mdata.getProperties().put(param.getName(), param.getValue());
                } else if (param.getValue() instanceof Integer) {
                    mdata.getProperties().put(param.getName(), param.getValue());
                } else if (param.getValue() instanceof Float) {
                    mdata.getProperties().put(param.getName(), param.getValue());
                } else if (param.getValue() instanceof Boolean) {
                    mdata.getProperties().put(param.getName(), param.getValue());
                } else {
                    LOGGER.warning("Unsupported property on model material import: " + param.getValue().getClass().getName());
                }
            }
            generatedMaterials.put(geo.getName(), mdata);
        }

Sorry for the complicated code here, this is part of a function I built for extracting and rebuilding materials dynamically for the Outside Engine.

Not sure why the code was important since it doesn’t deal with color space and doesn’t load textures that I see.

That was just the code I was using for getting the textures from the material when I was looking into the warning several months ago. The code does not have anything to do with loading the textures or the color space, as by the time I extract the textures from the material the texture is already loaded and the warning has already occurred. It was just a convenient because it already pulled the textures from the material. I’m simply showing that the texture object I checked was pulled from the material.

Ok, but without showing the check, etc… It lacks all of the meaningful parts to me. I would have already believed you if you said you looked at the textures in the material.

I think TestPbrLighting is probably a more useful direction since it’s a simple self-contained test that exhibits the issue.