Imports within shaders lead to an AssetNotFoundException

I’m playing with shaders and I’m trying to start with a known good shader (thats more or less what I want already) and then modify it. This worked fine for the fragment shader but the vertexShader has imports that seem not to work in my code giving errors of the form:

com.jme3.asset.AssetNotFoundException: Common/ShaderLib/GLSLCompat.glsllib

So if i copy

And edit it to refer to my own vertex shader,
Copied from

Then run my program I get the quoted error. Are these imports relative? How can I import from Common? (I could just copy the referenced files but that begins to blow up quickly)

Main class:

public class Main extends SimpleApplication {

    public static void main(String[] args) {
        Main app = new Main();
        app.start();
    }

    @Override
    public void simpleInitApp() {
/** A simple textured cube -- in good MIP map quality. */
    Box cube1Mesh = new Box( 1f,1f,1f);
    Geometry cube1Geo = new Geometry("My Textured Box", cube1Mesh);
    cube1Geo.setLocalTranslation(new Vector3f(-3f,1.1f,0f));
    Material cube1Mat = new Material(assetManager, 
        "MatDefs/RepeatingUnshaded.j3md");
    Texture cube1Tex = assetManager.loadTexture(
        "Textures/testTexture.png");
    cube1Mat.setTexture("ColorMap", cube1Tex);
    cube1Geo.setMaterial(cube1Mat);
    rootNode.attachChild(cube1Geo);

 

    }
}

Project structure:

Minorly modified material (just to refer to my shaders)

