private ShaderResourceView getSubresourceById(string p) { using (Stream stream = subresourceManager.getSubresourceByName(p)) { if (stream == null) { return(null); } return(ShaderResourceView.FromStream(device, stream, (int)stream.Length)); } }
public int LoadToon(string path) { using (Stream stream = _subresourceManager.getSubresourceByName(path)) { if (stream == null) { return(0); } resourceViewsList.Add(ShaderResourceView.FromStream(_device, stream, (int)stream.Length)); return(resourceViewsList.Count - 1); } }
public static MaterialInfo FromMaterialData(IDrawable drawable, Material material, RenderContext context, ISubresourceLoader loader) { MaterialInfo info = new MaterialInfo(); info.AmbientColor = material.ColorAmbient.ToSlimDX(); if (info.AmbientColor == Vector4.Zero) { info.AmbientColor = new Vector4(1f, 1f, 1f, 1f); } info.DiffuseColor = material.ColorDiffuse.ToSlimDX(); if (info.DiffuseColor == Vector4.Zero) { info.DiffuseColor = new Vector4(1f, 1f, 1f, 1f); } else if (info.DiffuseColor.W == 0f) { info.DiffuseColor.W = 1f; } info.EmissiveColor = material.ColorEmissive.ToSlimDX(); info.SpecularColor = material.ColorSpecular.ToSlimDX(); info.SpecularPower = material.ShininessStrength; if (info.SpecularColor == Vector4.Zero) { info.SpecularColor = new Vector4(0.1f); } info.GroundShadowColor = drawable.GroundShadowColor; info.isEdgeEnable = false; info.isGroundShadowEnable = true; info.SphereMode = SphereMode.Disable; info.IsToonUsed = false; if (material.GetTextures(TextureType.Diffuse) != null) { Stream stream = loader.getSubresourceByName(material.GetTextures(TextureType.Diffuse)[0].FilePath); if (stream != null) { using ( Texture2D texture = Texture2D.FromStream(context.DeviceManager.Device, stream, (int)stream.Length)) { info.MaterialTexture = new ShaderResourceView(context.DeviceManager.Device, texture); } } stream.Close(); } return(info); }