@Override
        @SuppressWarnings("unchecked")
        public void reload() {
            Field[] fields1 = filter.getClass().getDeclaredFields();
            Field[] fields2 = filter.getClass().getSuperclass().getDeclaredFields();

            List<Field> fields = new ArrayList<>();
            fields.addAll(Arrays.asList(fields1));
            fields.addAll(Arrays.asList(fields2));
            Material m = new Material();
            Filter.Pass p = filter.new Pass();
            try {
                for (Field field : fields) {
                    if (field.getType().isInstance(m)) {
                        field.setAccessible(true);
                        Material mat = reloadMaterial((Material) field.get(filter));
                        if (mat == null) {
                            return;
                        } else {
                            field.set(filter, mat);
                        }
                    }
                    if (field.getType().isInstance(p)) {
                        field.setAccessible(true);
                        p = (Filter.Pass) field.get(filter);
                        if (p != null && p.getPassMaterial() != null) {
                            Material mat = reloadMaterial(p.getPassMaterial());
                            if (mat == null) {
                                return;
                            } else {
                                p.setPassMaterial(mat);
                            }
                        }
                    }
                    if (field.getName().equals("postRenderPasses")) {
                        field.setAccessible(true);
                        List<Pass> passes = new ArrayList<>();
                        passes = (List<Pass>) field.get(filter);
                        if (passes != null) {
                            for (Pass pass : passes) {
                                Material mat = reloadMaterial(pass.getPassMaterial());
                                if (mat == null) {
                                    return;
                                } else {
                                    pass.setPassMaterial(mat);
                                }
                            }
                        }
                    }
                }
            } catch (IllegalArgumentException | IllegalAccessException ex) {
                Logger.getLogger(MaterialDebugAppState.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
Will reload the spatial's materials whenever the shader file is changed
on the hard drive
@param shaderName the shader name (relative path to the asset folder or 
to a registered asset path)
@param spat the spatial to reload
jme3-core/src/main/java/com/jme3/util/MaterialDebugAppState.java