Пример #1
0
        private void CreateSkyboxes(GraphicsDevice device, ContentStack content, FrameService frameService, CubeMapGenerator cubeMapGenerator, IrradianceMapGenerator irradianceMapGenerator, EnvironmentMapGenerator environmentMapGenerator)
        {
            var skyboxNames = new string[]
            {
                "Skyboxes/Circus/Circus_Backstage_3k",
                "Skyboxes/Industrial/fin4_Bg",
                "Skyboxes/Milkyway/Milkyway_small",
                "Skyboxes/Grid/testgrid",
                "Skyboxes/Loft/Newport_Loft_Ref"
            };

            foreach (var name in skyboxNames)
            {
                content.Push("generator");
                var equiRect    = content.Load <Texture2D>(name);
                var albedo      = cubeMapGenerator.Generate(equiRect);
                var irradiance  = irradianceMapGenerator.Generate(equiRect);
                var environment = environmentMapGenerator.Generate(equiRect);

                content.Pop();
                content.Link(albedo);
                content.Link(irradiance);
                content.Link(environment);

                this.Textures.Add(new SkyboxTextures(name, albedo, irradiance, environment));
            }

            frameService.Skybox = SkyboxGenerator.Generate(device, this.Textures[0].Albedo,
                                                           this.Textures[0].Irradiance,
                                                           this.Textures[0].Environment);
        }
Пример #2
0
        public void Load(ContentStack content)
        {
            var sponza = content.Load <GeometryModel>("sponza/sponza");

            (var geometry, var geometryTransform, var geometryBounds) = this.Geometry.Create(sponza);

            geometryTransform.SetScale(0.05f);

            (var particpatingMedia, var participatingMediaTransform) = this.ParticipatingMedia.Create(this.Device.Viewport.Width, this.Device.Viewport.Height);

            particpatingMedia.Strength = 4.0f;
            particpatingMedia.Color    = new Color(0.1f, 0.1f, 0.1f);
            participatingMediaTransform.SetScale(new Vector3(200, 150.0f, 120.0f));

            (var particleEmitter, var particleTransform, var particleBounds, var forces) = this.Particles.Create(1024 * 1024);
            particleTransform.MoveTo(new Vector3(-49.0f, 3.0f, 0.0f));
            particleTransform.SetRotation(Quaternion.CreateFromYawPitchRoll(0, MathHelper.PiOver2, 0));
        }
Пример #3
0
        private void AddLargeAsteroid(ContentStack content)
        {
            var asteroid = content.Load <GeometryModel>("AsteroidField/Asteroid001");

            (var geometry, var transform, var bounds) = this.Geometry.Create(asteroid);
        }
Пример #4
0
        public void Load(ContentStack content)
        {
            var red = new Texture2D(this.Device, 1, 1);

            red.SetData(new Color[] { Color.White });
            content.Link(red);

            var white = new Texture2D(this.Device, 1, 1);

            white.SetData(new Color[] { Color.White });
            content.Link(white);

            var black = new Texture2D(this.Device, 1, 1);

            black.SetData(new Color[] { Color.Black });
            content.Link(black);

            var normal = new Texture2D(this.Device, 1, 1);

            normal.SetData(new Color[] { new Color(0.5f, 0.5f, 1.0f) });
            content.Link(normal);

            var blue  = content.Load <Texture2D>("Textures/Blue");
            var bumps = content.Load <Texture2D>("Textures/Bricks_Normal");

            var rows     = 7;
            var columns  = 7;
            var spacing  = 2.5f;
            var geometry = SphereGenerator.Generate(this.Device, 15);

            for (var row = 0; row < rows; row++)
            {
                var metalicness = row / (float)rows;

                var metalicnessTexture = new Texture2D(this.Device, 1, 1);
                metalicnessTexture.SetData(new Color[] { new Color(Vector3.One * metalicness) });
                content.Link(metalicnessTexture);

                for (var col = 0; col < columns; col++)
                {
                    var roughness        = Math.Clamp(col / (float)columns, 0.05f, 1.0f);
                    var roughnessTexture = new Texture2D(this.Device, 1, 1);
                    roughnessTexture.SetData(new Color[] { new Color(Vector3.One * roughness) });
                    content.Link(roughnessTexture);

                    var material = new Material(red, normal, metalicnessTexture, roughnessTexture, white);

                    var position = new Vector3((col - (columns / 2.0f)) * spacing, (row - (rows / 2.0f)) * spacing, 0.0f);
                    this.CreateSphere(geometry, material, position, Vector3.One);
                }
            }

            var backgroundGeometry = CubeGenerator.Generate(this.Device);

            this.CreateSphere(backgroundGeometry, new Material(bumps, GeneratedAssets.NormalPixel(), black, white, white), Vector3.Forward * 20, new Vector3(200, 200, 1));

            this.CreateLight(new Vector3(-10, 10, 10), Color.Red, 30.0f);
            this.CreateLight(new Vector3(10, 10, 10), Color.Blue, 30.0f);
            this.CreateLight(new Vector3(-10, -10, 10), Color.Green, 30.0f);
            this.CreateLight(new Vector3(10, -10, 10), Color.White, 30.0f);

            this.CreateSpotLight(new Vector3(0, 0, 10), Vector3.Forward, 1500.0f);
        }