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); }
public static void InitDefault(GLTextureCubeArray texture) { if (CubeMapTexture == null) { CubeMapTexture = texture; } }
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(); }
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(); }
//Update all existing cubemap uint objects public static void GenerateCubemaps(List <GenericRenderer> targetModels, bool isWiiU) { var texture = isWiiU ? CubeMapTextureArray : CubeMapTexture; if (texture != null) { texture.Dispose(); } if (isWiiU) { texture = GLTexture2DArray.CreateUncompressedTexture(CUBEMAP_SIZE, CUBEMAP_SIZE, MAX_LAYER_COUNT * 6, MAX_MIP_LEVEL, PixelInternalFormat.Rgba16f, PixelFormat.Rgba, PixelType.Float); } else { texture = GLTextureCubeArray.CreateEmptyCubemap(CUBEMAP_SIZE, MAX_LAYER_COUNT, MAX_MIP_LEVEL, PixelInternalFormat.Rgba16f, PixelFormat.Rgba, PixelType.Float); } GLTextureCube cubemapTexture = GLTextureCube.CreateEmptyCubemap( CUBEMAP_UPSCALE_SIZE, PixelInternalFormat.Rgba16f, PixelFormat.Rgba, PixelType.Float, 9); //Get a list of cubemaps in the scene //The lighting engine has cube map objects with the object placement to draw var lightingEngine = LightingEngine.LightSettings; var cubemapEnvParams = lightingEngine.Resources.CubeMapFiles.FirstOrDefault().Value; var cubeMapUints = cubemapEnvParams.CubeMapObjects; int layer = 0; foreach (var cubeMap in cubeMapUints) { var cUint = cubeMap.CubeMapUint; //Cubemap has no area assigned skip it if (cubeMap.CubeMapUint.Name == string.Empty) { continue; } //Setup the camera to render the cube map faces CubemapCamera camera = new CubemapCamera( new Vector3(cUint.Position.X, cUint.Position.Y, cUint.Position.Z) * GLContext.PreviewScale, cUint.Near, cUint.Far); var context = new GLContext(); context.Camera = camera; GenerateCubemap(context, cubemapTexture, camera, targetModels, MAX_MIP_LEVEL); cubemapTexture.Bind(); cubemapTexture.GenerateMipmaps(); cubemapTexture.Unbind(); //HDR encode and output into the array CubemapHDREncodeRT.CreateCubemap(cubemapTexture, texture, layer, MAX_MIP_LEVEL, false, true); if (SAVE_TO_DISK) { cubemapTexture.SaveDDS(cubeMap.Name + "default.dds"); } layer++; } cubemapTexture.Dispose(); //Just generate mips to keep things easier texture.Bind(); texture.GenerateMipmaps(); texture.Unbind(); if (SAVE_TO_DISK) { texture.SaveDDS("Cubemap_Array_HDR.dds"); } if (isWiiU) { CubeMapTextureArray = texture; } else { CubeMapTexture = texture; } }