public void FindSinglePointOnJitteredAreaLight( double u, double v, double rx, double ry, double rz) { var corner = Vector4.CreatePosition(0, 0, 0); var v1 = Vector4.CreateDirection(2, 0, 0); var v2 = Vector4.CreateDirection(0, 0, 1); var light = new AreaLight( corner, v1, 4, v2, 2, Color.White) { Jitter = new Sequence(0.3, 0.7), }; var pt = light.GetPoint(u, v); var expected = Vector4.CreatePosition(rx, ry, rz); Assert.Equal(expected, pt); }
public void AreaLightWithJitteredSamples( double px, double py, double pz, double result) { var w = new DefaultWorld(); var corner = Vector4.CreatePosition(-0.5, -0.5, -5); var v1 = Vector4.CreateDirection(1, 0, 0); var v2 = Vector4.CreateDirection(0, 1, 0); var light = new AreaLight( corner, v1, 2, v2, 2, Color.White) { Jitter = new Sequence(0.7, 0.3, 0.9, 0.1, 0.5), }; var pt = Vector4.CreatePosition(px, py, pz); var intensity = light.GetIntensity(pt, w); Assert.Equal(result, intensity); }
public void TestAreaLightFindingSinglePoint() { var corner = Point.Zero; var v1 = new Vector(2, 0, 0); var v2 = Vector.VectorZ; var light = new AreaLight(corner, v1, 4, v2, 2, Color.White); light.JitterBy = Sequence.Generate(0.5, 0.5, 0.5); Point pt; pt = light.PointOnLight(0, 0); Assert.AreEqual(pt, new Point(0.25, 0, 0.25)); pt = light.PointOnLight(1, 0); Assert.AreEqual(pt, new Point(0.75, 0, 0.25)); pt = light.PointOnLight(0, 1); Assert.AreEqual(pt, new Point(0.25, 0, 0.75)); pt = light.PointOnLight(2, 0); Assert.AreEqual(pt, new Point(1.25, 0, 0.25)); pt = light.PointOnLight(3, 1); Assert.AreEqual(pt, new Point(1.75, 0, 0.75)); }
public void TestMaterialAreaLight() { var corner = new Point(-0.5, -0.5, -5); var v1 = Vector.VectorX; var v2 = Vector.VectorY; var light = new AreaLight(corner, v1, 2, v2, 2, Color.White); var shape = new Sphere(); shape.Material.Ambient = 0.1; shape.Material.Diffuse = 0.9; shape.Material.Specular = 0.0; shape.Material.Color = Color.White; var eye = new Point(0, 0, -5); Point pt; Vector eyeV, normalV; Color result; pt = new Point(0, 0, -1); eyeV = (new Vector(eye - pt)).Normalize; normalV = new Vector(pt); result = shape.Material.Lighting(shape, light, pt, eyeV, normalV, 1.0); Assert.AreEqual(result, new Color(0.9965, 0.9965, 0.9965), "test 1"); pt = new Point(0, 0.7071, -0.7071); eyeV = (new Vector(eye - pt)).Normalize; normalV = new Vector(pt); result = shape.Material.Lighting(shape, light, pt, eyeV, normalV, 1.0); Assert.AreEqual(result, new Color(0.6232, 0.6232, 0.6232), "test 2"); }
void Init() { if (m_Initialized) { return; } if ((m_Light = GetComponent <Light>()) != null) { switch (m_Light.type) { case LightType.Point: m_Type = Type.Point; break; case LightType.Directional: m_Type = Type.Directional; break; default: m_Type = Type.None; break; } } else if ((m_TubeLight = GetComponent <TubeLight>()) != null) { m_Type = Type.Tube; } else if ((m_AreaLight = GetComponent <AreaLight>()) != null) { m_Type = Type.Area; } m_Initialized = true; }
void SetUpAreaLightBuffers(int kernel) { int count = m_AreaLightParamsCB == null ? 0 : m_AreaLightParamsCB.count; m_InjectLightingAndDensity.SetFloat("_AreaLightsCount", count); if (count == 0) { // Can't not set the buffers/textures m_InjectLightingAndDensity.SetBuffer(kernel, "_AreaLights", m_DummyCB); m_InjectLightingAndDensity.SetTexture(kernel, "_AreaLightShadowmap", Texture2D.whiteTexture); return; } if (m_AreaLightParams == null || m_AreaLightParams.Length != count) { m_AreaLightParams = new AreaLightParams[count]; } HashSet <FogLight> fogLights = LightManagerFogLights.Get(); int shadowedAreaLightIndex = -1; int j = 0; for (var x = fogLights.GetEnumerator(); x.MoveNext();) { var fl = x.Current; if (fl == null || fl.type != FogLight.Type.Area || !fl.isOn) { continue; } AreaLight light = fl.areaLight; m_AreaLightParams[j].mat = light.GetProjectionMatrix(true); m_AreaLightParams[j].pos = light.GetPosition(); m_AreaLightParams[j].color = new Vector3(light.m_Color.r, light.m_Color.g, light.m_Color.b) * light.m_Intensity * fl.m_IntensityMult; m_AreaLightParams[j].bounded = fl.m_Bounded ? 1 : 0; if (fl.m_Shadows) { RenderTexture shadowmap = light.GetBlurredShadowmap(); if (shadowmap != null) { m_InjectLightingAndDensity.SetTexture(kernel, "_AreaLightShadowmap", shadowmap); m_InjectLightingAndDensity.SetFloat("_ESMExponentAreaLight", fl.m_ESMExponent); shadowedAreaLightIndex = j; } } j++; } m_AreaLightParamsCB.SetData(m_AreaLightParams); m_InjectLightingAndDensity.SetBuffer(kernel, "_AreaLights", m_AreaLightParamsCB); m_InjectLightingAndDensity.SetFloat("_ShadowedAreaLightIndex", shadowedAreaLightIndex < 0 ? fogLights.Count : shadowedAreaLightIndex); if (shadowedAreaLightIndex < 0) { m_InjectLightingAndDensity.SetTexture(kernel, "_AreaLightShadowmap", Texture2D.whiteTexture); } }
private void Spherical() { Emissive e = new Emissive(ColorUtils.WHITE, 28); Sphere s1 = new Sphere(new Vec3(972, 756, 108), 120); SphericalLamp sl1 = new SphericalLamp(s1, e); sl1.Shadows = false; sl1.Sampler = new MultiJittered(vp.NumSamples); Sphere s2 = new Sphere(new Vec3(972, 756, -1296), 120); SphericalLamp sl2 = new SphericalLamp(s2, e); sl2.Shadows = false; sl2.Sampler = new MultiJittered(vp.NumSamples); Sphere s3 = new Sphere(new Vec3(-1188, 756, 108), 120); SphericalLamp sl3 = new SphericalLamp(s3, e); sl3.Shadows = false; sl3.Sampler = new MultiJittered(vp.NumSamples); Sphere s4 = new Sphere(new Vec3(-1188, 756, -1296), 120); SphericalLamp sl4 = new SphericalLamp(s4, e); sl4.Shadows = false; sl4.Sampler = new MultiJittered(vp.NumSamples); AddObject(sl1); AddObject(sl2); AddObject(sl3); AddObject(sl4); AreaLight l1 = new AreaLight(); l1.Object = sl1; l1.Shadows = true; AreaLight l2 = new AreaLight(); l2.Object = sl2; l2.Shadows = true; AreaLight l3 = new AreaLight(); l3.Object = sl3; l3.Shadows = true; AreaLight l4 = new AreaLight(); l4.Object = sl4; l4.Shadows = true; AddLight(l1); AddLight(l2); AddLight(l3); AddLight(l4); }
public void DeterminePointOnLight() { var corner = new Point(0, 0, 0); var v1 = new Vector(2, 0, 0); var v2 = new Vector(0, 0, 1); var light = new AreaLight(corner, v1, 4, v2, 2, Colors.White); light.UVPoint(0, 0).Should().Be(new Point(0.25f, 0, 0.25f)); light.UVPoint(1, 0).Should().Be(new Point(0.75f, 0, 0.25f)); light.UVPoint(0, 1).Should().Be(new Point(0.25f, 0, 0.75f)); light.UVPoint(2, 0).Should().Be(new Point(1.25f, 0, 0.25f)); light.UVPoint(3, 1).Should().Be(new Point(1.75f, 0, 0.75f)); }
public void CalculateAreaLightIntensityWithJitter() { var w = World.Default(); var corner = new Point(-0.5f, -0.5f, -5); var v1 = new Vector(1, 0, 0); var v2 = new Vector(0, 1, 0); var light = new AreaLight(corner, v1, 2, v2, 2, Colors.White, new Sequence(0.7f, 0.3f, 0.9f, 0.1f, 0.5f)); PhongShading.IntensityAt(w, new Point(0, 0, 2), light).Should().BeApproximately(0.0f, 0.0001f); PhongShading.IntensityAt(w, new Point(1, -1, 2), light).Should().BeApproximately(0.75f, 0.0001f); PhongShading.IntensityAt(w, new Point(1.5f, 0, 2), light).Should().BeApproximately(0.75f, 0.0001f); PhongShading.IntensityAt(w, new Point(1.25f, 1.25f, 3), light).Should().BeApproximately(0.75f, 0.0001f); PhongShading.IntensityAt(w, new Point(0f, 0f, -2), light).Should().BeApproximately(1.0f, 0.0001f); }
public void FindingSinglePointOnAnAreaLight_ShouldWork(double u, double v, Point result) { var corner = new Point(0, 0, 0); var v1 = new Vector(2, 0, 0); var v2 = new Vector(0, 0, 1); var light = new AreaLight(corner, v1, 4, v2, 2, Color.White); light.JitterBy = new Sequence(new List <double> { 0.5 }); var pt = light.PointOnLight(u, v); Assert.Equal(result, pt, PointComparer); }
public void CreatingAnAreaLight_ShouldWork() { var corner = new Point(0, 0, 0); var v1 = new Vector(2, 0, 0); var v2 = new Vector(0, 0, 1); var light = new AreaLight(corner, v1, 4, v2, 2, Color.White); Assert.Equal(corner, light.Corner); Assert.Equal(new Vector(0.5, 0, 0), light.UVec, VectorComparer); Assert.Equal(4, light.USteps); Assert.Equal(new Vector(0, 0, 0.5), light.VVec, VectorComparer); Assert.Equal(2, light.VSteps); Assert.Equal(8, light.Samples); Assert.Equal(new Point(1, 0, 0.5), light.Position, PointComparer); }
public void CreateLight() { var corner = new Point(0, 0, 0); var v1 = new Vector(2, 0, 0); var v2 = new Vector(0, 0, 1); var light = new AreaLight(corner, v1, 4, v2, 2, Colors.White); light.Corner.Should().Be(corner); light.U.Should().Be(new Vector(0.5f, 0, 0)); light.USteps.Should().Be(4); light.V.Should().Be(new Vector(0, 0, 0.5f)); light.VSteps.Should().Be(2); light.Samples.Should().Be(8); light.Position.Should().Be(new Point(1, 0, 0.5f)); }
public void TestAreaLightIntensityFunction() { var w = World.Default; var corner = new Point(-0.5, -0.5, -5); var v1 = Vector.VectorX; var v2 = Vector.VectorY; var light = new AreaLight(corner, v1, 2, v2, 2, Color.White); light.JitterBy = Sequence.Generate(0.5, 0.5, 0.5); Assert.AreEqual(light.IntensityAt(new Point(0, 0, 2), w), 0.0, epsilon); Assert.AreEqual(light.IntensityAt(new Point(1, -1, 2), w), 0.25, epsilon); Assert.AreEqual(light.IntensityAt(new Point(1.5, 0, 2), w), 0.5, epsilon); Assert.AreEqual(light.IntensityAt(new Point(1.25, 1.25, 3), w), 0.75, epsilon); Assert.AreEqual(light.IntensityAt(new Point(0, 0, -2), w), 1.0, epsilon); }
public void TestAreaLightCreate() { var corner = Point.Zero; var v1 = new Vector(2, 0, 0); var v2 = Vector.VectorZ; var light = new AreaLight(corner, v1, 4, v2, 2, Color.White); Assert.AreEqual(light.Corner, corner); Assert.AreEqual(light.UVec, new Vector(0.5, 0, 0)); Assert.AreEqual(light.USteps, 4); Assert.AreEqual(light.VVec, new Vector(0, 0, 0.5)); Assert.AreEqual(light.VSteps, 2); Assert.AreEqual(light.Samples, 8); Assert.AreEqual(light.Position, new Point(1, 0, 0.5)); }
public void AreaLight_ShouldWorkWithJitteredSamples(Point point, double result) { var w = new World(); w.CreateDefaultWorld(); var corner = new Point(-0.5, -0.5, -5); var v1 = new Vector(1, 0, 0); var v2 = new Vector(0, 1, 0); var light = new AreaLight(corner, v1, 2, v2, 2, Color.White); light.JitterBy = new Sequence(new List <double> { 0.7, 0.3, 0.9, 0.1, 0.5 }); var pt = point; var intensity = light.IntensityAt(pt, w); Assert.Equal(result, intensity, 2); }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (objectToEdit != null && objectToEdit is AreaLight) { AreaLight obj = objectToEdit as AreaLight; txtBaseObjectId.Text = obj.BaseObjectId; txtBaseObjectName.Text = obj.BaseObjectName; isEditingObj = true; txtBaseObjectId.IsEnabled = false; //custom code haloToLoad.Content = obj.HaloTextureName; maskToLoad.Content = obj.LightMaskTextureName; mapToLoad.Content = obj.LightMapTextureName; cancelRevert = (AreaLight)Utils.DeepClone(obj); //custom code end } }
private void UpdateCurrentAreaLightValues() { selectedAreaLight = (AreaLight)areaLightListBox.SelectedItem; areaCeilRedTB.Text = selectedAreaLight.skyR + ""; areaCeilBlueTB.Text = selectedAreaLight.skyB + ""; areaCeilGreenTB.Text = selectedAreaLight.skyG + ""; areaGroundRedTB.Text = selectedAreaLight.groundR + ""; areaGroundGreenTB.Text = selectedAreaLight.groundG + ""; areaGroundBlueTB.Text = selectedAreaLight.groundB + ""; areaRotX.Text = selectedAreaLight.rotX + ""; areaRotY.Text = selectedAreaLight.rotY + ""; areaRotZ.Text = selectedAreaLight.rotZ + ""; areaPosXTB.Text = selectedAreaLight.positionX + ""; areaPosYTB.Text = selectedAreaLight.positionY + ""; areaPosZTB.Text = selectedAreaLight.positionZ + ""; areaScaleXTB.Text = selectedAreaLight.scaleX + ""; areaScaleYTB.Text = selectedAreaLight.scaleY + ""; areaScaleZTB.Text = selectedAreaLight.scaleZ + ""; }
public void CreatingAnAreaLight() { var corner = Vector4.CreatePosition(0, 0, 0); var v1 = Vector4.CreateDirection(2, 0, 0); var v2 = Vector4.CreateDirection(0, 0, 1); var light = new AreaLight( corner, v1, 4, v2, 2, Color.White); Assert.Equal(corner, light.Corner); Assert.Equal(Vector4.CreateDirection(0.5, 0, 0), light.Uvec); Assert.Equal(4, light.Usteps); Assert.Equal(Vector4.CreateDirection(0, 0, 0.5), light.Vvec); Assert.Equal(2, light.Vsteps); Assert.Equal(8, light.Samples); Assert.Equal(Vector4.CreatePosition(1, 0, 0.5), light.Position); }
public override Vector3 Shade(ShadeRec sr) { Vector3 wo = -sr.ray.dir; Vector3 L = m_ambientBRDF.rho(sr, wo) * sr.context.ambientLight.L(sr); int lc = sr.context.lights.Count; for (int i = 0; i < lc; i++) { var light = sr.context.lights[i]; Vector3 wi = light.GetDirection(sr).Nor(); AreaLight al = light as AreaLight; if (al != null && al.GEOMETRY.GetNormal(Vector3.Zero).Dot(wi) > 0) { //判定单向 continue; } float ndotwi = sr.normal.Dot(wi); if (ndotwi > 0) { bool inshadow = false; if (light.CAST_SHADOW) { Ray shadowRay = new Ray(sr.localHitPoint + sr.normal * TracerConst.kEpsilon, wi); inshadow = light.ShadowCheck(shadowRay, sr); } if (!inshadow) { L += (m_diffuseBRDF.F(sr, wo, wi) + m_specularBRDF.F(sr, wo, wi)) * light.L(sr) * ndotwi * light.G(sr) / light.PDF(sr); } } } return(L); }
//protected virtual bool InShadow(Intersection intersect, Vector3D L) { // if(this.scene.IsShadowActive) { // float len = L.Length; // Ray shadowRay = new Ray(intersect.HitPoint, L); // //foreach(Primitive primitive in this.scene.Primitives) { // if(this.scene.FindIntersection(shadowRay, out intersect) // && intersect.TMin < len) { // return true; //Total Shadow // } // //} // } // return false; //} protected virtual float ShadowFactor(Intersection intersect, Vector3D L, Light light) { float shadowFactor = 1; //[0..1] 1 = not in shadow, 0 = total shadow if (this.scene.IsShadowActive) { Ray shadowRay; if (!this.scene.IsSoftShadowActive) { float len = L.Length; shadowRay = new Ray(intersect.HitPoint, L); if (this.scene.FindIntersection(shadowRay, out intersect) && intersect.TMin < len) { shadowFactor = 0; //Total Shadow } } else { AreaLight areaLight = light as AreaLight; if (areaLight != null) { Vector3D toRndPointInLight; float reductFactor = 1.0f / this.scene.SoftShadowSamples; for (int i = 0; i < this.scene.SoftShadowSamples; i++) { toRndPointInLight = areaLight.GetRandomPoint() - intersect.HitPoint; shadowRay = new Ray(intersect.HitPoint, toRndPointInLight); if ((intersect.HitPrimitive != null && intersect.HitPrimitive.FindIntersection(shadowRay, out intersect)) || this.scene.FindIntersection(shadowRay, out intersect) && intersect.TMin < toRndPointInLight.Length) { shadowFactor -= reductFactor; } } } } } return(shadowFactor); }
public void AreaLightIntensityFunction( double px, double py, double pz, double result) { var w = new DefaultWorld(); var corner = Vector4.CreatePosition(-0.5, -0.5, -5); var v1 = Vector4.CreateDirection(1, 0, 0); var v2 = Vector4.CreateDirection(0, 1, 0); var light = new AreaLight( corner, v1, 2, v2, 2, Color.White); var pt = Vector4.CreatePosition(px, py, pz); var intensity = light.GetIntensity(pt, w); Assert.Equal(result, intensity); }
public void CalculateLightingWithAreaLight() { var corner = new Point(-0.5f, -0.5f, -5); var v1 = new Vector(1, 0, 0); var v2 = new Vector(0, 1, 0); var light = new AreaLight(corner, v1, 2, v2, 2, Colors.White); var s = new Sphere { Material = { Ambient = 0.1f, Diffuse = 0.9f, Specular = 0f, Texture = new SolidColor(Colors.White) } }; var eye = new Point(0, 0, -5); var pt = new Point(0, 0, -1); var eyeV = (eye - pt).Normalize(); var normal = new Normal(pt.X, pt.Y, pt.Z); var r = PhongShading.Lighting(s.Material, s, light, pt, eyeV, normal, 1.0f); r.Should().Be(new Color(0.9965f, 0.9965f, 0.9965f)); pt = new Point(0, 0.7071f, -0.7071f); eyeV = (eye - pt).Normalize(); normal = new Normal(pt.X, pt.Y, pt.Z); r = PhongShading.Lighting(s.Material, s, light, pt, eyeV, normal, 1.0f); r.Should().Be(new Color(0.6232f, 0.6232f, 0.6232f)); }
public void Lighting_ShouldSampleAreaLights(Point point, Color result) { var corner = new Point(-0.5, -0.5, -5); var v1 = new Vector(1, 0, 0); var v2 = new Vector(0, 1, 0); var light = new AreaLight(corner, v1, 2, v2, 2, Color.White); light.JitterBy = new Sequence(new List <double> { 0.5 }); var shape = new Sphere(); shape.Material.Ambient = 0.1; shape.Material.Diffuse = 0.9; shape.Material.Specular = 0; shape.Material.Color = Color.White; var eye = new Point(0, 0, -5); var pt = point; var eyev = (eye - pt).Normalize(); var normalv = new Vector(pt.x, pt.y, pt.z); var r = shape.Material.Lighting(shape, light, pt, eyev, normalv, 1.0); Assert.Equal(result, r, ColorComparer); }
public Scene Build(int width, int height) { var camera = new Camera(width, height, 0.7854) { Transform = Transform.View( Vector4.CreatePosition(-3, 1, 2.5), Vector4.CreatePosition(0, 0.5, 0), Vector4.CreateDirection(0, 1, 0)), }; var light = new AreaLight( Vector4.CreatePosition(-1, 2, 4), Vector4.CreateDirection(2, 0, 0), 10, Vector4.CreateDirection(0, 2, 0), 10, new Color(1.5, 1.5, 1.5)) { Jitter = new RandomSequence(), }; var cube = new Cube() { Material = new Material() { Color = new Color(1.5, 1.5, 1.5), Ambient = 1, Diffuse = 0, Specular = 0, }, Transform = Matrix4x4.Identity .Scale(1, 1, 0.01) .Translate(0, 3, 4), Shadow = false, }; var plane = new Plane() { Material = new Material() { Color = new Color(1, 1, 1), Ambient = 0.025, Diffuse = 0.67, Specular = 0, }, }; var sphere1 = new Sphere() { Transform = Matrix4x4.Identity .Scale(0.5, 0.5, 0.5) .Translate(0.5, 0.5, 0), Material = new Material() { Color = new Color(1, 0, 0), Ambient = 0.1, Specular = 0, Diffuse = 0.6, Reflective = 0.3, }, }; var sphere2 = new Sphere() { Transform = Matrix4x4.Identity .Scale(0.33, 0.33, 0.33) .Translate(-0.25, 0.33, 0), Material = new Material() { Color = new Color(0.5, 0.5, 1), Ambient = 0.1, Specular = 0, Diffuse = 0.6, Reflective = 0.3, }, }; var world = new World() { Objects = new Shape[] { cube, plane, sphere1, sphere2 }, Lights = new ILight[] { light, }, }; return(new Scene(world, camera)); }
public override void Build() { vp = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT); vp.NumSamples = 64; vp.ShowOutOfGamut = 2; backgroundColor = ColorUtils.BLACK; tracer = new AreaLighting(this); Ambient a = new Ambient(); a.ScaleRadiance = 1.0f; AmbientLight = a; Pinhole pinhole = new Pinhole(new Vec3(0.0, 0.0, 500.0), new Vec3(0.0, 0.0, 0.0), new Vec3(0.0, 1.0, 0.0), 2000.0f); Camera = pinhole; Emissive emissive = new Emissive(); emissive.ScaleRadiance = 40.0f; emissive.Ce = ColorUtils.WHITE; MultiJittered sampler = new MultiJittered(256); sampler.Generate(); Rectangle rectangle = new Rectangle(new Vec3(100.0, 100.0, 200.0), new Vec3(216.0, 0.0, 0.0), new Vec3(0.0, 0.0, 216.0)); rectangle.Shadows = false; RectangularLamp lamp = new RectangularLamp(rectangle, emissive); lamp.Sampler = sampler; AddObject(lamp); AreaLight areaLight = new AreaLight(); areaLight.Object = lamp; areaLight.Shadows = true; AddLight(areaLight); Vec3 lightGreen = new Vec3(0.65f, 1.0f, 0.30f); Vec3 green = new Vec3(0.0f, 0.6f, 0.3f); Vec3 darkGreen = new Vec3(0.0f, 0.41f, 0.41f); Vec3 yellow = new Vec3(1.0f, 1.0f, 0.0f); Vec3 darkYellow = new Vec3(0.61f, 0.61f, 0.0f); Vec3 lightPurple = new Vec3(0.65f, 0.3f, 1.0f); Vec3 darkPurple = new Vec3(0.5f, 0.0f, 1.0f); Vec3 brown = new Vec3(0.71f, 0.40f, 0.16f); Vec3 orange = new Vec3(1.0f, 0.75f, 0.0f); Matte matte = new Matte(); matte.SetKa(0.2f); matte.SetKd(0.5f); matte.SetColor(ColorUtils.WHITE); Plane p = new Plane(new Vec3(0, -85, 0), new Vec3(0, 1, 0)); p.Material = matte; AddObject(p); Matte m = new Matte(); //Plastic *m = new Plastic(); m.SetKa(0.2f); m.SetKd(0.65f); //m.SetKs(0.1f); //m.SetExp(8.0f); m.SetColor(ColorUtils.WHITE); Sphere s = new Sphere(new Vec3(5, 3, 0), 30); s.Material = m; AddObject((Sphere)s.Clone()); s.SetCenter(45, -7, -60); s.Radius = 20; m.SetColor(brown); AddObject((Sphere)s.Clone()); s.SetCenter(40, 43, -100); s.Radius = 17; m.SetColor(darkGreen); AddObject((Sphere)s.Clone()); s.SetCenter(-20, 28, -15); s.Radius = 20; m.SetColor(orange); AddObject((Sphere)s.Clone()); s.SetCenter(-25, -7, -35); s.Radius = 27; m.SetColor(green); AddObject((Sphere)s.Clone()); s.SetCenter(20, -27, -35); s.Radius = 25; m.SetColor(lightGreen); AddObject((Sphere)s.Clone()); s.SetCenter(35, 18, -35); s.Radius = 22; m.SetColor(green); AddObject((Sphere)s.Clone()); s.SetCenter(-57, -17, -50); s.Radius = 15; m.SetColor(brown); AddObject((Sphere)s.Clone()); s.SetCenter(-47, 16, -80); s.Radius = 23; m.SetColor(lightGreen); AddObject((Sphere)s.Clone()); s.SetCenter(-15, -32, -60); s.Radius = 22; m.SetColor(darkGreen); AddObject((Sphere)s.Clone()); s.SetCenter(-35, -37, -80); s.Radius = 22; m.SetColor(darkYellow); AddObject((Sphere)s.Clone()); s.SetCenter(10, 43, -80); s.Radius = 22; m.SetColor(darkYellow); AddObject((Sphere)s.Clone()); s.SetCenter(30, -7, -80); s.Radius = 10; m.SetColor(darkYellow); AddObject((Sphere)s.Clone()); s.SetCenter(-40, 48, -110); s.Radius = 18; m.SetColor(darkGreen); AddObject((Sphere)s.Clone()); s.SetCenter(-10, 53, -120); s.Radius = 18; m.SetColor(brown); AddObject((Sphere)s.Clone()); s.SetCenter(-55, -52, -100); s.Radius = 10; m.SetColor(lightPurple); AddObject((Sphere)s.Clone()); s.SetCenter(5, -52, -100); s.Radius = 15; m.SetColor(brown); AddObject((Sphere)s.Clone()); s.SetCenter(-20, -57, -120); s.Radius = 15; m.SetColor(darkPurple); AddObject((Sphere)s.Clone()); s.SetCenter(55, -27, -100); s.Radius = 17; m.SetColor(darkGreen); AddObject((Sphere)s.Clone()); s.SetCenter(50, -47, -120); s.Radius = 15; m.SetColor(brown); AddObject((Sphere)s.Clone()); s.SetCenter(70, -42, -150); s.Radius = 10; m.SetColor(lightPurple); AddObject((Sphere)s.Clone()); s.SetCenter(5, 73, -130); s.Radius = 12; m.SetColor(lightPurple); AddObject((Sphere)s.Clone()); s.SetCenter(66, 21, -130); s.Radius = 13; m.SetColor(darkPurple); AddObject((Sphere)s.Clone()); s.SetCenter(72, -12, -140); s.Radius = 12; m.SetColor(lightPurple); AddObject((Sphere)s.Clone()); s.SetCenter(64, 5, -160); s.Radius = 11; m.SetColor(green); AddObject((Sphere)s.Clone()); s.SetCenter(55, 38, -160); s.Radius = 12; m.SetColor(lightPurple); AddObject((Sphere)s.Clone()); s.SetCenter(-73, -2, -160); s.Radius = 12; m.SetColor(lightPurple); AddObject((Sphere)s.Clone()); s.SetCenter(30, -62, -140); s.Radius = 15; m.SetColor(darkPurple); AddObject((Sphere)s.Clone()); s.SetCenter(25, 63, -140); s.Radius = 15; m.SetColor(darkPurple); AddObject((Sphere)s.Clone()); s.SetCenter(-60, 46, -140); s.Radius = 15; m.SetColor(darkPurple); AddObject((Sphere)s.Clone()); s.SetCenter(-30, 68, -130); s.Radius = 12; m.SetColor(lightPurple); AddObject((Sphere)s.Clone()); s.SetCenter(58, 56, -180); s.Radius = 11; m.SetColor(green); AddObject((Sphere)s.Clone()); s.SetCenter(-63, -39, -180); s.Radius = 11; m.SetColor(green); AddObject((Sphere)s.Clone()); s.SetCenter(46, 68, -200); s.Radius = 10; m.SetColor(lightPurple); AddObject((Sphere)s.Clone()); s.SetCenter(-3, -72, -130); s.Radius = 12; m.SetColor(lightPurple); AddObject(s); }
public override void Build() { vp = ViewPlane.Create(1920, 1080, SystemOfCoordinates.SSC_INT); vp.NumSamples = 144; vp.MaxDepth = 10; backgroundColor = new Vec3(0.15); tracer = new AreaLighting(this); AmbientOccluder a = new AmbientOccluder(); a.ScaleRadiance = 0.5; a.MinAmount = 0.05; a.Sampler = new MultiJittered(vp.NumSamples); AmbientLight = a; Pinhole pinhole = new Pinhole(new Vec3(75, 40, 100), new Vec3(-10, 39, 0), new Vec3(0.0, 1.0, 0.0), 360, 3.0f); Camera = pinhole; Rectangle rectangle = new Rectangle(new Vec3(75, 40, 100), new Vec3(0, 50, 0), new Vec3(50, 0, -50)); Emissive e = new Emissive(ColorUtils.WHITE, 20); RectangularLamp lamp = new RectangularLamp(rectangle, e); lamp.Sampler = new MultiJittered(vp.NumSamples); lamp.Shadows = false; AddObject(lamp); AreaLight light = new AreaLight(); light.Object = lamp; AddLight(light); Reflective reflective1 = new Reflective(); reflective1.SetKa(0.25f); reflective1.SetKd(0.5f); reflective1.SetColor(0.75f, 0.75f, 0.0f); reflective1.SetSpecularColor(ColorUtils.WHITE); reflective1.SetKs(0.15f); reflective1.SetExp(100.0f); reflective1.SetKr(0.75f); reflective1.SetReflectiveColor(ColorUtils.WHITE); double radius = 23.0; Sphere s1 = new Sphere(new Vec3(38, radius, -25), radius); s1.Material = reflective1; AddObject(s1); Matte matte1 = new Matte(); matte1.SetKa(0.45f); matte1.SetKd(0.75f); matte1.SetColor(0.75f, 0.25f, 0.0f); Sphere s2 = new Sphere(new Vec3(-7, 10, 42), 20); s2.Material = matte1; AddObject(s2); Reflective reflective2 = new Reflective(); reflective2.SetKa(0.35f); reflective2.SetKd(0.75f); reflective2.SetColor(ColorUtils.BLACK); reflective2.SetSpecularColor(ColorUtils.WHITE); reflective2.SetKs(0.0f); reflective2.SetExp(1.0f); reflective2.SetKr(0.75f); reflective2.SetReflectiveColor(ColorUtils.WHITE); Sphere s3 = new Sphere(new Vec3(-30, 59, 35), 20); s3.Material = reflective2; AddObject(s3); //cylinder Reflective reflective3 = new Reflective(); reflective3.SetKa(0.35f); reflective3.SetKd(0.5f); reflective3.SetColor(0.0f, 0.5f, 0.75f); reflective3.SetSpecularColor(ColorUtils.WHITE); reflective3.SetKs(0.2f); reflective3.SetExp(100.0f); reflective3.SetKr(0.75f); reflective3.SetReflectiveColor(ColorUtils.WHITE); float b = 0.0f; float t = 85f; float cr = 22f; SolidCylinder cylinder = new SolidCylinder(b, t, cr); cylinder.Material = reflective3; AddObject(cylinder); //box Matte matte2 = new Matte(); matte2.SetKa(0.15f); matte2.SetKd(0.5f); matte2.SetColor(0.75f, 1.0f, 0.75f); Box box = new Box(new Vec3(-35, 0, -110), new Vec3(-25, 60, 65)); box.Material = matte2; AddObject(box); //plane Matte matte3 = new Matte(); matte3.SetKa(0.30f); matte3.SetKd(0.9f); matte3.SetColor(ColorUtils.WHITE); Plane plane = new Plane(new Vec3(), new Vec3(0, 1, 0)); plane.Material = matte3; AddObject(plane); }
public override void Build() { vp = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT); //vp.NumSamples = 4096; vp.NumSamples = 400; vp.MaxDepth = 10; backgroundColor = ColorUtils.BLACK; tracer = new GlobalTrace(this); //tracer = new PathTrace(this); Ambient ambient = new Ambient(); ambient.ScaleRadiance = 0; AmbientLight = ambient; Pinhole camera = new Pinhole(); camera.SetEye(27.6, 27.4, -80); camera.SetLookat(27.6, 27.4, 0.0); camera.ViewPlaneDistance = 1200; Camera = camera; Vec3 p0; Vec3 a, b; Vec3 normal; // box dimensions double width = 55.28; // x direction double height = 54.88; // y direction double depth = 55.92; // z direction Emissive emissive = new Emissive(new Vec3(1.0, 0.73, 0.4), 100); p0 = new Vec3(21.3, height - 0.001, 22.7); a = new Vec3(0.0, 0.0, 10.5); b = new Vec3(13.0, 0.0, 0.0); normal = new Vec3(0.0, -1.0, 0.0); RectangularLamp lamp = new RectangularLamp(new Rectangle(p0, a, b, normal), emissive); lamp.Sampler = new MultiJittered(vp.NumSamples); AddObject(lamp); AreaLight ceilingLight = new AreaLight(); ceilingLight.Object = lamp; AddLight(ceilingLight); // left wall Matte matte1 = new Matte(); matte1.SetKa(0.0f); matte1.SetKd(0.6f); matte1.SetColor(0.57f, 0.025f, 0.025f); // red matte1.SetSampler(new MultiJittered(vp.NumSamples)); p0 = new Vec3(width, 0.0, 0.0); a = new Vec3(0.0, 0.0, depth); b = new Vec3(0.0, height, 0.0); normal = new Vec3(-1.0, 0.0, 0.0); Rectangle leftWall = new Rectangle(p0, a, b, normal); leftWall.Material = matte1; AddObject(leftWall); // right wall Matte matte2 = new Matte(); matte2.SetKa(0.0f); matte2.SetKd(0.6f); matte2.SetColor(0.37f, 0.59f, 0.2f); // green matte2.SetSampler(new MultiJittered(vp.NumSamples)); p0 = new Vec3(0.0, 0.0, 0.0); a = new Vec3(0.0, 0.0, depth); b = new Vec3(0.0, height, 0.0); normal = new Vec3(1.0, 0.0, 0.0); Rectangle rightWall = new Rectangle(p0, a, b, normal); rightWall.Material = matte2; AddObject(rightWall); // back wall Matte matte3 = new Matte(); matte3.SetKa(0.0f); matte3.SetKd(0.6f); matte3.SetColor(ColorUtils.WHITE); matte3.SetSampler(new MultiJittered(vp.NumSamples)); p0 = new Vec3(0.0, 0.0, depth); a = new Vec3(width, 0.0, 0.0); b = new Vec3(0.0, height, 0.0); normal = new Vec3(0.0, 0.0, -1.0); Rectangle backWall = new Rectangle(p0, a, b, normal); backWall.Material = matte3; AddObject(backWall); // floor p0 = new Vec3(0.0, 0.0, 0.0); a = new Vec3(0.0, 0.0, depth); b = new Vec3(width, 0.0, 0.0); normal = new Vec3(0.0, 1.0, 0.0); Rectangle floor = new Rectangle(p0, a, b, normal); floor.Material = matte3; AddObject(floor); // ceiling p0 = new Vec3(0.0, height, 0.0); a = new Vec3(0.0, 0.0, depth); b = new Vec3(width, 0.0, 0.0); normal = new Vec3(0.0, -1.0, 0.0); Rectangle ceiling = new Rectangle(p0, a, b, normal); ceiling.Material = matte3; AddObject(ceiling); // the two boxes defined as 5 rectangles each // short box // top p0 = new Vec3(13.0, 16.5, 6.5); a = new Vec3(-4.8, 0.0, 16.0); b = new Vec3(16.0, 0.0, 4.9); normal = new Vec3(0.0, 1.0, 0.0); Rectangle shortTop = new Rectangle(p0, a, b, normal); shortTop.Material = matte3; AddObject(shortTop); // side 1 p0 = new Vec3(13.0, 0.0, 6.5); a = new Vec3(-4.8, 0.0, 16.0); b = new Vec3(0.0, 16.5, 0.0); Rectangle shortSide1 = new Rectangle(p0, a, b); shortSide1.Material = matte3; AddObject(shortSide1); // side 2 p0 = new Vec3(8.2, 0.0, 22.5); a = new Vec3(15.8, 0.0, 4.7); Rectangle shortSide2 = new Rectangle(p0, a, b); shortSide2.Material = matte3; AddObject(shortSide2); // side 3 p0 = new Vec3(24.2, 0.0, 27.4); a = new Vec3(4.8, 0.0, -16.0); Rectangle shortSide3 = new Rectangle(p0, a, b); shortSide3.Material = matte3; AddObject(shortSide3); // side 4 p0 = new Vec3(29.0, 0.0, 11.4); a = new Vec3(-16.0, 0.0, -4.9); Rectangle shortSide4 = new Rectangle(p0, a, b); shortSide4.Material = matte3; AddObject(shortSide4); // tall box // top p0 = new Vec3(42.3, 33.0, 24.7); a = new Vec3(-15.8, 0.0, 4.9); b = new Vec3(4.9, 0.0, 15.9); normal = new Vec3(0.0, 1.0, 0.0); Rectangle tallTop = new Rectangle(p0, a, b, normal); tallTop.Material = matte3; AddObject(tallTop); // side 1 p0 = new Vec3(42.3, 0.0, 24.7); a = new Vec3(-15.8, 0.0, 4.9); b = new Vec3(0.0, 33.0, 0.0); Rectangle tallSide1 = new Rectangle(p0, a, b); tallSide1.Material = matte3; AddObject(tallSide1); // side 2 p0 = new Vec3(26.5, 0.0, 29.6); a = new Vec3(4.9, 0.0, 15.9); Rectangle tallSide2 = new Rectangle(p0, a, b); tallSide2.Material = matte3; AddObject(tallSide2); // side 3 p0 = new Vec3(31.4, 0.0, 45.5); a = new Vec3(15.8, 0.0, -4.9); Rectangle tallSide3 = new Rectangle(p0, a, b); tallSide3.Material = matte3; AddObject(tallSide3); // side 4 p0 = new Vec3(47.2, 0.0, 40.6); a = new Vec3(-4.9, 0.0, -15.9); Rectangle tallSide4 = new Rectangle(p0, a, b); tallSide4.Material = matte3; AddObject(tallSide4); }
public override void Build() { vp = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT); vp.NumSamples = 100; vp.MaxDepth = 10; backgroundColor = new Vec3(0.0, 0.3, 0.25); tracer = new Whitted(this); //AmbientOccluder a = new AmbientOccluder(ColorUtils.WHITE, // 0.25, 1.0); //a.Sampler = new MultiJittered(vp.NumSamples); Ambient a = new Ambient(); a.ScaleRadiance = 0.25f; AmbientLight = a; Pinhole pinhole = new Pinhole(new Vec3(1, 7.5, 20), new Vec3(0.0, -0.35, 0.0), new Vec3(0.0, 1.0, 0.0), 5250); Camera = pinhole; Emissive e = new Emissive(); e.ScaleRadiance = 3.0f; e.Ce = ColorUtils.WHITE; RectangularLamp lamp = new RectangularLamp( new Rectangle(new Vec3(0, 20, 0), new Vec3(1, 0, 0), new Vec3(0, 0, 1), new Vec3(0, -1, 0)), e); lamp.Sampler = new MultiJittered(vp.NumSamples); AddObject(lamp); AreaLight areaLight = new AreaLight(); areaLight.Object = lamp; areaLight.Shadows = true; AddLight(areaLight); //PointLight l = new PointLight(); //l.SetLocation(20, 20, 15); //l.ScaleRadiance = 3.0f; //AddLight(l); Transparent glass = new Transparent(); glass.SetKs(0.5f); glass.SetExp(2000); glass.SetIor(1.5f); glass.SetKr(0.1f); glass.SetKt(1.53f); //glass.SetCd(0.4f); float ir = 0.9f; float or = 1; //Bowl b = Bowl.CreateFlatRimmedBowl(ir, or); Bowl b = Bowl.CreateRoundRimmedBowl(ir, or); b.Material = glass; AddObject(b); Reflective reflective = new Reflective(); reflective.SetKa(0.6f); reflective.SetKd(0.4f); reflective.SetCd(ColorUtils.RED); reflective.SetKs(0.5f); reflective.SetExp(2000); reflective.SetKr(0.25f); double r = 0.4; double t = 55; t = MathUtils.PI * t / 180; double x = -(0.9 - r) * Math.Cos(t); double y = -(0.9 - r) * Math.Sin(t); Sphere s = new Sphere(new Vec3(x, y, 0), r, reflective); AddObject(s); Reflective reflective2 = new Reflective(); reflective2.SetKa(0.6f); reflective2.SetKd(0.4f); reflective2.SetCd(ColorUtils.YELLOW); reflective2.SetKs(0.5f); reflective2.SetExp(2000); reflective2.SetKr(0.5f); r = 0.35; t = 35; t = MathUtils.PI * t / 180; x = (0.9 - r) * Math.Cos(t); y = -(0.9 - r) * Math.Sin(t); Sphere s2 = new Sphere(new Vec3(x, y, 0), r, reflective2); AddObject(s2); Matte rm = new Matte(); rm.SetColor(ColorUtils.WHITE); rm.SetKa(0.8f); rm.SetKd(0.85f); Rectangle rectangle = new Rectangle(new Vec3(-2, -1, -5), new Vec3(0, 0, 9), new Vec3(4, 0, 0)); rectangle.Material = rm; AddObject(rectangle); }
public (World, Camera) Setup(int width, int height, double fov) { // ====================================================== // the camera // ====================================================== var camera = new Camera(width, height, fov) { Transform = Transformation.ViewTransform( new Point(1, 2, -5), // view from new Point(0, 2, 0), // view to new Vector(0, 1, 0)), // vector up ProgressMonitor = new ParallelConsoleProgressMonitor(height), }; // ====================================================== // light sources // ====================================================== var light = new PointLight( new Point(-20, 20, -20), new Color(1, 1, 1) ); var light2 = new PointLight( new Point(-20, 10, -5), new Color(1, 1, 1) ); var areaLight = new AreaLight( new Point(-100, 100, -100), new Vector(4, 0, 0), 6, new Vector(0, 4, 0), 6, new Color(1.0, 1.0, 1.0) ); var floor = new Plane() { Material = new Material() { Color = Color.White, Ambient = 0.1, Diffuse = 0.1, Specular = 0.0, Reflective = 0.4, }, }; FileStream stream = File.OpenRead("/Users/rhagan/VSCode Projects/RayTracer/RayTracer.Program/Scenes/Textures/brickwall.ppm"); StreamReader reader = new StreamReader(stream); var wallTexture = PpmReader.ReadCanvasFromPpm(reader); var textureLeft = new UvImage(wallTexture); var textureFront = textureLeft; var textureRight = textureLeft; var textureBack = textureLeft; var textureUp = textureLeft; var textureDown = textureLeft; stream = File.OpenRead("/Users/rhagan/VSCode Projects/RayTracer/RayTracer.Program/Scenes/Textures/brickwall_normal.ppm"); reader = new StreamReader(stream); var wallNormalMap = PpmReader.ReadCanvasFromPpm(reader); var normalLeft = new UvImage(wallNormalMap); var normalFront = normalLeft; var normalRight = normalLeft; var normalBack = normalLeft; var normalUp = normalLeft; var normalDown = normalLeft; var mapCubeMaterial = new Material() { Pattern = new CubeMap(textureLeft, textureFront, textureRight, textureBack, textureUp, textureDown), NormalMap = new CubeMap(normalLeft, normalFront, normalRight, normalBack, normalUp, normalDown), Ambient = 0.7, Specular = 0.0, Diffuse = 0.8, }; var box = new Cube() { Transform = Transformation.Translation(0, 2, 0) * Transformation.Rotation_y(1.9), Material = mapCubeMaterial, }; World world = new World(); world.Shapes = new List <Shape> { floor, box }; world.Lights = new List <ILight> { light }; return(world, camera); }
public override void Build() { vp = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT); vp.NumSamples = 4; backgroundColor = ColorUtils.BLACK; tracer = new AreaLighting(this); MultiJittered sampler = new MultiJittered(vp.NumSamples); sampler.Generate(); AmbientOccluder occluder = new AmbientOccluder(ColorUtils.WHITE, 0.0); occluder.Sampler = sampler; //occluder.ScaleRadiance = 1.0; //occluder.Color = ColorUtils.WHITE; //occluder.SetMinAmount(0.0f); AmbientLight = occluder; Pinhole pinhole = new Pinhole(new Vec3(0.0, 0.0, 500.0), new Vec3(0.0, 0.0, 0.0), new Vec3(0.0, 1.0, 0.0), 2000.0f); Camera = pinhole; Emissive emissive = new Emissive(ColorUtils.WHITE, 20.0f); //emissive.ScaleRadiance = 1.0f; //emissive.Ce = new Vec3(1.0, 1.0, 1.0); sampler = new MultiJittered(256); sampler.Generate(); ConcaveSphere sphere = new ConcaveSphere(new Vec3(), 10000.0); //sphere.Radius = 10000.0; sphere.Sampler = sampler; sphere.Material = emissive; sphere.EmissiveMaterial = emissive; sphere.Shadows = false; AddObject(sphere); sampler = new MultiJittered(256); sampler.Generate(); EnvironmentLight l = new EnvironmentLight(); l.Material = emissive; l.Sampler = sampler; l.Sampler.MapSamplesToHemisphere(10); l.Shadows = true; AddLight(l); //Rectangle rectangle = new Rectangle(new Vec3(0.0, 100.0, 0.0), // new Vec3(216.0, 0.0, 0.0), // new Vec3(0.0, 0.0, 216.0)); //emissive = new Emissive(); //emissive.ScaleRadiance = 1.0f; //emissive.Ce = ColorUtils.WHITE; //rectangle.Material = emissive; //rectangle.Sampler = sampler; //rectangle.Shadows = false; //AddObject(rectangle); AreaLight areaLight = new AreaLight(); areaLight.Object = sphere; areaLight.Shadows = true; AddLight(areaLight); Vec3 lightGreen = new Vec3(0.65f, 1.0f, 0.30f); Vec3 green = new Vec3(0.0f, 0.6f, 0.3f); Vec3 darkGreen = new Vec3(0.0f, 0.41f, 0.41f); Vec3 yellow = new Vec3(1.0f, 1.0f, 0.0f); Vec3 darkYellow = new Vec3(0.61f, 0.61f, 0.0f); Vec3 lightPurple = new Vec3(0.65f, 0.3f, 1.0f); Vec3 darkPurple = new Vec3(0.5f, 0.0f, 1.0f); Vec3 brown = new Vec3(0.71f, 0.40f, 0.16f); Vec3 orange = new Vec3(1.0f, 0.75f, 0.0f); Matte matte = new Matte(); matte.SetKa(0.2f); matte.SetKd(0.5f); matte.SetColor(ColorUtils.WHITE); Plane p = new Plane(new Vec3(0, -85, 0), new Vec3(0, 1, 0)); p.Material = matte; AddObject(p); Phong m = new Phong(); m.SetKa(0.2f); m.SetKd(0.65f); m.SetKs(0.1f); m.SetExp(8.0f); m.SetColor(ColorUtils.WHITE); Sphere s = new Sphere(new Vec3(5, 3, 0), 30); s.Material = m; AddObject((Sphere)s.Clone()); s.SetCenter(45, -7, -60); s.Radius = 20; m.SetColor(brown); AddObject((Sphere)s.Clone()); s.SetCenter(40, 43, -100); s.Radius = 17; m.SetColor(darkGreen); AddObject((Sphere)s.Clone()); s.SetCenter(-20, 28, -15); s.Radius = 20; m.SetColor(orange); AddObject((Sphere)s.Clone()); s.SetCenter(-25, -7, -35); s.Radius = 27; m.SetColor(green); AddObject((Sphere)s.Clone()); s.SetCenter(20, -27, -35); s.Radius = 25; m.SetColor(lightGreen); AddObject((Sphere)s.Clone()); s.SetCenter(35, 18, -35); s.Radius = 22; m.SetColor(green); AddObject((Sphere)s.Clone()); s.SetCenter(-57, -17, -50); s.Radius = 15; m.SetColor(brown); AddObject((Sphere)s.Clone()); s.SetCenter(-47, 16, -80); s.Radius = 23; m.SetColor(lightGreen); AddObject((Sphere)s.Clone()); s.SetCenter(-15, -32, -60); s.Radius = 22; m.SetColor(darkGreen); AddObject((Sphere)s.Clone()); s.SetCenter(-35, -37, -80); s.Radius = 22; m.SetColor(darkYellow); AddObject((Sphere)s.Clone()); s.SetCenter(10, 43, -80); s.Radius = 22; m.SetColor(darkYellow); AddObject((Sphere)s.Clone()); s.SetCenter(30, -7, -80); s.Radius = 10; m.SetColor(darkYellow); AddObject((Sphere)s.Clone()); s.SetCenter(-40, 48, -110); s.Radius = 18; m.SetColor(darkGreen); AddObject((Sphere)s.Clone()); s.SetCenter(-10, 53, -120); s.Radius = 18; m.SetColor(brown); AddObject((Sphere)s.Clone()); s.SetCenter(-55, -52, -100); s.Radius = 10; m.SetColor(lightPurple); AddObject((Sphere)s.Clone()); s.SetCenter(5, -52, -100); s.Radius = 15; m.SetColor(brown); AddObject((Sphere)s.Clone()); s.SetCenter(-20, -57, -120); s.Radius = 15; m.SetColor(darkPurple); AddObject((Sphere)s.Clone()); s.SetCenter(55, -27, -100); s.Radius = 17; m.SetColor(darkGreen); AddObject((Sphere)s.Clone()); s.SetCenter(50, -47, -120); s.Radius = 15; m.SetColor(brown); AddObject((Sphere)s.Clone()); s.SetCenter(70, -42, -150); s.Radius = 10; m.SetColor(lightPurple); AddObject((Sphere)s.Clone()); s.SetCenter(5, 73, -130); s.Radius = 12; m.SetColor(lightPurple); AddObject((Sphere)s.Clone()); s.SetCenter(66, 21, -130); s.Radius = 13; m.SetColor(darkPurple); AddObject((Sphere)s.Clone()); s.SetCenter(72, -12, -140); s.Radius = 12; m.SetColor(lightPurple); AddObject((Sphere)s.Clone()); s.SetCenter(64, 5, -160); s.Radius = 11; m.SetColor(green); AddObject((Sphere)s.Clone()); s.SetCenter(55, 38, -160); s.Radius = 12; m.SetColor(lightPurple); AddObject((Sphere)s.Clone()); s.SetCenter(-73, -2, -160); s.Radius = 12; m.SetColor(lightPurple); AddObject((Sphere)s.Clone()); s.SetCenter(30, -62, -140); s.Radius = 15; m.SetColor(darkPurple); AddObject((Sphere)s.Clone()); s.SetCenter(25, 63, -140); s.Radius = 15; m.SetColor(darkPurple); AddObject((Sphere)s.Clone()); s.SetCenter(-60, 46, -140); s.Radius = 15; m.SetColor(darkPurple); AddObject((Sphere)s.Clone()); s.SetCenter(-30, 68, -130); s.Radius = 12; m.SetColor(lightPurple); AddObject((Sphere)s.Clone()); s.SetCenter(58, 56, -180); s.Radius = 11; m.SetColor(green); AddObject((Sphere)s.Clone()); s.SetCenter(-63, -39, -180); s.Radius = 11; m.SetColor(green); AddObject((Sphere)s.Clone()); s.SetCenter(46, 68, -200); s.Radius = 10; m.SetColor(lightPurple); AddObject((Sphere)s.Clone()); s.SetCenter(-3, -72, -130); s.Radius = 12; m.SetColor(lightPurple); AddObject(s); }
public static Light CreateLightFromElement(this RElement ele, int ns) { bool shad = getShadow(ele); float rad = ele.Attributes[P.Radi].ToFloat(); string n = ele.Name; if (n == P.Lights.Amb) { Ambient amb = new Ambient(); amb.RadianceScale = rad; amb.Color = ele.Attributes[P.Col].ToVector3(); amb.Shadows = shad; return amb; } else if (n == P.Lights.AmbOcc) { AmbientOccluder amb = new AmbientOccluder(); amb.SetSampler(ele.Attributes[P.Sampler].CreateSamplerFromAttribute(ns)); amb.RadianceScale = rad; amb.Color = ele.Attributes[P.Col].ToVector3(); amb.Shadows = shad; return amb; } else if (n == P.Lights.PL) { PointLight pl = new PointLight(); pl.Position = ele.Attributes[P.Pos].ToVector3(); pl.RadianceScale = rad; pl.Color = ele.Attributes[P.Col].ToVector3(); pl.Shadows = shad; return pl; } else if (n == P.Lights.Direc) { Directional d = new Directional(); d.Direction = ele.Attributes[P.Dir].ToVector3(); d.RadianceScale = rad; d.Color = ele.Attributes[P.Col].ToVector3(); d.Shadows = shad; return d; } else if (n == P.Lights.AL) { AreaLight al = new AreaLight(); al.SetObject(GeometricObject.GetObject(ele.Attributes[P.Name].Value)); al.Shadows = shad; return al; } throw new Exception(); }
private void Start() { m_areaLight = GetComponentInChildren<AreaLight>(); }