public EnvironmentMap(int size, IContentLoader contentLoader, Dictionary <Enums.EntityType, DefaultMesh> meshes)
        {
            _bloom = new[] {
                new Bloom(contentLoader),
                new Bloom(contentLoader),
                new Bloom(contentLoader),
                new Bloom(contentLoader),
                new Bloom(contentLoader),
                new Bloom(contentLoader)
            };

            _positions = new[]
            {
                new Position(Vector3.Zero, -90, 180), //right
                new Position(Vector3.Zero, 90, 180),  //left
                new Position(Vector3.Zero, 0, -90),   //up
                new Position(Vector3.Zero, 0, 90),    //down
                new Position(Vector3.Zero, 0, 180),   //back
                new Position(Vector3.Zero, 180, 180)  //front
            };

            for (int i = 0; i < 6; i++)
            {
                _cameras[i]     = new Camera <Position, Perspective>(_positions[i], new Perspective(farClip: 500f));
                _mapSurfaces[i] = new FBOwithDepth(Texture2dGL.Create(size, size));
            }

            _cubeFbo = new CubeMapFBO(size);

            _deferred = new Deferred(contentLoader, meshes);
            _deferred.UpdateResolution(size, size);
            _shadowMapping = new DirectionalShadowMapping(contentLoader, meshes);
            _shadowMapping.UpdateResolution(size, size);
            _lighting = new Lighting(contentLoader);
            _lighting.UpdateResolution(size, size);
            _skybox = new Skybox(contentLoader, 245, "blue");
            _skybox.UpdateResolution(size, size);
            _add = new Add(contentLoader);
            _add.UpdateResolution(size, size);

            _environmentMapProgram = contentLoader.Load <IShaderProgram>("environmentMap.*");

            foreach (var meshContainer in meshes)
            {
                _geometries.Add(meshContainer.Key, VAOLoader.FromMesh(meshContainer.Value, _environmentMapProgram));
            }
        }
Exemple #2
0
        public Skybox(IContentLoader contentLoader, float size, string textureName)
        {
            _skyboxProgram = contentLoader.Load <IShaderProgram>("sky.*");

            ITexture2D[] textures = new ITexture2D[6];

            for (int i = 0; i < 6; i++)
            {
                textures[i] = contentLoader.Load <ITexture2D>(textureName + Endings[i]);
            }

            _cubeFbo = new CubeMapFBO(textures[0].Width);

            CreateMap(textures);

            var sphere = Meshes.CreateSphere(size).SwitchHandedness();

            _sphereGeometry = VAOLoader.FromMesh(sphere, _skyboxProgram);
        }