MaterialDef Unshaded {

    MaterialParameters {
        Texture2D ColorMap
        Texture2D LightMap
        Color Color (Color)
        Boolean VertexColor (UseVertexColor)
        Boolean SeparateTexCoord

        // Texture of the glowing parts of the material
        Texture2D GlowMap
        // The glow color of the object
        Color GlowColor

        // For instancing
        Boolean UseInstancing

        // For hardware skinning
        Int NumberOfBones
        Matrix4Array BoneMatrices

        // Alpha threshold for fragment discarding
        Float AlphaDiscardThreshold (AlphaTestFallOff)

        //Shadows
        Int FilterMode
        Boolean HardwareShadows

        Texture2D ShadowMap0
        Texture2D ShadowMap1
        Texture2D ShadowMap2
        Texture2D ShadowMap3
        //pointLights
        Texture2D ShadowMap4
        Texture2D ShadowMap5
        
        Float ShadowIntensity
        Vector4 Splits
        Vector2 FadeInfo

        Matrix4 LightViewProjectionMatrix0
        Matrix4 LightViewProjectionMatrix1
        Matrix4 LightViewProjectionMatrix2
        Matrix4 LightViewProjectionMatrix3
        //pointLight
        Matrix4 LightViewProjectionMatrix4
        Matrix4 LightViewProjectionMatrix5
        Vector3 LightPos
        Vector3 LightDir

        Float PCFEdge

        Float ShadowMapSize

        Boolean BackfaceShadows: true
    }

    Technique {
        VertexShader GLSL150:   MatDefs/repeatingVert.vert
        FragmentShader GLSL150: Common/MatDefs/Misc/Unshaded.frag

        WorldParameters {
            WorldViewProjectionMatrix
            ViewProjectionMatrix
            ViewMatrix
        }

        Defines {
            INSTANCING : UseInstancing
            SEPARATE_TEXCOORD : SeparateTexCoord
            HAS_COLORMAP : ColorMap
            HAS_LIGHTMAP : LightMap
            HAS_VERTEXCOLOR : VertexColor
            HAS_COLOR : Color
            NUM_BONES : NumberOfBones
            DISCARD_ALPHA : AlphaDiscardThreshold
        }
    }

    Technique {
        VertexShader GLSL100:   MatDefs/repeatingVert.vert
        FragmentShader GLSL100: Common/MatDefs/Misc/Unshaded.frag

        WorldParameters {
            WorldViewProjectionMatrix
            ViewProjectionMatrix
            ViewMatrix
        }

        Defines {
            INSTANCING : UseInstancing
            SEPARATE_TEXCOORD : SeparateTexCoord
            HAS_COLORMAP : ColorMap
            HAS_LIGHTMAP : LightMap
            HAS_VERTEXCOLOR : VertexColor
            HAS_COLOR : Color
            NUM_BONES : NumberOfBones
            DISCARD_ALPHA : AlphaDiscardThreshold
        }
    }

    Technique PreNormalPass {

          VertexShader GLSL100 :   Common/MatDefs/SSAO/normal.vert
          FragmentShader GLSL100 : Common/MatDefs/SSAO/normal.frag

          WorldParameters {
              WorldViewProjectionMatrix
              WorldViewMatrix
              NormalMatrix
              ViewProjectionMatrix
              ViewMatrix
          }

          Defines {
              NUM_BONES : NumberOfBones
              INSTANCING : UseInstancing
          }
   }

    Technique PreShadow {

        VertexShader GLSL100 :   Common/MatDefs/Shadow/PreShadow.vert
        FragmentShader GLSL100 : Common/MatDefs/Shadow/PreShadow.frag

        WorldParameters {
            WorldViewProjectionMatrix
            WorldViewMatrix
            ViewProjectionMatrix
            ViewMatrix
        }

        Defines {
            COLOR_MAP : ColorMap
            DISCARD_ALPHA : AlphaDiscardThreshold
            NUM_BONES : NumberOfBones
            INSTANCING : UseInstancing
        }

        ForcedRenderState {
            FaceCull Off
            DepthTest On
            DepthWrite On
            PolyOffset 5 3
            ColorWrite Off
        }

    }


    Technique PostShadow {
        VertexShader GLSL150:   Common/MatDefs/Shadow/PostShadow.vert
        FragmentShader GLSL150: Common/MatDefs/Shadow/PostShadow.frag

        WorldParameters {
            WorldViewProjectionMatrix
            WorldMatrix
            ViewProjectionMatrix
            ViewMatrix
        }

        Defines {
            HARDWARE_SHADOWS : HardwareShadows
            FILTER_MODE : FilterMode
            PCFEDGE : PCFEdge
            DISCARD_ALPHA : AlphaDiscardThreshold           
            COLOR_MAP : ColorMap
            SHADOWMAP_SIZE : ShadowMapSize
            FADE : FadeInfo
            PSSM : Splits
            POINTLIGHT : LightViewProjectionMatrix5
            NUM_BONES : NumberOfBones
	    INSTANCING : UseInstancing
	        BACKFACE_SHADOWS: BackfaceShadows
        }

        ForcedRenderState {
            Blend Modulate
            DepthWrite Off                 
            PolyOffset -0.1 0
        }
    }

    Technique PostShadow {
        VertexShader GLSL100:   Common/MatDefs/Shadow/PostShadow.vert
        FragmentShader GLSL100: Common/MatDefs/Shadow/PostShadow.frag

        WorldParameters {
            WorldViewProjectionMatrix
            WorldMatrix
            ViewProjectionMatrix
            ViewMatrix
        }

        Defines {
            HARDWARE_SHADOWS : HardwareShadows
            FILTER_MODE : FilterMode
            PCFEDGE : PCFEdge
            DISCARD_ALPHA : AlphaDiscardThreshold           
            COLOR_MAP : ColorMap
            SHADOWMAP_SIZE : ShadowMapSize
            FADE : FadeInfo
            PSSM : Splits
            POINTLIGHT : LightViewProjectionMatrix5
            NUM_BONES : NumberOfBones
            INSTANCING : UseInstancing
            BACKFACE_SHADOWS: BackfaceShadows
        }

        ForcedRenderState {
            Blend Modulate
            DepthWrite Off   
            PolyOffset -0.1 0  
        }
    }

    Technique Glow {

        VertexShader GLSL100:   Common/MatDefs/Misc/Unshaded.vert
        FragmentShader GLSL100: Common/MatDefs/Light/Glow.frag

        WorldParameters {
            WorldViewProjectionMatrix
            ViewProjectionMatrix
            ViewMatrix
        }

        Defines {
            NEED_TEXCOORD1
            HAS_GLOWMAP : GlowMap
            HAS_GLOWCOLOR : GlowColor
            NUM_BONES : NumberOfBones
	    INSTANCING : UseInstancing
        }
    }
}

