Esempio n. 1
0
 public bool Update(ParameterList pl, SunflowAPI api)
 {
     function = pl.getInt("function", function);
     size = pl.getFloat("size", size);
     scale = pl.getFloat("scale", scale);
     return true;
 }
Esempio n. 2
0
 public virtual bool Update(ParameterList pl, SunflowAPI api)
 {
     bright = pl.getColor("bright", bright);
     dark = pl.getColor("dark", dark);
     samples = pl.getInt("samples", samples);
     maxDist = pl.getFloat("maxdist", maxDist);
     if (maxDist <= 0)
         maxDist = float.PositiveInfinity;
     return true;
 }
Esempio n. 3
0
        public bool update(ParameterList pl, SunflowAPI api)
        {
            int n = pl.getInt("transform.steps", 0);

            if (n <= 0)
            {
                // no motion blur, get regular arguments or leave unchanged
                updateCameraMatrix(-1, pl);
            }
            else
            {
                // new motion blur settings - get transform for each step
                c2w = new Matrix4[n];
                for (int i = 0; i < n; i++)
                {
                    if (!updateCameraMatrix(i, pl))
                    {
                        UI.printError(UI.Module.CAM, "Camera matrix for step {0} was not specified!", i + 1);
                        return(false);
                    }
                }
            }
            w2c = new Matrix4[c2w.Length];
            for (int i = 0; i < c2w.Length; i++)
            {
                if (c2w[i] != null)
                {
                    w2c[i] = c2w[i].inverse();
                    if (w2c[i] == null)
                    {
                        UI.printError(UI.Module.CAM, "Camera matrix is not invertible");
                        return(false);
                    }
                }
                else
                {
                    w2c[i] = null;
                }
            }
            return(lens.update(pl, api));
        }
Esempio n. 4
0
 public bool Update(ParameterList pl, SunflowAPI api)
 {
     nx = pl.getInt("resolutionX", nx);
     ny = pl.getInt("resolutionY", ny);
     nz = pl.getInt("resolutionZ", nz);
     voxelwx = 2.0f / nx;
     voxelwy = 2.0f / ny;
     voxelwz = 2.0f / nz;
     invVoxelwx = 1 / voxelwx;
     invVoxelwy = 1 / voxelwy;
     invVoxelwz = 1 / voxelwz;
     return true;
 }
Esempio n. 5
0
 public bool Update(ParameterList pl, SunflowAPI api)
 {
     diff = pl.getColor("diffuse", diff);
     spec = pl.getColor("specular", spec);
     string filename;
     filename = pl.getstring("diffuse.texture", null);
     if (filename != null)
         diffmap = TextureCache.getTexture(api.resolveTextureFilename(filename), false);
     filename = pl.getstring("specular.texture", null);
     if (filename != null)
         specmap = TextureCache.getTexture(api.resolveTextureFilename(filename), false);
     diffBlend = MathUtils.clamp(pl.getFloat("diffuse.blend", diffBlend), 0, 1);
     specBlend = MathUtils.clamp(pl.getFloat("specular.blend", diffBlend), 0, 1);
     glossyness = MathUtils.clamp(pl.getFloat("glossyness", glossyness), 0, 1);
     numSamples = pl.getInt("samples", numSamples);
     return true;
 }
Esempio n. 6
0
 public bool update(ParameterList pl, SunflowAPI api)
 {
     Vector3 up = pl.getVector("up", null);
     Vector3 east = pl.getVector("east", null);
     if (up != null && east != null)
         basis = OrthoNormalBasis.makeFromWV(up, east);
     else if (up != null)
         basis = OrthoNormalBasis.makeFromW(up);
     numSkySamples = pl.getInt("samples", numSkySamples);
     sunDirWorld = pl.getVector("sundir", sunDirWorld);
     turbidity = pl.getFloat("turbidity", turbidity);
     // recompute model
     initSunSky();
     return true;
 }
