private void AddButton_Click(object sender, RoutedEventArgs e)
 {
     if (sidesTextBox.Text == "" || colorTextBox.Text == "")
     {
         msgTextBlock.Foreground = new SolidColorBrush(Colors.Red);
         msgTextBlock.Text       = "Данные не были введены";
     }
     else
     {
         try
         {
             flatness.AddPolygons(colorTextBox.Text, Flatness.SidesToInt(sidesTextBox.Text));
             msgTextBlock.Foreground = new SolidColorBrush(Colors.Green);
             msgTextBlock.Text       = "Многоугольник успешно добавлен.";
         }
         catch
         {
             msgTextBlock.Foreground = new SolidColorBrush(Colors.Red);
             msgTextBlock.Text       = "Данные некоректно введены!";
         }
     }
 }
Ejemplo n.º 2
0
 private void addButton_Click(object sender, EventArgs e)
 {
     if (sidesTextBox.Text == "" || colorTextBox.Text == "")
     {
         msgLabel.ForeColor = Color.FromName("Red");
         msgLabel.Text      = "Данные не были введены";
     }
     else
     {
         try
         {
             flatness.AddPolygons(colorTextBox.Text, Flatness.SidesToInt(sidesTextBox.Text));
             msgLabel.ForeColor = Color.FromName("Green");
             msgLabel.Text      = "Многоугольник успешно добавлен.";
         }
         catch
         {
             msgLabel.ForeColor = Color.FromName("Red");
             msgLabel.Text      = "Данные некоректно введены!";
         }
     }
 }
Ejemplo n.º 3
0
        public void ComputeScatteringFunctions(SurfaceInteraction si,
                                               IObjectArena arena,
                                               TransportMode mode,
                                               bool allowMultipleLobes)
        {
            BumpMap?.Bump(si);

            si.BSDF.Initialize(si);

            // Diffuse
            var c = Color.Evaluate(si).Clamp();
            var metallicWeight = Metallic.Evaluate(si);
            var e             = Eta.Evaluate(si);
            var strans        = SpecTrans.Evaluate(si);
            var diffuseWeight = (1f - metallicWeight) * (1f - strans);
            var dt            = DiffTrans.Evaluate(si) / 2f;
            var rough         = Roughness.Evaluate(si);
            var lum           = c.YComponent();
            var Ctint         = lum > 0f ? c / lum : Spectrum.One;

            if (diffuseWeight > 0f)
            {
                if (IsThin)
                {
                    var flat = Flatness.Evaluate(si);
                    si.BSDF.Add(arena.Create <DisneyDiffuse>().Initialize(diffuseWeight * (1f - flat) * (1 - dt) * c));
                    si.BSDF.Add(arena.Create <DisneyFakeSS>().Initialize(diffuseWeight * flat * (1f - dt) * c, rough));
                }
                else
                {
                    var sd = ScatterDistance.Evaluate(si);
                    if (sd.IsBlack())
                    {
                        si.BSDF.Add(arena.Create <DisneyDiffuse>().Initialize(diffuseWeight * c));
                    }
                    else
                    {
                        // The line below was the original code but produces some odd results.
                        si.BSDF.Add(arena.Create <SpecularTransmission>().Initialize(Spectrum.One, 1f, e, mode));
                        si.BSSRDF = arena.Create <DisneyBSSRDF>().Initialize(diffuseWeight * c, sd, si, e, this, mode);
                    }
                }

                // Retro-reflection.
                si.BSDF.Add(arena.Create <DisneyRetro>().Initialize(diffuseWeight * c, rough));

                // Sheen
                var sheenWeight = Sheen.Evaluate(si);
                if (sheenWeight > 0f)
                {
                    var stint  = SheenTint.Evaluate(si);
                    var Csheen = Spectrum.Lerp(Spectrum.One, Ctint, stint);
                    si.BSDF.Add(arena.Create <DisneySheen>().Initialize(diffuseWeight * sheenWeight * Csheen));
                }
            }

            // Microfacet distribution
            var aspect = Sqrt(1f - Anisotropic.Evaluate(si) * 0.9f);
            var ax     = Max(0.001f, Sqr(rough) / aspect);
            var ay     = Max(0.001f, Sqr(rough) * aspect);
            var dist   = arena.Create <DisneyMicrofacetDistribution>().Initialize(ax, ay);

            // Specular = Trowbridge-Reitz with modified Fresnel function.
            var specTint = SpecularTint.Evaluate(si);
            var Cspec0   = Spectrum.Lerp(SchlickR0FromEta(e) * Spectrum.Lerp(Spectrum.One, Ctint, specTint), c,
                                         metallicWeight);
            var fresnel = arena.Create <DisneyFresnel>().Initialize(Cspec0, metallicWeight, e);

            si.BSDF.Add(arena.Create <MicrofacetReflection>().Initialize(c, dist, fresnel));

            // Clearcoat
            var cc = Clearcoat.Evaluate(si);

            if (cc > 0f)
            {
                si.BSDF.Add(arena.Create <DisneyClearcoat>()
                            .Initialize(cc, Lerp(0.1f, 0.001f, ClearcoatGloss.Evaluate(si))));
            }

            // BTDF
            if (strans > 0f)
            {
                // Walter et al's model, with the provided transmissive term scaled
                // by sqrt(color), so that after two refractions, we're back to the
                // provided color.
                var T = strans * c.Sqrt();
                if (IsThin)
                {
                    var rScaled    = (0.65f * e - 0.35f) * rough;
                    var atx        = Max(0.001f, Sqr(rScaled) / aspect);
                    var aty        = Max(0.001f, Sqr(rScaled) * aspect);
                    var scaledDist = arena.Create <TrowbridgeReitzDistribution>().Initialize(atx, aty);
                    si.BSDF.Add(arena.Create <MicrofacetTransmission>().Initialize(T, scaledDist, 1f, e, mode));
                }
                else
                {
                    si.BSDF.Add(arena.Create <MicrofacetTransmission>().Initialize(T, dist, 1f, e, mode));
                }
            }

            if (IsThin)
            {
                si.BSDF.Add(arena.Create <LambertianTransmission>().Initialize(dt * c));
            }
        }
 public AddPolygonWindow(ref Flatness flatness)
 {
     this.flatness = flatness;
     InitializeComponent();
 }