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); }
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); }