public ViewPlane(int hres, int vres) { HRes = hres; VRes = vres; BackBuffer = new WriteableBitmap(HRes, VRes, 96, 96, PixelFormats.Bgra32, null); SamplerRef = new MultiJittered(TestData.TestVPSampleCount); NumOfSample = SamplerRef.NumSamples; SamplerRef.Generate_Samples(); MaxDepth = TestData.TestMaxBounce; }
public void Build() { VP.PixelSize = 1.0; VP.Gamma = 1.0; BackgroundColor = PreDefColor.BlackColor; RayTracer = new PathTracer(this);//new WhittedTracer(this);//new AreaLighting(this);//new MultiObjects(this); Sampler AmbientSampler = new MultiJittered(TestData.TestSampleCount); Ambient AmbLt = new Ambient(); AmbLt.ls = 0.15f; AmbLt.MinAmount = 0.0f; AmbLt.Color = PreDefColor.WhiteColor; AmbLt.SetSampler(ref AmbientSampler); AmbientLight = AmbLt; Directional DirLt = new Directional(); DirLt.bCastShadow = true; DirLt.Dir = new Vector3D(90, 100, 0.0); DirLt.ls = 3.0f; DirLt.Color = PreDefColor.WhiteColor; Lights.Add(DirLt); Objects = new List <GeometryObject>(); GeometryObject TestSphere1 = new Sphere(new Vector3D(-60, 100, -230), 90.0); TestSphere1.Color = PreDefColor.RedColor; Reflective SphereMat = new Reflective(); SphereMat.AmbientBRDF.Kd = 0.0f; SphereMat.AmbientBRDF.Cd = PreDefColor.WhiteColor; SphereMat.DiffuseBRDF.Kd = 0.75f; SphereMat.DiffuseBRDF.Cd = TestSphere1.Color; SphereMat.DiffuseBRDF.SetSampler(ref AmbientSampler); SphereMat.SpecularBRDF.Kr = 0.6f; SphereMat.SpecularBRDF.Cr = TestSphere1.Color; TestSphere1.Material = SphereMat; //glossy //GlossyReflective RMat = new GlossyReflective(); //RMat.AmbientBRDF.Kd = 0.0f; //RMat.DiffuseBRDF.Kd = 0.0f; //RMat.DiffuseBRDF.Cd = PreDefColor.WhiteColor; //RMat.GlossySpecularBRDF.Ks = 0.9f; //RMat.GlossySpecularBRDF.Cs = PreDefColor.WhiteColor; //RMat.GlossySpecularBRDF.Exp = 1; //Sampler GlossySampler = new MultiJittered(TestData.TestSampleCount); //RMat.GlossySpecularBRDF.SetSampler(ref GlossySampler); //GlossySampler.MapSamplesToHemisphere(RMat.GlossySpecularBRDF.Exp); //TestSphere1.Material = RMat; AddRenderObjects(ref TestSphere1); GeometryObject TestSphere2 = new Sphere(new Vector3D(75, 15, -130), 60.0); TestSphere2.Color = PreDefColor.YellowColor; Matte SphereMat2 = new Matte(); SphereMat2.AmbientBRDF.Kd = 1.0f; SphereMat2.AmbientBRDF.Cd = PreDefColor.WhiteColor; SphereMat2.DiffuseBRDF.Kd = 0.75f; SphereMat2.DiffuseBRDF.Cd = TestSphere2.Color; SphereMat2.DiffuseBRDF.SetSampler(ref AmbientSampler); SphereMat2.SpecularBRDF.Ks = 0.25f; SphereMat2.SpecularBRDF.Exp = 2.0f; TestSphere2.Material = SphereMat2; AddRenderObjects(ref TestSphere2); GeometryObject TestPlane1 = new Plane(new Vector3D(0, 0, -200), new Vector3D(0.0, 1, 0.5)); TestPlane1.Color = PreDefColor.WhiteColor; Matte PlaneMat1 = new Matte(); PlaneMat1.AmbientBRDF.Kd = 5.0f; PlaneMat1.AmbientBRDF.Cd = PreDefColor.WhiteColor; PlaneMat1.DiffuseBRDF.Kd = 0.8f; PlaneMat1.DiffuseBRDF.Cd = TestPlane1.Color; PlaneMat1.SpecularBRDF.Ks = 0.25f; PlaneMat1.SpecularBRDF.Exp = 2.0f; PlaneMat1.DiffuseBRDF.SetSampler(ref AmbientSampler); TestPlane1.Material = PlaneMat1; AddRenderObjects(ref TestPlane1); //emissive light //Emissive ELight = new Emissive(); //ELight.ls = 40; //ELight.ce = PreDefColor.WhiteColor; //GeometryObject RectLight = new RectLight(new Vector3D(100, 0, 250), new Vector3D(10,10,10), new Vector3D(15,15,15), new Vector3D(0, 1, 0)); //RectLight.Material = ELight; //RectLight.SamplerRef = AmbientSampler; //AddRenderObjects(ref RectLight); //AreaLight AreaLt = new AreaLight(); //AreaLt.GeoObj = RectLight; //Lights.Add(AreaLt); //Emissive EnvLight = new Emissive(); //EnvLight.ls = 1.5f; //EnvLight.ce = new Vector3D(1.0, 1.0,0.5); //GeometryObject SphereEnv = new Sphere(PreDefColor.BlackColor, 10000); //SphereEnv.Material = EnvLight; //((Sphere)SphereEnv).bInside = true; //AddRenderObjects(ref SphereEnv); //EnviromentLight EvnLt = new EnviromentLight(); //EvnLt.Mat = EnvLight; //EvnLt.SamplerRef = AmbientSampler; //Lights.Add(EvnLt); }