Beispiel #1
0
 public void init(string name, SunflowAPI api)
 {
     // register this object with the api properly
     api.geometry(name, this);
     api.shader(name + ".shader", this);
     api.parameter("shaders", name + ".shader");
     api.instance(name + ".instance", name);
     api.light(name + ".light", this);
 }
Beispiel #2
0
 public void init(string name, SunflowAPI api)
 {
     api.light(name, this);
     api.geometry(name + ".geo", new Sphere());
     api.shader(name + ".shader", this);
     api.parameter("shaders", name + ".shader");
     api.parameter("transform", Matrix4.translation(center.x, center.y, center.z).multiply(Matrix4.scale(radius)));
     api.instance(name + ".instance", name + ".geo");
 }
Beispiel #3
0
 public void init(string name, SunflowAPI api)
 {
     api.geometry(name, this);
     api.shader(name + ".shader", this);
     api.parameter("shaders", name + ".shader");
     api.instance(name + ".instance", name);
     for (int i = 0, j = 0; i < triangles.Length; i += 3, j++)
     {
         TriangleLight t = new TriangleLight(j, this);
         string lname = string.Format("%s.light[%d]", name, j);
         api.light(lname, t);
     }
 }
Beispiel #4
0
 public void init(string name, SunflowAPI api)
 {
     api.geometry(name, this);
     api.shader(name + ".shader", this);
     api.parameter("shaders", name + ".shader");
     api.instance(name + ".instance", name);
     for (int i = 0, j = 0; i < triangles.Length; i += 3, j++)
     {
         TriangleLight t     = new TriangleLight(j, this);
         string        lname = string.Format("%s.light[%d]", name, j);
         api.light(lname, t);
     }
 }
Beispiel #5
0
 public void init(string name, SunflowAPI api)
 {
     // register this object with the api properly
     api.geometry(name, this);
     if (api.lookupGeometry(name) == null)
     {
         // quit if we don't see our geometry in here (error message
         // will have already been printed)
         return;
     }
     api.shader(name + ".shader", this);
     api.parameter("shaders", name + ".shader");
     api.instance(name + ".instance", name);
     api.light(name + ".light", this);
 }
Beispiel #6
0
 public void init(string name, SunflowAPI api)
 {
     // register this object with the api properly
     api.geometry(name, this);
     if (api.lookupGeometry(name) == null)
     {
         // quit if we don't see our geometry in here (error message
         // will have already been printed)
         return;
     }
     api.shader(name + ".shader", this);
     api.parameter("shaders", name + ".shader");
     api.instance(name + ".instance", name);
     api.light(name + ".light", this);
 }
Beispiel #7
0
    public void SetupSunflow(SunflowAPI a)
    {
        a.parameter("threads", Environment.ProcessorCount);
        //          parameter ("threads", 1);
        a.options(SunflowAPI.DEFAULT_OPTIONS);
        //The render's resolution. 1920 by 1080 is full HD.
        int resolutionX = 3840;
        int resolutionY = 1920;

        //      resolutionX = 1920;
        //    resolutionY = 1920;

        resolutionX = 384 * 4;
        resolutionY = 192 * 4;
//		      int resolutionX = 3840;
//		      int resolutionY = 960;
        a.parameter("resolutionX", resolutionX);
        a.parameter("resolutionY", resolutionY);

        //The anti-aliasing. Negative is subsampling and positive is supersampling.
        a.parameter("aa.min", 1);
        a.parameter("aa.max", 2);

        //Number of samples.
        a.parameter("aa.samples", 1);

        //The contrast needed to increase anti-aliasing.
        a.parameter("aa.contrast", .016f);

        //Subpixel jitter.
        a.parameter("aa.jitter", true);

        //The filter.
        a.parameter("filter", "mitchell");
        a.options(SunflowAPI.DEFAULT_OPTIONS);



//				Point3 eye = new Point3(7.0f, -7.0f, -7.0f);
//				Point3 target = new Point3(0.0f, -7.0f, 0.0f);


        Point3  target = new Point3(7.0f, -7.0f, -7.0f);
        Point3  eye    = new Point3(-6.0f, -10.0f, 2.0f);
        Vector3 up     = new Vector3(0, 1, 0);

        a.parameter("transform", Matrix4.lookAt(eye, target, up));

        String name = "Camera";


        /*     thinlens camera */

        /*
         *      //Aspect Ratio.
         *      float aspect = ((float)resolutionX) / ((float)resolutionY);
         *      a.parameter("aspect", aspect);
         *      a.camera(name, "thinlens");
         */

        /* 360 3D VR camera */

        /*
         *
         *      a.parameter("lens.eyegap", 0.5f);
         * //		a.camera(name, "spherical3d");
         *
         *      a.camera(name, "spherical1803d");
         *
         *
         */
        a.parameter("lens.eyegap", 0.1f);
        a.camera(name, "vr180fisheye");


        a.parameter("camera", name);
        a.options(SunflowAPI.DEFAULT_OPTIONS);

        //Trace depths. Higher numbers look better.
        a.parameter("depths.diffuse", 3);
        a.parameter("depths.reflection", 2);
        a.parameter("depths.refraction", 2);
        a.options(SunflowAPI.DEFAULT_OPTIONS);

        //Setting up the shader for the ground.
        a.parameter("diffuse", null, 0.4f, 0.4f, 0.4f);
        a.parameter("shiny", .1f);
        a.shader("ground", "shiny_diffuse");
        a.options(SunflowAPI.DEFAULT_OPTIONS);

        //Setting up the shader for the big metal sphere.
        a.parameter("diffuse", null, 0.3f, 0.3f, 0.3f);
        a.parameter("shiny", .95f);
        a.shader("metal", "shiny_diffuse");
        a.options(SunflowAPI.DEFAULT_OPTIONS);


        //Setting up the shader for the cube of spheres.
        a.parameter("diffuse", null, 1.0f, 0.0f, 0.0f);
        a.shader("sps", "diffuse");
        a.options(SunflowAPI.DEFAULT_OPTIONS);

        //Instancing the floor.
        a.parameter("center", new Point3(0, -14.2f, 0));
        a.parameter("normal", new Vector3(0, 1, 0));
        a.geometry("floor", "plane");
        a.parameter("shaders", "ground");
        a.instance("FloorInstance", "floor");
        a.options(SunflowAPI.DEFAULT_OPTIONS);

        //Creating the lighting system with the sun and sky.
        a.parameter("up", new Vector3(0, 1, 0));
        a.parameter("east", new Vector3(1, 0, 0));
        //            double sunRad = (Math.PI * 1.05);
        //          a.parameter("sundir", new Vector3((float)Math.Cos(sunRad), (float)Math.Sin(sunRad), (float)(.5 * Math.Sin(sunRad))).normalize());
        a.parameter("sundir", new Vector3(0.8f, 0.8f, 0.5f).normalize());
        a.parameter("turbidity", 4f);
        a.parameter("samples", 128);
        a.light("sunsky", "sunsky");
        a.options(SunflowAPI.DEFAULT_OPTIONS);
    }
