/// <summary> /// Create a file based normap map /// </summary> void CreateFileBasedNormalMap() { Texture fileBasedSource = null; try { // Load the texture from a file fileBasedSource = GraphicsUtility.CreateTexture(device, "earthbump.bmp", Format.A8R8G8B8); SurfaceDescription desc = fileBasedSource.GetLevelDescription(0); fileBasedNormalMap = new Texture(device, desc.Width, desc.Height, fileBasedSource.LevelCount, 0, Format.A8R8G8B8, Pool.Managed); TextureLoader.ComputeNormalMap(fileBasedNormalMap, fileBasedSource, 0, Channel.Red, 1.0f); } catch { SampleException e = new MediaNotFoundException(); HandleSampleException(e, ApplicationMessage.ApplicationMustExit); throw e; } finally { if (fileBasedSource != null) { fileBasedSource.Dispose(); } } }
/// <summary> /// The make textures. /// </summary> /// <param name="device">The device.</param> /// <remarks></remarks> public void MakeTextures(ref Device device) { /* * BitmapTextures = new Texture[Bitmaps.Count]; * for (int x = 0; x < Bitmaps.Count; x++) BitmapTextures[x] = CreateTexture(ref device, Bitmaps[x]); */ if (BumpMapBitmap != null) { BumpMapTexture = CreateTexture(ref device, BumpMapBitmap); SurfaceDescription desc = BumpMapTexture.GetLevelDescription(0); NormalMap = new Texture( device, desc.Width, desc.Height, BumpMapTexture.LevelCount, 0, Format.A8R8G8B8, Pool.Managed); TextureLoader.ComputeNormalMap(NormalMap, BumpMapTexture, 0, Channel.Alpha, 1.0f); } if (primarydetailBitmap != null) { primarydetailTexture = CreateTexture(ref device, primarydetailBitmap); } if (secondarydetailBitmap != null) { secondarydetailTexture = CreateTexture(ref device, secondarydetailBitmap); } if (microdetailBitmap != null) { microdetailTexture = CreateTexture(ref device, microdetailBitmap); } if (CubeMapBitmap != null) { // CubeMapTexture = Texture.FromBitmap(device, CubeMapBitmap, Usage.AutoGenerateMipMap, Pool.Managed); } if (MainBitmap != null) { MainTexture = CreateTexture(ref device, MainBitmap); // try // { // } // catch // { // MainTexture = Texture.FromBitmap(device, MainBitmap, Usage.AutoGenerateMipMap, Pool.Managed); // } } }