/** * Internally called to generate the maps. * This method will spawn 7 thread (one for the Irradiance spherical harmonics generator, and one for each face of the prefiltered env map). * Those threads will be executed in a ScheduledThreadPoolExecutor that will be shutdown when the generation is done. * * @param envMap the raw env map rendered by the env camera * @param probe the LightProbe to generate maps for * @param app the Application * @param listener a progress listener. (can be null if no progress reporting is needed) */ private static void generatePbrMaps(TextureCubeMap envMap, final LightProbe probe, Application app, EnvMapUtils.GenerationType genType, final JobProgressListener<LightProbe> listener) { IrradianceSphericalHarmonicsGenerator irrShGenerator; PrefilteredEnvMapFaceGenerator[] pemGenerators = new PrefilteredEnvMapFaceGenerator[6]; final JobState jobState = new JobState(new ScheduledThreadPoolExecutor(7)); irrShGenerator = new IrradianceSphericalHarmonicsGenerator(app, new JobListener(listener, jobState, probe, 6)); int size = envMap.getImage().getWidth(); irrShGenerator.setGenerationParam(EnvMapUtils.duplicateCubeMap(envMap), probe); jobState.executor.execute(irrShGenerator); for (int i = 0; i < pemGenerators.length; i++) { pemGenerators[i] = new PrefilteredEnvMapFaceGenerator(app, i, new JobListener(listener, jobState, probe, i)); pemGenerators[i].setGenerationParam(EnvMapUtils.duplicateCubeMap(envMap), size, EnvMapUtils.FixSeamsMethod.None, genType, probe.getPrefilteredEnvMap()); jobState.executor.execute(pemGenerators[i]); } }
/** * Internally called to generate the maps. * This method will spawn 7 thread (one for the Irradiance spherical harmonics generator, and one for each face of the prefiltered env map). * Those threads will be executed in a ScheduledThreadPoolExecutor that will be shutdown when the generation is done. * * @param envMap the raw env map rendered by the env camera * @param probe the LightProbe to generate maps for * @param app the Application * @param listener a progress listener. (can be null if no progress reporting is needed) */ private static void generatePbrMaps(TextureCubeMap envMap, final LightProbe probe, Application app, EnvMapUtils.GenerationType genType, final JobProgressListener<LightProbe> listener) { IrradianceSphericalHarmonicsGenerator irrShGenerator; PrefilteredEnvMapFaceGenerator[] pemGenerators = new PrefilteredEnvMapFaceGenerator[6]; final JobState jobState = new JobState(new ScheduledThreadPoolExecutor(7)); irrShGenerator = new IrradianceSphericalHarmonicsGenerator(app, new JobListener(listener, jobState, probe, 6)); int size = envMap.getImage().getWidth(); irrShGenerator.setGenerationParam(EnvMapUtils.duplicateCubeMap(envMap), probe); jobState.executor.execute(irrShGenerator); for (int i = 0; i < pemGenerators.length; i++) { pemGenerators[i] = new PrefilteredEnvMapFaceGenerator(app, i, new JobListener(listener, jobState, probe, i)); pemGenerators[i].setGenerationParam(EnvMapUtils.duplicateCubeMap(envMap), size, EnvMapUtils.FixSeamsMethod.None, genType, probe.getPrefilteredEnvMap()); jobState.executor.execute(pemGenerators[i]); } }