Uniform bind ifdef recompile seems to not happen

Well i have a material with uniforms.
In the fragment shader i use ifdefine stuff for all possible 4 paths of execution.

(Note the clip is for cuttong of stuff in like scrollpanes ect, but not relevant in my test case, as it is never set.)

Now i create a quad with this material, and set the color.
-> I see the color
If i set the texture I see the texture as well.

However when i set the color and the texture i see only one of both, except when I remove the ifdefine stuff.
Any ideas what might causing this behaviour?

I extend Geometry for the gui to generate their respective necessary stuff. Each geometry has a own material instance.

package de.visiongamestudios.gui;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jme3.asset.TextureKey;
import com.jme3.material.MatParamTexture;
import com.jme3.material.Material;
import com.jme3.material.RenderState.BlendMode;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Mesh;
import com.jme3.texture.Texture;
import com.jme3.texture.Texture2D;

/**
 * Abstract base class for all inner components
 * 
 * @author Empire-Phoenix
 * 
 */
public abstract class VGSGUIGeometry extends Geometry {

	protected float				width;
	protected float				height;
	protected boolean			init;
	private boolean				visible					= true;

	private static final Logger	LOGGER					= LoggerFactory.getLogger(VGSGUIGeometry.class);

	/**
	 * After super call init() MUST be befor end of constructor
	 * 
	 * @param name
	 */
	public VGSGUIGeometry(final String name) {
		super(name);
	}

	protected void init(final Mesh m) {
		assert m != null;
		this.setMesh(m);
		this.setCullHint(CullHint.Always);

		this.material = new Material(VGSGUIManager.getInstance().getAssetManager(), VGSGUIConstants.GUI_MATERIALDEFINITION);
		this.material.setFloat("Bloomscalefactor", VGSGUIManager.getInstance().getBloomscalefactor());
		this.material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
		this.setMaterial(this.material);
		this.init = true;
	}

	public void setWidth(final float width) {
		assert this.init;
		assert !Float.isNaN(width);
		this.width = width;
		if (width == 0 || this.height == 0) {
			this.setCullHint(CullHint.Always);
			VGSGUIGeometry.LOGGER.trace("Hiding component:{} -{}:{}", new Object[] { this, width, this.height });
		} else {
			VGSGUIGeometry.LOGGER.trace("Showing component:{} -{}:{}", new Object[] { this, width, this.height });
			this.setLocalScale(new Vector3f(this.width, this.height, 1f));
			this.setVisibleIfContainsContent();
		}
	}

	protected void setVisibleIfContainsContent() {
		assert this.init;
		if (this.visible) {
			if (this.getMaterial().getTextureParam("ColorMap") != null || this.material.getParam("Color") != null) {
				this.setCullHint(CullHint.Dynamic);
			}
		}
	}

	public void setHeight(final float height) {
		assert this.init;
		assert !Float.isNaN(height);
		this.height = height;
		if (this.width == 0 || height == 0) {
			this.setCullHint(CullHint.Always);
			VGSGUIGeometry.LOGGER.trace("Hiding component:{} -{}:{}", new Object[] { this, this.width, this.height });
		} else {
			VGSGUIGeometry.LOGGER.trace("Showing component:{} -{}:{}", new Object[] { this, this.width, this.height });
			this.setLocalScale(new Vector3f(this.width, this.height, 1f));
			this.setVisibleIfContainsContent();
		}

	}

	public void setPosition(final float x, final float y) {
		assert this.init;
		final float z = this.getLocalTranslation().getZ();
		this.setLocalTranslation(x, y, z);
	}

	public Vector3f getPosition() {
		assert this.init;
		return this.getLocalTranslation();
	}

	public void setImage(final String imgName) {
		assert this.init;
		if (imgName != null) {

			final TextureKey key = new TextureKey(imgName, true);
			final Texture2D tex = (Texture2D) VGSGUIManager.getInstance().getAssetManager().loadTexture(key);
			assert tex != null : "Cant load " + imgName;
			this.setTexture(tex);
		} else {
			this.setTexture(null);
		}
	}

	public void setTexture(final Texture tex) {
		assert this.init;
		if (tex == null) {
			this.material.clearParam("ColorMap");
			this.setMaterial(this.material);
			this.setVisible(false);
		} else {
			this.material.setTexture("ColorMap", tex);
			this.setMaterial(this.material);
			this.setVisible(true);
		}
	}

	@Override
	public void setMaterial(final Material material) {
		System.out.println(material);
		super.setMaterial(material);
	}

