コード例 #1
0
ファイル: CausticPhotonMap.cs プロジェクト: rzel/sunflowsharp
 public CausticPhotonMap(Options options)
 {
     _numEmit = options.getInt("caustics.emit", 10000);
     gatherNum = options.getInt("caustics.gather", 50);
     gatherRadius = options.getFloat("caustics.radius", 0.5f);
     filterValue = options.getFloat("caustics.filter", 1.1f);
     bounds = new BoundingBox();
     maxPower = 0;
     maxRadius = 0;
 }
コード例 #2
0
ファイル: InstantGI.cs プロジェクト: rzel/sunflowsharp
 public InstantGI(Options options)
 {
     numPhotons = options.getInt("gi.igi.samples", 64);
     numSets = options.getInt("gi.igi.sets", 1);
     c = options.getFloat("gi.igi.c", 0.00003f);
     numBias = options.getInt("gi.igi.bias_samples", 0);
     virtualLights = null;
 }
コード例 #3
0
 public AmbientOcclusionGIEngine(Options options)
 {
     bright = options.getColor("gi.ambocc.bright", Color.WHITE);
     dark = options.getColor("gi.ambocc.dark", Color.BLACK);
     samples = options.getInt("gi.ambocc.samples", 32);
     maxDist = options.getFloat("gi.ambocc.maxdist", 0);
     maxDist = (maxDist <= 0) ? float.PositiveInfinity : maxDist;
 }
コード例 #4
0
 public bool init(Options options, Scene scene)
 {
     bright = options.getColor("gi.ambocc.bright", Color.WHITE);
     dark = options.getColor("gi.ambocc.dark", Color.BLACK);
     samples = options.getInt("gi.ambocc.samples", 32);
     maxDist = options.getFloat("gi.ambocc.maxdist", 0);
     maxDist = (maxDist <= 0) ? float.PositiveInfinity : maxDist;
     return true;
 }
コード例 #5
0
 public IrradianceCacheGIEngine(Options options)
 {
     samples = options.getInt("gi.irr-cache.samples", 256);
     tolerance = options.getFloat("gi.irr-cache.tolerance", 0.05f);
     invTolerance = 1.0f / tolerance;
     minSpacing = options.getFloat("gi.irr-cache.min_spacing", 0.05f);
     maxSpacing = options.getFloat("gi.irr-cache.max_spacing", 5.00f);
     root = null;
     //rwl = new ReentrantReadWriteLock();
     globalPhotonMap = null;
     string gmap = options.getstring("gi.irr-cache.gmap", null);
     if (gmap == null || gmap == "none")
         return;
     int numEmit = options.getInt("gi.irr-cache.gmap.emit", 100000);
     int gather = options.getInt("gi.irr-cache.gmap.gather", 50);
     float radius = options.getFloat("gi.irr-cache.gmap.radius", 0.5f);
     if (gmap == "kd")
         globalPhotonMap = new GlobalPhotonMap(numEmit, gather, radius);
     else if (gmap == "grid")
         globalPhotonMap = new GridPhotonMap(numEmit, gather, radius);
     else
         UI.printWarning(UI.Module.LIGHT, "Unrecognized global photon map type \"%s\" - ignoring", gmap);
 }
コード例 #6
0
 public void prepare(Options options, BoundingBox sceneBounds)
 {
     // get settings
     _numEmit = options.getInt("gi.irr-cache.gmap.emit", 100000);
     numGather = options.getInt("gi.irr-cache.gmap.gather", 50);
     gatherRadius = options.getFloat("gi.irr-cache.gmap.radius", 0.5f);
     // init
     bounds = new BoundingBox(sceneBounds);
     bounds.enlargeUlps();
     Vector3 w = bounds.getExtents();
     nx = (int)Math.Max(((w.x / gatherRadius) + 0.5f), 1);
     ny = (int)Math.Max(((w.y / gatherRadius) + 0.5f), 1);
     nz = (int)Math.Max(((w.z / gatherRadius) + 0.5f), 1);
     int numCells = nx * ny * nz;
     UI.printInfo(UI.Module.LIGHT, "Initializing grid photon map:");
     UI.printInfo(UI.Module.LIGHT, "  * Resolution:  {0}x{1}x{2}", nx, ny, nz);
     UI.printInfo(UI.Module.LIGHT, "  * Total cells: {0}", numCells);
     for (hashPrime = 0; hashPrime < PRIMES.Length; hashPrime++)
         if (PRIMES[hashPrime] > (numCells / 5))
             break;
     cellHash = new PhotonGroup[PRIMES[hashPrime]];
     UI.printInfo(UI.Module.LIGHT, "  * Initial hash size: {0}", cellHash.Length);
 }