Esempio n. 7
0
 public virtual bool update(ParameterList pl, SunflowAPI api)
 {
     rhoD = pl.getColor("diffuse", rhoD);
     rhoS = pl.getColor("specular", rhoS);
     alphaX = pl.getFloat("roughnessX", alphaX);
     alphaY = pl.getFloat("roughnessY", alphaY);
     numRays = pl.getInt("samples", numRays);
     return true;
 }
Esempio n. 8
0
 public override bool update(ParameterList pl, SunflowAPI api)
 {
     radiance = pl.getColor("radiance", radiance);
     numSamples = pl.getInt("samples", numSamples);
     return base.update(pl, api);
 }
Esempio n. 9
0
 public bool Update(ParameterList pl, SunflowAPI api)
 {
     ParameterList.FloatParameter p = pl.getPointArray("particles");
     if (p != null)
         particles = p.data;
     r = pl.getFloat("radius", r);
     r2 = r * r;
     n = pl.getInt("num", n);
     return particles != null && n <= (particles.Length / 3);
 }
Esempio n. 10
0
 public bool Update(ParameterList pl, SunflowAPI api)
 {
     // get parameters
     fov = pl.getFloat("fov", fov);
     aspect = pl.getFloat("aspect", aspect);
     shiftX = pl.getFloat("shift.x", shiftX);
     shiftY = pl.getFloat("shift.y", shiftY);
     focusDistance = pl.getFloat("focus.distance", focusDistance);
     lensRadius = pl.getFloat("lens.radius", lensRadius);
     lensSides = pl.getInt("lens.sides", lensSides);
     lensRotation = pl.getFloat("lens.rotation", lensRotation);
     Update();
     return true;
 }
Esempio n. 11
0
        public bool Update(ParameterList pl, SunflowAPI api)
        {
            Point3 corner0 = pl.getPoint("corner0", null);
            Point3 corner1 = pl.getPoint("corner1", null);
            if (corner0 != null && corner1 != null)
            {
                updateGeometry(corner0, corner1);
            }

            // shader colors
            left = pl.getColor("leftColor", left);
            right = pl.getColor("rightColor", right);
            top = pl.getColor("topColor", top);
            bottom = pl.getColor("bottomColor", bottom);
            back = pl.getColor("backColor", back);

            // light
            radiance = pl.getColor("radiance", radiance);
            samples = pl.getInt("samples", samples);
            return true;
        }
Esempio n. 12
0
 public bool update(ParameterList pl, SunflowAPI api)
 {
     maxIterations = pl.getInt("iterations", maxIterations);
     epsilon = pl.getFloat("epsilon", epsilon);
     cw = pl.getFloat("cw", cw);
     cx = pl.getFloat("cx", cx);
     cy = pl.getFloat("cy", cy);
     cz = pl.getFloat("cz", cz);
     return true;
 }
Esempio n. 13
0
        public bool update(ParameterList pl, SunflowAPI api)
        {
            numSegments = pl.getInt("segments", numSegments);
            if (numSegments < 1)
            {
                UI.printError(UI.Module.HAIR, "Invalid number of segments: {0}", numSegments);
                return false;
            }
            ParameterList.FloatParameter pointsP = pl.getPointArray("points");
            if (pointsP != null)
            {
                if (pointsP.interp != ParameterList.InterpolationType.VERTEX)
                    UI.printError(UI.Module.HAIR, "Point interpolation type must be set to \"vertex\" - was \"{0}\"", pointsP.interp.ToString().ToLower());
                else
                {
                    points = pointsP.data;
                }
            }
            if (points == null)
            {
                UI.printError(UI.Module.HAIR, "Unabled to update hair - vertices are missing");
                return false;
            }

            pl.setVertexCount(points.Length / 3);
            ParameterList.FloatParameter widthsP = pl.getFloatArray("widths");
            if (widthsP != null)
            {
                if (widthsP.interp == ParameterList.InterpolationType.NONE || widthsP.interp == ParameterList.InterpolationType.VERTEX)
                    widths = widthsP;
                else
                    UI.printWarning(UI.Module.HAIR, "Width interpolation type {0} is not supported -- ignoring", widthsP.interp.ToString().ToLower());
            }
            return true;
        }