Unmodified vertex shader

#import "Common/ShaderLib/GLSLCompat.glsllib"
#import "Common/ShaderLib/Skinning.glsllib"
#import "Common/ShaderLib/Instancing.glsllib"

attribute vec3 inPosition;

#if defined(HAS_COLORMAP) || (defined(HAS_LIGHTMAP) && !defined(SEPARATE_TEXCOORD))
    #define NEED_TEXCOORD1
#endif

attribute vec2 inTexCoord;
attribute vec2 inTexCoord2;
attribute vec4 inColor;

varying vec2 texCoord1;
varying vec2 texCoord2;

varying vec4 vertColor;

void main(){
    #ifdef NEED_TEXCOORD1
        texCoord1 = inTexCoord;
    #endif

    #ifdef SEPARATE_TEXCOORD
        texCoord2 = inTexCoord2;
    #endif

    #ifdef HAS_VERTEXCOLOR
        vertColor = inColor;
    #endif

    vec4 modelSpacePos = vec4(inPosition, 1.0);
    #ifdef NUM_BONES
        Skinning_Compute(modelSpacePos);
    #endif

    gl_Position = TransformWorldViewProjection(modelSpacePos);
}

Full error

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
com.jme3.asset.AssetNotFoundException: Common/ShaderLib/GLSLCompat.glsllib
	at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:283)
	at com.jme3.shader.plugins.GLSLLoader.loadNode(GLSLLoader.java:101)
	at com.jme3.shader.plugins.GLSLLoader.load(GLSLLoader.java:180)
	at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:288)
	at com.jme3.asset.DesktopAssetManager.loadShader(DesktopAssetManager.java:410)
	at com.jme3.material.Technique.loadShader(Technique.java:217)
	at com.jme3.material.Technique.makeCurrent(Technique.java:201)
	at com.jme3.material.Material.selectTechnique(Material.java:928)
	at com.jme3.material.Material.autoSelectTechnique(Material.java:936)
	at com.jme3.material.Material.render(Material.java:1055)
	at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:523)
	at com.jme3.renderer.queue.RenderQueue.renderGeometryList(RenderQueue.java:322)
	at com.jme3.renderer.queue.RenderQueue.renderQueue(RenderQueue.java:374)
	at com.jme3.renderer.RenderManager.renderViewPortQueues(RenderManager.java:763)
	at com.jme3.renderer.RenderManager.flushQueue(RenderManager.java:719)
	at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:983)
	at com.jme3.renderer.RenderManager.render(RenderManager.java:1029)
	at com.jme3.app.SimpleApplication.update(SimpleApplication.java:252)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
	at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
	at java.lang.Thread.run(Thread.java:744)

What am I doing wrong here? Why can’t my shader find its imports?

GlslCompat has been added in 3.1 i think what version of JME are you using?

Ah! I’m using JME sdk 3.0.10. I’ll look back at the history of that file and start with a slightly older version. I didn’t even think of that because I only just downloaded the library yesterday (new environment, I haven’t just started with jMonkey and immediately broken out the shaders) but of course i’m on latest stable and that link is to bleeding edge

well you can just grab it from the repo and put it in your own project, if you don’t want to upgrade JME version.

Ah yes, if I click “releases” on the page Release JME sdk 3.0.10 · jMonkeyEngine/sdk · GitHub I get a whole load more builds which I didn’t notice before, I’ll go with the new version, thanks