コード例 #7
0
        public bool prepare(Options options, Scene scene, int w, int h)
        {
            this.scene = scene;
            imageWidth = w;
            imageHeight = h;

            // fetch options
            bucketSize = options.getInt("bucket.size", bucketSize);
            bucketOrderName = options.getstring("bucket.order", bucketOrderName);
            minAADepth = options.getInt("aa.min", minAADepth);
            maxAADepth = options.getInt("aa.max", maxAADepth);
            superSampling = options.getInt("aa.samples", superSampling);
            displayAA = options.getbool("aa.display", displayAA);
            jitter = options.getbool("aa.jitter", jitter);
            contrastThreshold = options.getFloat("aa.contrast", contrastThreshold);

            // limit bucket size and compute number of buckets in each direction
            bucketSize = MathUtils.clamp(bucketSize, 16, 512);
            int numBucketsX = (imageWidth + bucketSize - 1) / bucketSize;
            int numBucketsY = (imageHeight + bucketSize - 1) / bucketSize;
            bucketOrder = BucketOrderFactory.create(bucketOrderName);
            bucketCoords = bucketOrder.getBucketSequence(numBucketsX, numBucketsY);
            // validate AA options
            minAADepth = MathUtils.clamp(minAADepth, -4, 5);
            maxAADepth = MathUtils.clamp(maxAADepth, minAADepth, 5);
            superSampling = MathUtils.clamp(superSampling, 1, 256);
            invSuperSampling = 1.0 / superSampling;
            // compute AA stepping sizes
            subPixelSize = (maxAADepth > 0) ? (1 << maxAADepth) : 1;
            minStepSize = maxAADepth >= 0 ? 1 : 1 << (-maxAADepth);
            if (minAADepth == maxAADepth)
                maxStepSize = minStepSize;
            else
                maxStepSize = minAADepth > 0 ? 1 << minAADepth : subPixelSize << (-minAADepth);
            useJitter = jitter && maxAADepth > 0;
            // compute anti-aliasing contrast thresholds
            contrastThreshold = MathUtils.clamp(contrastThreshold, 0, 1);
            thresh = contrastThreshold * (float)Math.Pow(2.0f, minAADepth);
            // read filter settings from scene
            filterName = options.getstring("filter", filterName);
			filter = PluginRegistry.filterPlugins.createObject(filterName);
            // adjust filter
            if (filter == null)
            {
                UI.printWarning(UI.Module.BCKT, "Unrecognized filter type: \"{0}\" - defaulting to box", filterName);
                filter = new BoxFilter();
                filterName = "box";
            }
            fhs = filter.getSize() * 0.5f;
            fs = (int)Math.Ceiling(subPixelSize * (fhs - 0.5f));

            // prepare QMC sampling
			sigmaOrder = Math.Min(QMC.MAX_SIGMA_ORDER, Math.Max(0, maxAADepth) + 13); // FIXME: how big should the table be?
			sigmaLength = 1 << sigmaOrder;
            UI.printInfo(UI.Module.BCKT, "Bucket renderer settings:");
            UI.printInfo(UI.Module.BCKT, "  * Resolution:         {0}x{1}", imageWidth, imageHeight);
            UI.printInfo(UI.Module.BCKT, "  * Bucket size:        {0}", bucketSize);
            UI.printInfo(UI.Module.BCKT, "  * Number of buckets:  {0}x{1}", numBucketsX, numBucketsY);
            if (minAADepth != maxAADepth)
                UI.printInfo(UI.Module.BCKT, "  * Anti-aliasing:      {0} -> {1} (adaptive)", aaDepthTostring(minAADepth), aaDepthTostring(maxAADepth));
            else
                UI.printInfo(UI.Module.BCKT, "  * Anti-aliasing:      {0} (fixed)", aaDepthTostring(minAADepth));
            UI.printInfo(UI.Module.BCKT, "  * Rays per sample:    {0}", superSampling);
            UI.printInfo(UI.Module.BCKT, "  * Subpixel jitter:    {0}", useJitter ? "on" : (jitter ? "auto-off" : "off"));
            UI.printInfo(UI.Module.BCKT, "  * Contrast threshold: {0}", contrastThreshold);
            UI.printInfo(UI.Module.BCKT, "  * Filter type:        {0}", filterName);
            UI.printInfo(UI.Module.BCKT, "  * Filter size:        {0} pixels", filter.getSize());
            return true;
        }
コード例 #8
0
 public void prepare(Options options, BoundingBox sceneBounds)
 {
     // get settings
     _numEmit = options.getInt("gi.irr-cache.gmap.emit", 100000);
     numGather = options.getInt("gi.irr-cache.gmap.gather", 50);
     gatherRadius = options.getFloat("gi.irr-cache.gmap.radius", 0.5f);
     // init
     photonList = new List<Photon>();
     photonList.Add(null);
     photons = null;
     storedPhotons = halfStoredPhotons = 0;
 }
コード例 #9
0
 public bool init(Options options, Scene scene)
 {
     numPhotons = options.getInt("gi.igi.samples", 64);
     numSets = options.getInt("gi.igi.sets", 1);
     c = options.getFloat("gi.igi.c", 0.00003f);
     numBias = options.getInt("gi.igi.bias_samples", 0);
     virtualLights = null;
     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, options))
                 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;
 }
コード例 #10
0
 public void prepare(Options options, BoundingBox sceneBounds)
 {
     // get options
     _numEmit = options.getInt("caustics.emit", 10000);
     gatherNum = options.getInt("caustics.gather", 50);
     gatherRadius = options.getFloat("caustics.radius", 0.5f);
     filterValue = options.getFloat("caustics.filter", 1.1f);
     bounds = new BoundingBox();
     // init
     maxPower = 0;
     maxRadius = 0;
     photonList = new List<Photon>();
     photonList.Add(null);
     photons = null;
     storedPhotons = halfStoredPhotons = 0;
 }