Esempio n. 14
0
 public virtual bool update(ParameterList pl, SunflowAPI api)
 {
     diff = pl.getColor("diffuse", diff);
     spec = pl.getColor("specular", spec);
     power = pl.getFloat("power", power);
     numRays = pl.getInt("samples", numRays);
     return true;
 }
Esempio n. 15
0
        public bool Update(ParameterList pl, SunflowAPI api)
        {
            updateBasis(pl.getVector("center", null), pl.getVector("up", null));
            numSamples = pl.getInt("samples", numSamples);
            numLowSamples = pl.getInt("lowsamples", numLowSamples);

            string filename = pl.getstring("texture", null);
            if (filename != null)
                texture = TextureCache.getTexture(api.resolveTextureFilename(filename), false);

            // no texture provided
            if (texture == null)
                return false;
            Bitmap b = texture.getBitmap();
            if (b == null)
                return false;

            // rebuild histograms if this is a new texture
            if (filename != null) {
                imageHistogram = new float[b.getWidth()][];
                for(int i = 0;i < imageHistogram.Length;i++)
                    imageHistogram[i] = new float[b.getHeight()];
                    colHistogram = new float[b.getWidth()];
                    float du = 1.0f / b.getWidth();
                    float dv = 1.0f / b.getHeight();
                    for (int x = 0; x < b.getWidth(); x++) {
                        for (int y = 0; y < b.getHeight(); y++) {
                        float u = (x + 0.5f) * du;
                        float v = (y + 0.5f) * dv;
                        Color c = texture.getPixel(u, v);
                        imageHistogram[x][y] = c.getLuminance() * (float) Math.Sin(Math.PI * v);
                        if (y > 0)
                            imageHistogram[x][y] += imageHistogram[x][y - 1];
                    }
                    colHistogram[x] = imageHistogram[x][b.getHeight() - 1];
                    if (x > 0)
                        colHistogram[x] += colHistogram[x - 1];
                    for (int y = 0; y < b.getHeight(); y++)
                        imageHistogram[x][y] /= imageHistogram[x][b.getHeight() - 1];
                }
                for (int x = 0; x < b.getWidth(); x++)
                    colHistogram[x] /= colHistogram[b.getWidth() - 1];
                jacobian = (float) (2 * Math.PI * Math.PI) / (b.getWidth() * b.getHeight());
            }
            // take fixed samples
            if (pl.getbool("fixed", samples != null)) {
                // high density samples
                samples = new Vector3[numSamples];
                colors = new Color[numSamples];
                generateFixedSamples(samples, colors);
                // low density samples
                lowSamples = new Vector3[numLowSamples];
                lowColors = new Color[numLowSamples];
                generateFixedSamples(lowSamples, lowColors);
            } else {
                // turn off
                samples = lowSamples = null;
                colors = lowColors = null;
            }
            return true;
        }
Esempio n. 16
0
 public override bool Update(ParameterList pl, SunflowAPI api)
 {
     radiance = pl.getColor("radiance", radiance);
     numSamples = pl.getInt("samples", numSamples);
     if (base.Update(pl, api)) {
         // precompute triangle areas and normals
         areas = new float[getNumPrimitives()];
         ngs = new Vector3[getNumPrimitives()];
         totalArea = 0;
         for (int tri3 = 0, i = 0; tri3 < triangles.Length; tri3 += 3, i++) {
             int a = triangles[tri3 + 0];
             int b = triangles[tri3 + 1];
             int c = triangles[tri3 + 2];
             Point3 v0p = getPoint(a);
             Point3 v1p = getPoint(b);
             Point3 v2p = getPoint(c);
             ngs[i] = Point3.normal(v0p, v1p, v2p);
             areas[i] = 0.5f * ngs[i].Length();
             ngs[i].normalize();
             totalArea += areas[i];
         }
     } else
         return false;
     return true;
 }
