public bool init(Scene scene) { // check settings samples = Math.Max(0, samples); minSpacing = Math.Max(0.001f, minSpacing); maxSpacing = Math.Max(0.001f, maxSpacing); // display settings UI.printInfo(UI.Module.LIGHT, "Irradiance cache settings:"); UI.printInfo(UI.Module.LIGHT, " * Samples: %d", samples); if (tolerance <= 0) UI.printInfo(UI.Module.LIGHT, " * Tolerance: off"); else UI.printInfo(UI.Module.LIGHT, " * Tolerance: %.3f", tolerance); UI.printInfo(UI.Module.LIGHT, " * Spacing: %.3f to %.3f", minSpacing, maxSpacing); // prepare root node Vector3 ext = scene.getBounds().getExtents(); root = new Node(scene.getBounds().getCenter(), 1.0001f * MathUtils.max(ext.x, ext.y, ext.z), this); // init global photon map return (globalPhotonMap != null) ? scene.calculatePhotons(globalPhotonMap, "global", 0) : true; }
public bool init(Scene scene) { if (numSets < 1) numSets = 1; UI.printInfo(UI.Module.LIGHT, "Instant Global Illumination settings:"); UI.printInfo(UI.Module.LIGHT, " * Samples: {0}", numPhotons); UI.printInfo(UI.Module.LIGHT, " * Sets: {0}", numSets); UI.printInfo(UI.Module.LIGHT, " * Bias bound: {0}", c); UI.printInfo(UI.Module.LIGHT, " * Bias rays: {0}", numBias); virtualLights = new PointLight[numSets][]; if (numPhotons > 0) { for (int i = 0, seed = 0; i < virtualLights.Length; i++, seed += numPhotons) { PointLightStore map = new PointLightStore(this); if (!scene.calculatePhotons(map, "virtual", seed)) return false; virtualLights[i] = map.virtualLights.ToArray(); UI.printInfo(UI.Module.LIGHT, "Stored {0} virtual point lights for set {0} of {0}", virtualLights[i].Length, i + 1, numSets); } } else { // create an empty array for (int i = 0; i < virtualLights.Length; i++) virtualLights[i] = new PointLight[0]; } return true; }