protected void updateUniform(Shader shader, Uniform uniform) {
        int shaderId = shader.getId();

        assert uniform.getName() != null;
        assert shader.getId() > 0;

        bindProgram(shader);

        int loc = uniform.getLocation();
        if (loc == -1) {
            return;
        }

        if (loc == -2) {
            // get uniform location
            updateUniformLocation(shader, uniform);
            if (uniform.getLocation() == -1) {
                // not declared, ignore
                uniform.clearUpdateNeeded();
                return;
            }
            loc = uniform.getLocation();
        }

        if (uniform.getVarType() == null) {
            return; // value not set yet
        }
        statistics.onUniformSet();

        uniform.clearUpdateNeeded();
        FloatBuffer fb;
        IntBuffer ib;
        switch (uniform.getVarType()) {
            case Float:
                Float f = (Float) uniform.getValue();
                assert isValidNumber(f) : "Invalid float value " + f + " for " + uniform.getBinding();
                gl.glUniform1f(loc, f.floatValue());
                break;
            case Vector2:
                Vector2f v2 = (Vector2f) uniform.getValue();
                assert isValidNumber(v2) : "Invalid Vector2f value " + v2 + " for " + uniform.getBinding();
                gl.glUniform2f(loc, v2.getX(), v2.getY());
                break;
            case Vector3:
                Vector3f v3 = (Vector3f) uniform.getValue();
                assert isValidNumber(v3) : "Invalid Vector3f value " + v3 + " for " + uniform.getBinding();
                gl.glUniform3f(loc, v3.getX(), v3.getY(), v3.getZ());
                break;
            case Vector4:
                Object val = uniform.getValue();
                if (val instanceof ColorRGBA) {
                    ColorRGBA c = (ColorRGBA) val;
                    assert isValidNumber(c) : "Invalid ColorRGBA value " + c + " for " + uniform.getBinding();
                    gl.glUniform4f(loc, c.r, c.g, c.b, c.a);
                } else if (val instanceof Vector4f) {
                    Vector4f c = (Vector4f) val;
                    assert isValidNumber(c) : "Invalid Vector4f value " + c + " for " + uniform.getBinding();
                    gl.glUniform4f(loc, c.x, c.y, c.z, c.w);
                } else {
                    Quaternion c = (Quaternion) uniform.getValue();
                    assert isValidNumber(c) : "Invalid Quaternion value " + c + " for "
                            + uniform.getBinding();
                    gl.glUniform4f(loc, c.getX(), c.getY(), c.getZ(), c.getW());
                }
                break;
            case Boolean:
                Boolean b = (Boolean) uniform.getValue();
                gl.glUniform1i(loc, b.booleanValue() ? GL.GL_TRUE : GL.GL_FALSE);
                break;
            case Matrix3:
                fb = uniform.getMultiData();
                assert isValidNumber(fb) : "Invalid Matrix3f value " + uniform.getValue() + " for "
                        + uniform.getBinding();
                assert fb.remaining() == 9;
                gl.glUniformMatrix3(loc, false, fb);
                break;
            case Matrix4:
                fb = uniform.getMultiData();
                assert isValidNumber(fb) : "Invalid Matrix4f value " + uniform.getValue() + " for "
                        + uniform.getBinding();
                assert fb.remaining() == 16;
                gl.glUniformMatrix4(loc, false, fb);
                break;
            case IntArray:
                ib = (IntBuffer) uniform.getValue();
                gl.glUniform1(loc, ib);
                break;
            case FloatArray:
                fb = uniform.getMultiData();
                assert isValidNumber(fb) : "Invalid float array value "
                        + Arrays.asList((float[]) uniform.getValue()) + " for " + uniform.getBinding();
                gl.glUniform1(loc, fb);
                break;
            case Vector2Array:
                fb = uniform.getMultiData();
                assert isValidNumber(fb) : "Invalid Vector2f array value "
                        + Arrays.deepToString((Vector2f[]) uniform.getValue()) + " for "
                        + uniform.getBinding();
                gl.glUniform2(loc, fb);
                break;
            case Vector3Array:
                fb = uniform.getMultiData();
                assert isValidNumber(fb) : "Invalid Vector3f array value "
                        + Arrays.deepToString((Vector3f[]) uniform.getValue()) + " for "
                        + uniform.getBinding();
                gl.glUniform3(loc, fb);
                break;
            case Vector4Array:
                fb = uniform.getMultiData();
                assert isValidNumber(fb) : "Invalid Vector4f array value "
                        + Arrays.deepToString((Vector4f[]) uniform.getValue()) + " for "
                        + uniform.getBinding();
                gl.glUniform4(loc, fb);
                break;
            case Matrix4Array:
                fb = uniform.getMultiData();
                assert isValidNumber(fb) : "Invalid Matrix4f array value "
                        + Arrays.deepToString((Matrix4f[]) uniform.getValue()) + " for "
                        + uniform.getBinding();
                gl.glUniformMatrix4(loc, false, fb);
                break;
            case Int:
                Integer i = (Integer) uniform.getValue();
                gl.glUniform1i(loc, i.intValue());
                break;
            default:
                throw new UnsupportedOperationException(
                        "Unsupported uniform type: " + uniform.getVarType() + " for " + uniform.getBinding());
        }
    }
Update the location of the specified Uniform in the specified Shader.

@param shader the Shader containing the Uniform (not null)
@param uniform the Uniform to update (not null)
jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java