Esempio n. 17
0
 public bool update(ParameterList pl, SunflowAPI api)
 {
     int n = pl.getInt("transform.steps", 0);
     if (n <= 0)
     {
         // no motion blur, get regular arguments or leave unchanged
         updateCameraMatrix(-1, pl);
     }
     else
     {
         // new motion blur settings - get transform for each step
         c2w = new Matrix4[n];
         for (int i = 0; i < n; i++)
         {
             if (!updateCameraMatrix(i, pl))
             {
                 UI.printError(UI.Module.CAM, "Camera matrix for step {0} was not specified!", i + 1);
                 return false;
             }
         }
     }
     w2c = new Matrix4[c2w.Length];
     for (int i = 0; i < c2w.Length; i++)
     {
         if (c2w[i] != null)
         {
             w2c[i] = c2w[i].inverse();
             if (w2c[i] == null)
             {
                 UI.printError(UI.Module.CAM, "Camera matrix is not invertible");
                 return false;
             }
         }
         else
             w2c[i] = null;
     }
     return lens.update(pl, api);
 }
Esempio n. 18
0
 public bool update(ParameterList pl, SunflowAPI api)
 {
     radiance = pl.getColor("radiance", radiance);
     numSamples = pl.getInt("samples", numSamples);
     radius = pl.getFloat("radius", radius);
     r2 = radius * radius;
     center = pl.getPoint("center", center);
     return true;
 }
Esempio n. 19
0
        public bool update(ParameterList pl, SunflowAPI api)
        {
            updateBasis(pl.getVector("center", null), pl.getVector("up", null));
            numSamples = pl.getInt("samples", numSamples);

            string filename = pl.getstring("texture", null);
            if (filename != null)
            texture = TextureCache.getTexture(api.resolveTextureFilename(filename), true);

            // no texture provided
            if (texture == null)
            return false;
            Bitmap b = texture.getBitmap();
            if (b == null)
            return false;

            // rebuild histograms if this is a new texture
            if (filename != null) {
            imageHistogram = new float[b.Width][];
            for(int i = 0;i < imageHistogram.Length;i++)
                imageHistogram[i] = new float[b.Height];
            colHistogram = new float[b.Width];
            float du = 1.0f / b.Width;
            float dv = 1.0f / b.Height;
            for (int x = 0; x < b.Width; x++) {
                for (int y = 0; y < b.Height; y++) {
                    float u = (x + 0.5f) * du;
                    float v = (y + 0.5f) * dv;
                    Color c = texture.getPixel(u, v);
                    // box filter the image
                    // c.add(texture.getPixel(u + du, v));
                    // c.add(texture.getPixel(u + du, v+ dv));
                    // c.add(texture.getPixel(u, v + dv));
                    // c.mul(0.25f);
                    imageHistogram[x][y] = c.getLuminance() * (float) Math.Sin(Math.PI * v);
                    if (y > 0)
                        imageHistogram[x][y] += imageHistogram[x][y - 1];
                }
                colHistogram[x] = imageHistogram[x][b.Height - 1];
                if (x > 0)
                    colHistogram[x] += colHistogram[x - 1];
                for (int y = 0; y < b.Height; y++)
                    imageHistogram[x][y] /= imageHistogram[x][b.Height - 1];
            }
            for (int x = 0; x < b.Width; x++)
                colHistogram[x] /= colHistogram[b.Width - 1];
            jacobian = (float) (2 * Math.PI * Math.PI) / (b.Width * b.Height);
            }
            // take fixed samples
            if (pl.getbool("fixed", samples != null)) {
            // Bitmap loc = new Bitmap(filename);
            samples = new Vector3[numSamples];
            colors = new Color[numSamples];
            for (int i = 0; i < numSamples; i++) {
                double randX = (double) i / (double) numSamples;
                double randY = QMC.halton(0, i);
                int x = 0;
                while (randX >= colHistogram[x] && x < colHistogram.Length - 1)
                    x++;
                float[] rowHistogram = imageHistogram[x];
                int y = 0;
                while (randY >= rowHistogram[y] && y < rowHistogram.Length - 1)
                    y++;
                // sample from (x, y)
                float u = (float) ((x == 0) ? (randX / colHistogram[0]) : ((randX - colHistogram[x - 1]) / (colHistogram[x] - colHistogram[x - 1])));
                float v = (float) ((y == 0) ? (randY / rowHistogram[0]) : ((randY - rowHistogram[y - 1]) / (rowHistogram[y] - rowHistogram[y - 1])));

                float px = ((x == 0) ? colHistogram[0] : (colHistogram[x] - colHistogram[x - 1]));
                float py = ((y == 0) ? rowHistogram[0] : (rowHistogram[y] - rowHistogram[y - 1]));

                float su = (x + u) / colHistogram.Length;
                float sv = (y + v) / rowHistogram.Length;

                float invP = (float) Math.Sin(sv * Math.PI) * jacobian / (numSamples * px * py);
                samples[i] = getDirection(su, sv);
                basis.transform(samples[i]);
                colors[i] = texture.getPixel(su, sv).mul(invP);
                // loc.setPixel(x, y, Color.YELLOW.copy().mul(1e6f));
            }
            // loc.save("samples.hdr");
            } else {
            // turn off
            samples = null;
            colors = null;
            }
            return true;
        }
