static void InitTextures()
        {
            //Cube maps
            PrefilterCubeArrayTexture = GLTextureCubeArray.FromDDS(new DDS($"Resources\\CubemapPrefilter.dds"));
            DynamicReflectionTexture  = GLTextureCubeArray.FromDDS(new DDS($"Resources\\CubemapHDR.dds"));

            DiffuseLightmapTexture = GLTextureCube.FromDDS(
                new DDS(new MemoryStream(Resources.CubemapLightmap)));

            //Shadows
            DepthShadowTexture        = GLTexture2D.FromBitmap(Resources.white);
            DepthShadowCascadeTexture = GLTexture2D.FromBitmap(Resources.white);
            StaticShadowTexture       = GLTexture2D.FromBitmap(Resources.white);

            //Extra
            ProjectionTexture = GLTexture2D.FromBitmap(Resources.white);
            LightPPTexture    = GLTexture2D.FromBitmap(Resources.black);

            UserData0Texture = GLTexture2D.FromBitmap(Resources.black);
            BrdfTexture      = GLTexture2D.FromGeneric(
                new DDS(new MemoryStream(Resources.brdf)), new ImageParameters());
            UserData3Texture = GLTexture2D.FromBitmap(Resources.black);
            TableTexture     = GLTexture2DArray.FromBitmap(Resources.white);
            UserData5Texture = GLTexture2D.FromBitmap(Resources.black);

            ColorBufferTexture = GLTexture2D.FromBitmap(Resources.black);
            DepthBufferTexture = GLTexture2D.FromBitmap(Resources.black);
            SSAOBufferTexture  = GLTexture2DArray.FromBitmap(Resources.white);
        }
        static void InitTextures()
        {
            CubeMapTextureID = GLTextureCubeArray.FromDDS(new DDS($"Resources\\CubemapHDR.dds"));

            DiffuseCubeTextureID = GLTextureCube.FromDDS(
                new DDS(new MemoryStream(Resources.CubemapLightmap)),
                new DDS(new MemoryStream(Resources.CubemapLightmapShadow)));

            SpecularCubeTextureID = GLTextureCube.CreateEmptyCubemap(32);

            LightingEngine.LightSettings.InitTextures();

            DepthShadowCascadeTextureID = GLTexture2D.FromBitmap(Resources.white);
            ProjectionTextureID         = GLTexture2D.FromBitmap(Resources.white);
            User1Texture = GLTexture2D.FromBitmap(Resources.white);

            //Adjust mip levels
            CubeMapTextureID.Bind();
            GL.TexParameter(CubeMapTextureID.Target, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
            GL.TexParameter(CubeMapTextureID.Target, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);
            GL.TexParameter(CubeMapTextureID.Target, TextureParameterName.TextureBaseLevel, 0);
            GL.TexParameter(CubeMapTextureID.Target, TextureParameterName.TextureMaxLevel, 13);
            CubeMapTextureID.Unbind();

            DiffuseCubeTextureID.Bind();
            GL.TexParameter(CubeMapTextureID.Target, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
            GL.TexParameter(CubeMapTextureID.Target, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);
            GL.TexParameter(DiffuseCubeTextureID.Target, TextureParameterName.TextureBaseLevel, 0);
            GL.TexParameter(DiffuseCubeTextureID.Target, TextureParameterName.TextureMaxLevel, 2);
            DiffuseCubeTextureID.Unbind();
        }
Example #3
0
        public static void LoadCubemap()
        {
            Scenarios.Clear();

            string path = $"{GlobalSettings.GamePath}\\ObjectData\\CubeMap{Stage}.szs";

            //Load the cubemap (archive -> bfres textures)
            var file           = STFileLoader.OpenFileFormat(path) as IArchiveFile;
            var cubemapArchive = file.Files.FirstOrDefault().OpenFile() as BFRES;

            if (!Directory.Exists("TextureCache"))
            {
                Directory.CreateDirectory("TextureCache");
            }

            foreach (var texture in cubemapArchive.Textures)
            {
                if (texture.Name != "Default_")
                {
                    continue;
                }

                if (!File.Exists($"TextureCache\\{texture.Name}.dds"))
                {
                    texture.SaveDDS($"TextureCache\\{texture.Name}.dds");
                }
            }

            foreach (var texture in cubemapArchive.Textures)
            {
                if (texture.Name != "Default_")
                {
                    continue;
                }

                var dds = new DDS($"TextureCache\\{texture.Name}.dds");
                dds.Parameters.UseSoftwareDecoder = true;
                dds.Parameters.FlipY = true;

                //Cubemaps load into areas and have presets from render info in materials
                string sceneName   = texture.Name.Split('_').LastOrDefault();
                string cubemapType = texture.Name.Split('_').FirstOrDefault();

                if (string.IsNullOrWhiteSpace(sceneName))
                {
                    sceneName = "Scenario1";
                }

                if (!Scenarios.ContainsKey(sceneName))
                {
                    Scenarios.Add(sceneName, new CubemapArea());
                }

                Scenarios[sceneName].Cubemaps.Add(cubemapType, GLTextureCube.FromDDS(dds));
            }
        }
        static void InitTextures()
        {
            //Reflective cubemap
            var cubemap = GLTextureCubeArray.FromDDS(
                new DDS($"Resources\\CubemapHDR.dds"));

            CubemapManager.InitDefault(cubemap);

            CubemapManager.CubeMapTextureArray = GLTexture2DArray.FromDDS(new DDS($"Resources\\CubemapHDR.dds"));
            DiffuseLightmapTextureArray        = GLTexture2DArray.FromDDS(new DDS[2]
            {
                new DDS(new MemoryStream(Resources.CubemapLightmap)),
                new DDS(new MemoryStream(Resources.CubemapLightmapShadow))
            });

            //Diffuse cubemap lighting
            //Map gets updated when an object moves using probe lighting.
            DiffuseLightmapTexture = GLTextureCube.FromDDS(
                new DDS(new MemoryStream(Resources.CubemapLightmap)),
                new DDS(new MemoryStream(Resources.CubemapLightmapShadow)));

            LightingEngine.LightSettings.InitTextures();

            DepthShadowCascadeTexture = GLTexture2D.CreateWhiteTexture(4, 4);

            //Tire marks
            ProjectionTexture = GLTexture2D.CreateWhiteTexture(4, 4);

            //Depth information. Likely for shadows
            NormalizedLinearDepth = GLTexture2D.FromBitmap(Resources.black);

            //Adjust mip levels

            CubemapManager.CubeMapTexture.Bind();
            GL.TexParameter(CubemapManager.CubeMapTexture.Target, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
            GL.TexParameter(CubemapManager.CubeMapTexture.Target, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);
            GL.TexParameter(CubemapManager.CubeMapTexture.Target, TextureParameterName.TextureBaseLevel, 0);
            GL.TexParameter(CubemapManager.CubeMapTexture.Target, TextureParameterName.TextureMaxLevel, 13);
            GL.TexParameter(CubemapManager.CubeMapTexture.Target, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge);
            GL.TexParameter(CubemapManager.CubeMapTexture.Target, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge);
            GL.TexParameter(CubemapManager.CubeMapTexture.Target, TextureParameterName.TextureWrapR, (int)TextureWrapMode.ClampToEdge);
            CubemapManager.CubeMapTexture.Unbind();

            DiffuseLightmapTexture.Bind();
            GL.TexParameter(DiffuseLightmapTexture.Target, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
            GL.TexParameter(DiffuseLightmapTexture.Target, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);
            GL.TexParameter(DiffuseLightmapTexture.Target, TextureParameterName.TextureBaseLevel, 0);
            GL.TexParameter(DiffuseLightmapTexture.Target, TextureParameterName.TextureMaxLevel, 2);
            GL.TexParameter(DiffuseLightmapTexture.Target, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge);
            GL.TexParameter(DiffuseLightmapTexture.Target, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge);
            GL.TexParameter(DiffuseLightmapTexture.Target, TextureParameterName.TextureWrapR, (int)TextureWrapMode.ClampToEdge);
            DiffuseLightmapTexture.Unbind();
        }
        static void InitTextures()
        {
            //Reflective cubemap
            CubeMapTexture = GLTextureCubeArray.FromDDS(new DDS($"Resources\\CubemapHDR.dds"));

            CubemapManager.InitDefault(CubeMapTexture);

            //Diffuse cubemap lighting
            //Map gets updated when an object moves using probe lighting.
            DiffuseLightmapTexture = GLTextureCube.FromDDS(
                new DDS(new MemoryStream(Resources.CubemapLightmap)),
                new DDS(new MemoryStream(Resources.CubemapLightmapShadow)));

            //Shadows
            //Channel usage:
            //Red - Dynamic shadows
            //Green - Static shadows (course)
            //Blue - Soft shading (under kart, dynamic AO?)
            //Alpha - Usually gray
            DepthShadowTexture = GLTexture2D.FromBitmap(Resources.white);

            DepthShadowCascadeTexture = GLTexture2D.FromBitmap(Resources.white);

            //Tire marks
            ProjectionTexture = GLTexture2D.FromBitmap(Resources.white);

            //Used for dynamic lights. Ie spot, point, kart lights
            //Dynamic lights are setup using the g buffer pass (normals) and depth information before material pass is drawn
            //Additional slices may be used for bloom intensity
            LightPPTexture = GLTexture2DArray.FromBitmap(Resources.black);

            //Depth information. Likely for shadows
            NormalizedLinearDepth = GLTexture2D.FromBitmap(Resources.black);

            //Adjust mip levels

            CubeMapTexture.Bind();
            GL.TexParameter(CubeMapTexture.Target, TextureParameterName.TextureBaseLevel, 0);
            GL.TexParameter(CubeMapTexture.Target, TextureParameterName.TextureMaxLevel, 13);
            CubeMapTexture.Unbind();

            DiffuseLightmapTexture.Bind();
            GL.TexParameter(DiffuseLightmapTexture.Target, TextureParameterName.TextureBaseLevel, 0);
            GL.TexParameter(DiffuseLightmapTexture.Target, TextureParameterName.TextureMaxLevel, 2);
            DiffuseLightmapTexture.Unbind();
        }
        public static void LoadCubemap()
        {
            Areas.Clear();

            string path = $"{SM3DWShaderLoader.GamePath}\\CubeMapTextureData\\{Stage}.szs";

            //Load the cubemap (archive -> bfres textures)
            var file           = STFileLoader.OpenFileFormat(path) as IArchiveFile;
            var cubemapArchive = file.Files.FirstOrDefault().OpenFile() as BFRES;

            if (!Directory.Exists("TextureCache"))
            {
                Directory.CreateDirectory("TextureCache");
            }

            foreach (var texture in cubemapArchive.Textures)
            {
                if (!File.Exists($"TextureCache\\{texture.Name}.dds") && texture.Name.StartsWith("Default_Obj"))
                {
                    texture.SaveDDS($"TextureCache\\{texture.Name}.dds");
                }
            }

            foreach (var texture in cubemapArchive.Textures)
            {
                if (!texture.Name.StartsWith("Default_Obj"))
                {
                    continue;
                }

                var dds = new DDS($"TextureCache\\{texture.Name}.dds");

                //Cubemaps load into areas and have presets from render info in materials
                string areaName   = texture.Name.Split('_').FirstOrDefault();
                string presetName = texture.Name.Split('_').LastOrDefault();

                if (!Areas.ContainsKey(areaName))
                {
                    Areas.Add(areaName, new CubemapArea());
                }

                Areas[areaName].Cubemaps.Add(presetName, GLTextureCube.FromDDS(dds));
            }
        }
        static void InitTextures()
        {
            //SMOCubemapLoader.LoadCubemap();

            MaterialLightCube = GLTextureCube.FromDDS(new DDS($"Resources\\CubemapHDR2.dds"), false, true);

            MaterialLightSphere     = GLTexture2D.FromBitmap(Resources.black);
            DirectionalLightTexture = GLTexture2D.FromGeneric(
                new DDS(new MemoryStream(Resources.HalfMap)), new ImageParameters());

            MaterialLightCube.Bind();
            GL.TexParameter(MaterialLightCube.Target, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
            GL.TexParameter(MaterialLightCube.Target, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);
            GL.TexParameter(MaterialLightCube.Target, TextureParameterName.TextureBaseLevel, 0);
            GL.TexParameter(MaterialLightCube.Target, TextureParameterName.TextureMaxLevel, 5);
            MaterialLightCube.Unbind();

            ColorBufferTexture      = GLTexture2D.FromBitmap(Resources.black);
            DepthShadowTexture      = GLTexture2D.FromBitmap(Resources.white);
            LinearDepthTexture      = GLTexture2D.FromBitmap(Resources.black);
            ExposureTexture         = GLTexture2D.FromBitmap(Resources.white);
            RoughnessCubemapTexture = MaterialLightCube;
            Uniform0Texture         = GLTexture2D.FromBitmap(Resources.black);
        }
Example #8
0
        static void InitTextures()
        {
            //Cube maps
            DiffuseCubemapTexture = GLTextureCube.FromDDS(
                new DDS($"Resources\\CubemapIrradianceDefault.dds"));

            DiffuseCubemapTexture.Bind();
            DiffuseCubemapTexture.MagFilter = TextureMagFilter.Linear;
            DiffuseCubemapTexture.MinFilter = TextureMinFilter.Linear;
            DiffuseCubemapTexture.UpdateParameters();

            GL.TexParameter(DiffuseCubemapTexture.Target, TextureParameterName.TextureBaseLevel, 0);
            GL.TexParameter(DiffuseCubemapTexture.Target, TextureParameterName.TextureMaxLevel, 0);
            DiffuseCubemapTexture.Unbind();

            SpecularCubemapTexture = GLTextureCube.FromDDS(new DDS($"Resources\\CubemapDefault.dds"));

            SpecularCubemapTexture.Bind();
            SpecularCubemapTexture.MagFilter = TextureMagFilter.Linear;
            SpecularCubemapTexture.MinFilter = TextureMinFilter.LinearMipmapLinear;
            SpecularCubemapTexture.UpdateParameters();

            GL.TexParameter(SpecularCubemapTexture.Target, TextureParameterName.TextureBaseLevel, 0);
            GL.TexParameter(SpecularCubemapTexture.Target, TextureParameterName.TextureMaxLevel, 7);
            SpecularCubemapTexture.Unbind();

            //Shadows
            ShadowDepthNearTexture = GLTexture2D.FromBitmap(Resources.white);
            ShadowDepthFarTexture  = GLTexture2D.FromBitmap(Resources.white);
            ShadowDepthCharTexture = GLTexture2D.FromBitmap(Resources.white);

            //Extra
            ColorBufferTexture = GLTexture2D.FromBitmap(Resources.black);
            DepthBufferTexture = GLTexture2D.FromBitmap(Resources.black);
            HalfTone           = GLTexture2D.FromBitmap(Resources.dot);
        }