public void DrawScene(CommandBuffer cmd, BlendFlags blendFlags) { var set0 = Set0 ?? View.Set0; Span <DescriptorSet> set1 = new [] { Set1 ?? View.Set1, Set2 }; cmd.SetViewport(View.Viewport); cmd.SetScissor(View.ViewRect); if ((blendFlags & BlendFlags.Solid) != 0) { if (MultiThreaded) { DrawBatchesMT(cmd, View.opaqueBatches, set0, set1); } else { DrawBatches(cmd, View.opaqueBatches.AsSpan(), set0, set1); } } if ((blendFlags & BlendFlags.AlphaTest) != 0 && View.alphaTestBatches.Count > 0) { DrawBatches(cmd, View.alphaTestBatches.AsSpan(), set0, set1); } if ((blendFlags & BlendFlags.AlphaBlend) != 0 && View.translucentBatches.Count > 0) { DrawBatches(cmd, View.translucentBatches.AsSpan(), set0, set1); } }
public static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref Point pptDst, ref Size psize, IntPtr hdcSrc, ref Point pprSrc, Int32 crKey, ref BLENDFUNCTION pblend, BlendFlags dwFlags);
Material ConvertMaterial(string path, Assimp.Material aiMaterial, bool hasTangent) { Shader shader = null; BlendFlags blendType = BlendFlags.Solid; if (hasTangent) { if (aiMaterial.HasTextureOpacity) { blendType = BlendFlags.AlphaTest; shader = Resources.Instance.Load <Shader>("Shaders/LitAlphaTest.shader"); } else if (aiMaterial.Opacity < 1) { blendType = BlendFlags.AlphaBlend; shader = Resources.Instance.Load <Shader>("Shaders/LitParticle.shader"); } else { shader = Resources.Instance.Load <Shader>("Shaders/LitSolid.shader"); } } else { shader = Resources.Instance.Load <Shader>("Shaders/Basic.shader"); } Material material = new Material(shader); material.Name = aiMaterial.Name; material.BlendType = blendType; if (aiMaterial.HasTextureDiffuse) { string texPath = FileUtil.CombinePath(path, aiMaterial.TextureDiffuse.FilePath); Texture tex = Resources.Instance.Load <Texture>(texPath); if (tex != null) { material.SetTexture("DiffMap", tex); } else { int idx = texPath.LastIndexOfAny(new[] { '\\', '/' }); if (idx != -1) { texPath = texPath.Substring(idx + 1); } tex = Resources.Instance.Load <Texture>(texPath.Replace(".ktx", "_bc3_unorm.ktx")); if (tex != null) { material.SetTexture("DiffMap", tex); } } } else { if (aiMaterial.HasColorDiffuse) { Color c = new Color(aiMaterial.ColorDiffuse[0], aiMaterial.ColorDiffuse[1], aiMaterial.ColorDiffuse[2], aiMaterial.ColorDiffuse[3] * aiMaterial.Opacity); material.SetTexture("DiffMap", Texture.CreateByColor(c)); material.SetShaderParameter("diffuse", c); } else { material.SetTexture("DiffMap", Texture.White); } } if (aiMaterial.HasTextureNormal) { string texPath = FileUtil.CombinePath(path, aiMaterial.TextureNormal.FilePath); Texture tex = Resources.Instance.Load <Texture>(texPath); if (tex != null) { material.SetTexture("NormalMap", tex); } else { tex = Resources.Instance.Load <Texture>(texPath.Replace(".ktx", "_bc3_unorm.ktx")); if (tex != null) { material.SetTexture("NormalMap", tex); } } } else { material.SetTexture("NormalMap", Texture.Blue); } if (aiMaterial.HasTextureSpecular) { string texPath = FileUtil.CombinePath(path, aiMaterial.TextureSpecular.FilePath); Texture tex = Resources.Instance.Load <Texture>(texPath); if (tex != null) { material.SetTexture("SpecMap", tex); } else { tex = Resources.Instance.Load <Texture>(texPath.Replace(".ktx", "_bc3_unorm.ktx")); if (tex != null) { material.SetTexture("SpecMap", tex); } } } else { if (aiMaterial.HasColorSpecular) { Color c = new Color(aiMaterial.ColorSpecular[0], aiMaterial.ColorSpecular[1], aiMaterial.ColorSpecular[2], aiMaterial.Shininess / 255.0f); material.SetTexture("SpecMap", Texture.CreateByColor(c)); material.SetShaderParameter("specular", c); } else { material.SetTexture("SpecMap", Texture.Black); } } return(material); }
public static bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref Point pptDst, ref Size psize, IntPtr hdcSrc, ref Point pprSrc, Int32 crKey, ref BLENDFUNCTION pblend, BlendFlags dwFlags) { NotImplemented(MethodBase.GetCurrentMethod()); return(false); }