public void build() { DestroyRenderAreaTexture(); texture = new Texture2D(200, 200); GameObject.Find("ViewRectangle").GetComponent <MeshRenderer> ().material.mainTexture = texture; vp = new ViewPlane(texture.width, texture.height, 1.0f, 100); background_color = Constants.black; tracer_ptr = new AreaLightTracer(this); Ambient ambLight = new Ambient(); ambLight.set_color(new Color(1, 1, 1, 1)); ambLight.scale_radiance(1.0f); set_ambient_light(ambLight); PerspectiveCamera pinhole_ptr1 = new PerspectiveCamera(); set_camera(pinhole_ptr1); Emissive ems = new Emissive(); ems.scale_radiance(40.0f); ems.set_ce(new Color(1, 0, 0, 1)); //Create Sky Object Sky sky = new Sky(); sky.sphereCenter = new Vector3(0, 0, 0); sky.sphereRad = 20000.0f; sky.set_material(ems); add_object(sky); //Create Environment Light Environment envLight = new Environment(); envLight.set_material(ems); envLight.SetSampler(new Regular(100)); add_light(envLight); Matte mat_ptr = new Matte(); mat_ptr.set_ka(0.25f); mat_ptr.set_kd(0.65f); mat_ptr.set_cd(new Color(1, 1, 0, 1)); Sphere sphere = new Sphere(); sphere.sphereCenter = new Vector3(-20, 0, 0); sphere.sphereRad = 30.0f; sphere.set_material(mat_ptr); add_object(sphere); render_scene(); }
void MatteRender() { DestroyRenderAreaTexture(); texture = new Texture2D(200, 200); GameObject.Find("ViewRectangle").GetComponent <MeshRenderer>().material.mainTexture = texture; vp = new ViewPlane(texture.width, texture.height, 1.0f, 1); vp.max_depth = 1; background_color = Constants.white; Ambient ambLight = new Ambient(); ambLight.set_color(new Color(1, 1, 1, 1)); ambLight.scale_radiance(1.0f); set_ambient_light(ambLight); PerspectiveCamera pinhole_ptr1 = new PerspectiveCamera(); pinhole_ptr1.set_eye(new Vector3(0, 0, 500)); pinhole_ptr1.set_lookat(Vector3.zero); pinhole_ptr1.set_view_distance(500.0f); pinhole_ptr1.compute_uvw(); set_camera(pinhole_ptr1); Directional directional = new Directional(); directional.set_color(new Color(1, 1, 1, 1)); directional.set_direction(new Vector3(0, -1, 0)); directional.cast_shadows = false; directional.scale_radiance(3.0f); add_light(directional); tracer_ptr = new RayCastTracer(this); TextureData textData = new TextureData(); Model ground = new Model("Quad/Quad", "Quad/Quad_Tex", 1, out textData); SV_Matte mat_ptr = new SV_Matte(); mat_ptr.set_ka(0.25f); mat_ptr.set_kd(0.5f); mat_ptr.set_cd(textData); ground.SetMaterial(mat_ptr); ground.set_identity(); ground.Rotate(Constants.PI / 2, 0, 0); ground.Scale(600, 1, 1000); ground.Translate(0, -100, 0); textData = new TextureData(); Model rightSphere = new Model("Sphere/Sphere", "Sphere/Sphere_Ball_Tex", 2, out textData); mat_ptr = new SV_Matte(); mat_ptr.set_ka(0.25f); mat_ptr.set_kd(0.5f); mat_ptr.set_cd(textData); rightSphere.SetMaterial(mat_ptr); rightSphere.set_identity(); rightSphere.Scale(40, 40, 40); rightSphere.Translate(50.0f, -60, 80); Model leftSphere = new Model("Sphere/Sphere", "Sphere/Sphere_Ball_Tex", 2, out textData); mat_ptr = new SV_Matte(); mat_ptr.set_ka(0.25f); mat_ptr.set_kd(0.5f); mat_ptr.set_cd(textData); leftSphere.SetMaterial(mat_ptr); leftSphere.set_identity(); leftSphere.Scale(40, 40, 40); leftSphere.Translate(-50.0f, -60, 80); Model cube = new Model("Cube/Cube", "Cube/Cube_Tex", 2, out textData); mat_ptr = new SV_Matte(); mat_ptr.set_ka(0.25f); mat_ptr.set_kd(0.5f); mat_ptr.set_cd(textData); cube.SetMaterial(mat_ptr); cube.set_identity(); cube.Scale(40, 100, 40); cube.Translate(0.0f, -40, -200); Model pyramid = new Model("Pyramid/Pyramid", "Pyramid/Pyramid_Tex", 2, out textData); mat_ptr = new SV_Matte(); mat_ptr.set_ka(0.25f); mat_ptr.set_kd(0.5f); mat_ptr.set_cd(textData); pyramid.SetMaterial(mat_ptr); pyramid.set_identity(); pyramid.Scale(80, 100, 40); pyramid.Translate(-100.0f, -50, -800); Model pyramidRight = new Model("Pyramid/Pyramid", "Pyramid/Pyramid_Tex", 2, out textData); mat_ptr = new SV_Matte(); mat_ptr.set_ka(0.25f); mat_ptr.set_kd(0.5f); mat_ptr.set_cd(textData); pyramidRight.SetMaterial(mat_ptr); pyramidRight.set_identity(); pyramidRight.Scale(80, 100, 40); pyramidRight.Translate(120.0f, -50, -800); Model cubeLeft = new Model("Cube/Cube", "Cube/Cube_Tex", 2, out textData); mat_ptr = new SV_Matte(); mat_ptr.set_ka(0.25f); mat_ptr.set_kd(0.5f); mat_ptr.set_cd(textData); cubeLeft.SetMaterial(mat_ptr); cubeLeft.set_identity(); cubeLeft.Scale(40, 100, 40); cubeLeft.Translate(-100.0f, -40, -100); Model cubeRight = new Model("Cube/Cube", "Cube/Cube_Tex", 2, out textData); mat_ptr = new SV_Matte(); mat_ptr.set_ka(0.25f); mat_ptr.set_kd(0.5f); mat_ptr.set_cd(textData); cubeRight.SetMaterial(mat_ptr); cubeRight.set_identity(); cubeRight.Scale(40, 100, 40); cubeRight.Translate(100.0f, -40, -100); }
public void build() { DestroyRenderAreaTexture(); texture = new Texture2D(200, 200); GameObject.Find("ViewRectangle").GetComponent <MeshRenderer> ().material.mainTexture = texture; vp = new ViewPlane(texture.width, texture.height, 1.0f, 1); vp.max_depth = 5; tracer_ptr = new GlobalTracer(this); Ambient amblight = new Ambient(); amblight.scale_radiance(1.0f); amblight.set_color(new Color(1, 1, 1, 1)); set_ambient_light(amblight); PerspectiveCamera pinhole_ptr1 = new PerspectiveCamera(); pinhole_ptr1.set_eye(new Vector3(0, 0, 500)); pinhole_ptr1.set_lookat(Vector3.zero); pinhole_ptr1.set_view_distance(600.0f); pinhole_ptr1.compute_uvw(); set_camera(pinhole_ptr1); Directional directional = new Directional(); directional.set_color(new Color(1, 1, 1, 1)); directional.set_direction(new Vector3(-1, -1, 0)); directional.cast_shadows = false; directional.scale_radiance(3.0f); add_light(directional); Reflective mat_ptr = new Reflective(); mat_ptr.set_kr(1.0f); mat_ptr.set_exp(1.0f); mat_ptr.set_cr(sphere_1_col); Sphere sphere = new Sphere(); sphere.sphereCenter = new Vector3(0, 0, 0); sphere.sphereRad = 1.0f; sphere.set_material(mat_ptr); Instance sphereInst = new Instance(sphere); sphereInst.set_material(mat_ptr); add_object(sphereInst); sphereInst.set_identity(); sphereInst.Scale(20, 20, 20); sphereInst.Translate(60.0f, 20.0f, 0); Matte mat_ptr1 = new Matte(); mat_ptr1.ambient_brdf.Set_Sampler(100, 0.5f); mat_ptr1.diffuse_brdf.Set_Sampler(100, 0.5f); mat_ptr1.set_ka(1.0f); mat_ptr1.set_kd(1); mat_ptr1.set_cd(plane_col); Plane p = new Plane(); p.planeNormal = new Vector3(0, 1, 0); p.planePassThrghPnt = new Vector3(0, -20, 0); p.set_material(mat_ptr1); add_object(p); Emissive mat_ptr2 = new Emissive(); mat_ptr2.scale_radiance(1); mat_ptr2.set_ce(sphere_2_col); Sphere sphere1 = new Sphere(); sphere1.sphereCenter = new Vector3(0, 0, 0); sphere1.sphereRad = 1.0f; sphere1.set_material(mat_ptr2); Instance sphereInst1 = new Instance(sphere1); sphereInst1.set_material(mat_ptr2); add_object(sphereInst1); sphereInst1.set_identity(); sphereInst1.Scale(20, 20, 20); sphereInst1.Translate(-60.0f, 20.0f, 0); render_scene(); }