private void InitTextures(Device d3d, DeviceContext d3dContext) { if (aoHash != null) { ShaderResourceView texture; if (!RenderStorageSingleton.Instance.TextureCache.TryGetValue(aoHash.uHash, out texture)) { if (!string.IsNullOrEmpty(aoHash.String)) { texture = TextureLoader.LoadTexture(d3d, d3dContext, aoHash.String); RenderStorageSingleton.Instance.TextureCache.Add(aoHash.uHash, texture); } } AOTexture = texture; } else { AOTexture = RenderStorageSingleton.Instance.TextureCache[0]; } for (int i = 0; i < LODs.Length; i++) { for (int x = 0; x < LODs[i].ModelParts.Length; x++) { ModelPart part = LODs[i].ModelParts[x]; if (part.Material != null) { ShaderParameterSampler sampler; if (part.Material.Samplers.TryGetValue("S000", out sampler)) { ShaderResourceView texture; if (!RenderStorageSingleton.Instance.TextureCache.TryGetValue(sampler.TextureHash, out texture)) { if (!string.IsNullOrEmpty(sampler.File)) { texture = TextureLoader.LoadTexture(d3d, d3dContext, sampler.File); RenderStorageSingleton.Instance.TextureCache.Add(sampler.TextureHash, texture); } } } if (part.Material.Samplers.TryGetValue("S001", out sampler)) { ShaderResourceView texture; if (!RenderStorageSingleton.Instance.TextureCache.TryGetValue(sampler.TextureHash, out texture)) { if (!string.IsNullOrEmpty(sampler.File)) { texture = TextureLoader.LoadTexture(d3d, d3dContext, sampler.File); RenderStorageSingleton.Instance.TextureCache.Add(sampler.TextureHash, texture); } } } if (part.Material.Samplers.TryGetValue("S011", out sampler)) { ShaderResourceView texture; if (!RenderStorageSingleton.Instance.TextureCache.TryGetValue(sampler.TextureHash, out texture)) { if (!string.IsNullOrEmpty(sampler.File)) { texture = TextureLoader.LoadTexture(d3d, d3dContext, sampler.File); RenderStorageSingleton.Instance.TextureCache.Add(sampler.TextureHash, texture); } } } } } } }