	public Texture getTexture() {
		final MatParamTexture param = this.material.getTextureParam("ColorMap");
		if (param != null) {
			return param.getTextureValue();
		}

		return null;
	}

	/**
	 * Sets the color and replaces materials setted before.
	 * 
	 * @param color
	 */
	public void setColor(final ColorRGBA color) {
		assert this.init;
		if (color == null) {
			this.material.clearParam("Color");
			this.setMaterial(this.material);
			this.setVisible(false);
		} else {
			System.out.println(color + " " + this);
			this.material.setColor("Color", color);
			this.setMaterial(this.material);
			this.setVisible(true);
		}

	}

	public float getTextureWidth() {
		assert this.init;
		assert this.mesh != null : "Mesh is null " + this.name;
		final MatParamTexture texparam = this.getMaterial().getTextureParam("ColorMap");
		if (texparam == null) {
			return Float.NaN;
		}
		return texparam.getTextureValue().getImage().getWidth();
	}

	public float getTextureHeight() {
		assert this.init;
		assert this.mesh != null : "Mesh is null " + this.name;
		final MatParamTexture texparam = this.getMaterial().getTextureParam("ColorMap");
		if (texparam == null) {
			return Float.NaN;
		}
		return texparam.getTextureValue().getImage().getHeight();
	}

	public float getWidth() {
		assert this.init;
		return this.width;
	}

	public float getHeight() {
		assert this.init;
		return this.height;
	}

	public void setClipRect(final ColorRGBA clipRect) {
		assert this.init;
		assert clipRect != null;
		this.material.setColor("ClipRect", clipRect);
		this.setMaterial(this.material);
	}

	public boolean isVisible() {
		assert this.init;
		return this.getCullHint() != CullHint.Always;
	}

	public void setVisible(final boolean visible) {
		assert this.init;
		this.visible = visible;
		if (visible && this.width != 0 && this.height != 0) {
			this.setVisibleIfContainsContent();
			return;
		}
		this.setCullHint(CullHint.Always);
	}

	@Override
	public String toString() {
		return String.format("GUIGeometry [name=%s,width=%s, height=%s, init=%s, visible=%s] world=[%s]", this.name, this.width, this.height, this.init, this.visible, this.getWorldTranslation());
	}

}
uniform vec4 m_Color;
uniform sampler2D m_ColorMap;
uniform vec4 m_ClipRect;

varying vec2 texCoord1;

void main(){
	vec4 color = vec4(1,1,1,1); //white as basis color
	#ifdef HAS_COLORMAP
		color *= texture2D(m_ColorMap, texCoord1);
	#endif
	#ifdef HAS_COLOR
		color *= m_Color;
	#endif
			
	#ifdef HAS_CLIP
		if(m_ClipRect!=vec4(0,0,0,0)){
	 		if(gl_FragCoord.y>m_ClipRect.y+m_ClipRect.w){
	 			discard;
	 		}
	 		else if(gl_FragCoord.x>m_ClipRect.x+m_ClipRect.z){
				discard;
			}
			else if(gl_FragCoord.y<m_ClipRect.y){
				discard;
			}
			else if(gl_FragCoord.x<m_ClipRect.x){
				discard;
			}
		}
	#endif
    gl_FragColor = color;
}
MaterialDef GUI{

    MaterialParameters {
        Texture2D ColorMap
        Color Color
        Color ClipRect
        Color GlowColor
        Float Bloomscalefactor
    }

    Technique {
        VertexShader GLSL100:   assets/material/Gui.vert
        FragmentShader GLSL100: assets/material/Gui.frag

        WorldParameters {
            WorldViewProjectionMatrix
        }

        Defines {
            HAS_CLIP : ClipRect            
            HAS_COLORMAP : ColorMap
            HAS_COLOR : Color
        }
    }
    
    Technique Glow {

        VertexShader GLSL100:   assets/material/Gui.vert
        FragmentShader GLSL100: assets/material/GlowGui.frag

        WorldParameters {
            WorldViewProjectionMatrix
        }

        Defines {
            HAS_CLIP : ClipRect                
            HAS_GLOWMAP : GlowMap
            HAS_GLOWCOLOR : GlowColor
        }
    }
}

That’s what the unshaded material does. It should work fine.

What you can do is to make a syntax error on purpose in the shader, then launch your test. The shader code will be output in the console with the defines at the beginning.
This way you can check if this is really a define issue.

On a side note, make sure to initialize your vec4 like this vec4(1.0,1.0,1.0,1.0) instead of vec4(1,1,1,1) because this is very likely to fail on some hardware