Beispiel #8
0
 public void init(string name, SunflowAPI api)
 {
     // register this object with the api properly
     api.geometry(name, this);
     api.shader(name + ".shader", this);
     api.parameter("shaders", name + ".shader");
     api.instance(name + ".instance", name);
     api.light(name + ".light", this);
 }
Beispiel #9
0
 public void init(string name, SunflowAPI api)
 {
     api.light(name, this);
     api.geometry(name + ".geo", new Sphere());
     api.shader(name + ".shader", this);
     api.parameter("shaders", name + ".shader");
     api.parameter("transform", Matrix4.translation(center.x, center.y, center.z).multiply(Matrix4.scale(radius)));
     api.instance(name + ".instance", name + ".geo");
 }
Beispiel #10
0
 private void parseLightBlock(SunflowAPI api)
 {
     p.checkNextToken("{");
     p.checkNextToken("type");
     if (p.peekNextToken("mesh"))
     {
         UI.printWarning(UI.Module.API, "Deprecated light type: mesh");
         p.checkNextToken("name");
         string name = p.getNextToken();
         UI.printInfo(UI.Module.API, "Reading light mesh: {0} ...", name);
         p.checkNextToken("emit");
         api.parameter("radiance", parseColor());
         int samples = numLightSamples;
         if (p.peekNextToken("samples"))
             samples = p.getNextInt();
         else
             UI.printWarning(UI.Module.API, "Samples keyword not found - defaulting to {0}", samples);
         api.parameter("samples", samples);
         int numVertices = p.getNextInt();
         int numTriangles = p.getNextInt();
         float[] points = new float[3 * numVertices];
         int[] triangles = new int[3 * numTriangles];
         for (int i = 0; i < numVertices; i++)
         {
             p.checkNextToken("v");
             points[3 * i + 0] = p.getNextFloat();
             points[3 * i + 1] = p.getNextFloat();
             points[3 * i + 2] = p.getNextFloat();
             // ignored
             p.getNextFloat();
             p.getNextFloat();
             p.getNextFloat();
             p.getNextFloat();
             p.getNextFloat();
         }
         for (int i = 0; i < numTriangles; i++)
         {
             p.checkNextToken("t");
             triangles[3 * i + 0] = p.getNextInt();
             triangles[3 * i + 1] = p.getNextInt();
             triangles[3 * i + 2] = p.getNextInt();
         }
         api.parameter("points", "point", "vertex", points);
         api.parameter("triangles", triangles);
         TriangleMeshLight mesh = new TriangleMeshLight();
         mesh.init(name, api);
     }
     else if (p.peekNextToken("point"))
     {
         UI.printInfo(UI.Module.API, "Reading point light ...");
         Color pow;
         if (p.peekNextToken("color"))
         {
             pow = parseColor();
             p.checkNextToken("power");
             float po = p.getNextFloat();
             pow.mul(po);
         }
         else
         {
             UI.printWarning(UI.Module.API, "Deprecated color specification - please use color and power instead");
             p.checkNextToken("power");
             pow = parseColor();
         }
         p.checkNextToken("p");
         api.parameter("center", parsePoint());
         api.parameter("power", pow);
         api.light(api.getUniqueName("pointlight"), new PointLight());
     }
     else if (p.peekNextToken("spherical"))
     {
         UI.printInfo(UI.Module.API, "Reading spherical light ...");
         p.checkNextToken("color");
         Color pow = parseColor();
         p.checkNextToken("radiance");
         pow.mul(p.getNextFloat());
         api.parameter("radiance", pow);
         p.checkNextToken("center");
         api.parameter("center", parsePoint());
         p.checkNextToken("radius");
         api.parameter("radius", p.getNextFloat());
         p.checkNextToken("samples");
         api.parameter("samples", p.getNextInt());
         SphereLight light = new SphereLight();
         light.init(api.getUniqueName("spherelight"), api);
     }
     else if (p.peekNextToken("directional"))
     {
         UI.printInfo(UI.Module.API, "Reading directional light ...");
         p.checkNextToken("source");
         Point3 s = parsePoint();
         api.parameter("source", s);
         p.checkNextToken("target");
         Point3 t = parsePoint();
         api.parameter("dir", Point3.sub(t, s, new Vector3()));
         p.checkNextToken("radius");
         api.parameter("radius", p.getNextFloat());
         p.checkNextToken("emit");
         Color e = parseColor();
         if (p.peekNextToken("intensity"))
         {
             float i = p.getNextFloat();
             e.mul(i);
         }
         else
             UI.printWarning(UI.Module.API, "Deprecated color specification - please use emit and intensity instead");
         api.parameter("radiance", e);
         api.light(api.getUniqueName("dirlight"), new DirectionalSpotlight());
     }
     else if (p.peekNextToken("ibl"))
     {
         UI.printInfo(UI.Module.API, "Reading image based light ...");
         p.checkNextToken("image");
         api.parameter("texture", p.getNextToken());
         p.checkNextToken("center");
         api.parameter("center", parseVector());
         p.checkNextToken("up");
         api.parameter("up", parseVector());
         p.checkNextToken("lock");
         api.parameter("fixed", p.getNextbool());
         int samples = numLightSamples;
         if (p.peekNextToken("samples"))
             samples = p.getNextInt();
         else
             UI.printWarning(UI.Module.API, "Samples keyword not found - defaulting to {0}", samples);
         api.parameter("samples", samples);
         ImageBasedLight ibl = new ImageBasedLight();
         ibl.init(api.getUniqueName("ibl"), api);
     }
     else if (p.peekNextToken("meshlight"))
     {
         p.checkNextToken("name");
         string name = p.getNextToken();
         UI.printInfo(UI.Module.API, "Reading meshlight: {0} ...", name);
         p.checkNextToken("emit");
         Color e = parseColor();
         if (p.peekNextToken("radiance"))
         {
             float r = p.getNextFloat();
             e.mul(r);
         }
         else
             UI.printWarning(UI.Module.API, "Deprecated color specification - please use emit and radiance instead");
         api.parameter("radiance", e);
         int samples = numLightSamples;
         if (p.peekNextToken("samples"))
             samples = p.getNextInt();
         else
             UI.printWarning(UI.Module.API, "Samples keyword not found - defaulting to {0}", samples);
         api.parameter("samples", samples);
         // parse vertices
         p.checkNextToken("points");
         int np = p.getNextInt();
         api.parameter("points", "point", "vertex", parseFloatArray(np * 3));
         // parse triangle indices
         p.checkNextToken("triangles");
         int nt = p.getNextInt();
         api.parameter("triangles", parseIntArray(nt * 3));
         TriangleMeshLight mesh = new TriangleMeshLight();
         mesh.init(name, api);
     }
     else if (p.peekNextToken("sunsky"))
     {
         p.checkNextToken("up");
         api.parameter("up", parseVector());
         p.checkNextToken("east");
         api.parameter("east", parseVector());
         p.checkNextToken("sundir");
         api.parameter("sundir", parseVector());
         p.checkNextToken("turbidity");
         api.parameter("turbidity", p.getNextFloat());
         if (p.peekNextToken("samples"))
             api.parameter("samples", p.getNextInt());
         SunSkyLight sunsky = new SunSkyLight();
         sunsky.init(api.getUniqueName("sunsky"), api);
     }
     else
         UI.printWarning(UI.Module.API, "Unrecognized object type: {0}", p.getNextToken());
     p.checkNextToken("}");
 }