Esempio n. 20
0
 public bool update(ParameterList pl, SunflowAPI api)
 {
     subdivs = pl.getInt("subdivs", subdivs);
     smooth = pl.getbool("smooth", smooth);
     quads = pl.getbool("quads", quads);
     int nu = pl.getInt("nu", 0);
     int nv = pl.getInt("nv", 0);
     pl.setVertexCount(nu * nv);
     bool uwrap = pl.getbool("uwrap", false);
     bool vwrap = pl.getbool("vwrap", false);
     ParameterList.FloatParameter points = pl.getPointArray("points");
     if (points != null && points.interp == ParameterList.InterpolationType.VERTEX)
     {
         int numUPatches = uwrap ? nu / 3 : (nu - 4) / 3 + 1;
         int numVPatches = vwrap ? nv / 3 : (nv - 4) / 3 + 1;
         if (numUPatches < 1 || numVPatches < 1)
         {
             UI.printError(UI.Module.GEOM, "Invalid number of patches for bezier mesh - ignoring");
             return false;
         }
         // generate patches
         patches = new float[numUPatches * numVPatches][];
         for (int v = 0, p = 0; v < numVPatches; v++)
         {
             for (int u = 0; u < numUPatches; u++, p++)
             {
                 float[] patch = patches[p] = new float[16 * 3];
                 int up = u * 3;
                 int vp = v * 3;
                 for (int pv = 0; pv < 4; pv++)
                 {
                     for (int pu = 0; pu < 4; pu++)
                     {
                         int meshU = (up + pu) % nu;
                         int meshV = (vp + pv) % nv;
                         // copy point
                         patch[3 * (pv * 4 + pu) + 0] = points.data[3 * (meshU + nu * meshV) + 0];
                         patch[3 * (pv * 4 + pu) + 1] = points.data[3 * (meshU + nu * meshV) + 1];
                         patch[3 * (pv * 4 + pu) + 2] = points.data[3 * (meshU + nu * meshV) + 2];
                     }
                 }
             }
         }
     }
     if (subdivs < 1)
     {
         UI.printError(UI.Module.GEOM, "Invalid subdivisions for bezier mesh - ignoring");
         return false;
     }
     if (patches == null)
     {
         UI.printError(UI.Module.GEOM, "No patch data present in bezier mesh - ignoring");
         return false;
     }
     return true;
 }