public static GLTexture GetCubemap(FMAT material)
        {
            //Get cubemap from roughness preset.
            var preset = material.GetRenderInfo("roughness_preset");

            return(Areas["Default"].Cubemaps[$"Obj{preset}"]);
        }
        /// <summary>
        /// Gets options generated from the render state to be used for program searching.
        /// If a given key is not present as an option, then it will be skipped.
        /// </summary>
        /// <param name="options"></param>
        /// <param name="mat"></param>
        public static void LoadRenderStateOptions(Dictionary <string, string> options, FMAT mat)
        {
            string alphaFunction = mat.GetRenderInfo("gsys_alpha_test_func");

            string renderMode = mat.GetRenderInfo("gsys_render_state_mode");

            if (mat.BlendState.State == GLFrameworkEngine.GLMaterialBlendState.BlendState.Opaque)
            {
                renderMode = "opaque";
            }
            if (mat.BlendState.State == GLFrameworkEngine.GLMaterialBlendState.BlendState.Mask)
            {
                renderMode = "mask";
            }
            if (mat.BlendState.State == GLFrameworkEngine.GLMaterialBlendState.BlendState.Translucent)
            {
                renderMode = "translucent";
            }
            if (mat.BlendState.State == GLFrameworkEngine.GLMaterialBlendState.BlendState.Custom)
            {
                renderMode = "custom";
            }

            if (alphaFunction != null && RenderStateFuncs.ContainsKey(alphaFunction))
            {
                options["gsys_alpha_test_func"] = RenderStateFuncs[alphaFunction];
            }
            if (renderMode != null && RenderStateModes.ContainsKey(renderMode))
            {
                options["gsys_renderstate"] = RenderStateModes[renderMode];
            }

            if (mat.BlendState.AlphaTest)
            {
                options["gsys_alpha_test_enable"] = "1";
            }
        }
        static void ConvertSwitchRenderState(FMAT mat)
        {
            string blend = mat.GetRenderInfo("gsys_render_state_blend_mode");
            //Alpha test
            string alphaTest  = mat.GetRenderInfo("gsys_alpha_test_enable");
            string alphaFunc  = mat.GetRenderInfo("gsys_alpha_test_func");
            float  alphaValue = mat.GetRenderInfo("gsys_alpha_test_value");

            string colorOp  = mat.GetRenderInfo("gsys_color_blend_rgb_op");
            string colorDst = mat.GetRenderInfo("gsys_color_blend_rgb_dst_func");
            string colorSrc = mat.GetRenderInfo("gsys_color_blend_rgb_src_func");

            float[] blendColorF32 = mat.Material.RenderInfos["gsys_color_blend_const_color"].GetValueSingles();

            string alphaOp  = mat.GetRenderInfo("gsys_color_blend_alpha_op");
            string alphaDst = mat.GetRenderInfo("gsys_color_blend_alpha_dst_func");
            string alphaSrc = mat.GetRenderInfo("gsys_color_blend_alpha_src_func");

            string depthTest     = mat.GetRenderInfo("gsys_depth_test_enable");
            string depthTestFunc = mat.GetRenderInfo("gsys_depth_test_func");
            string depthWrite    = mat.GetRenderInfo("gsys_depth_test_write");
            string state         = mat.GetRenderInfo("gsys_render_state_mode");

            if (state == "opaque")
            {
                mat.BlendState.State = GLMaterialBlendState.BlendState.Opaque;
            }
            else if (state == "translucent")
            {
                mat.BlendState.State = GLMaterialBlendState.BlendState.Translucent;
            }
            else if (state == "mask")
            {
                mat.BlendState.State = GLMaterialBlendState.BlendState.Mask;
            }
            else
            {
                mat.BlendState.State = GLMaterialBlendState.BlendState.Custom;
            }

            string displayFace = mat.GetRenderInfo("gsys_render_state_display_face");

            if (displayFace == "front")
            {
                mat.CullFront = false;
                mat.CullBack  = true;
            }
            if (displayFace == "back")
            {
                mat.CullFront = true;
                mat.CullBack  = false;
            }
            if (displayFace == "both")
            {
                mat.CullFront = false;
                mat.CullBack  = false;
            }
            if (displayFace == "none")
            {
                mat.CullFront = true;
                mat.CullBack  = true;
            }

            if (!string.IsNullOrEmpty(state) && state != "opaque")
            {
                mat.IsTransparent = true;
            }

            mat.BlendState.Color      = new OpenTK.Vector4(blendColorF32[0], blendColorF32[1], blendColorF32[2], blendColorF32[3]);
            mat.BlendState.BlendColor = blend == "color";
            mat.BlendState.DepthTest  = depthTest == "true";
            mat.BlendState.DepthWrite = depthWrite == "true";
            mat.BlendState.AlphaTest  = alphaTest == "true";
            mat.BlendState.AlphaValue = alphaValue;

            if (alphaFunc == "always")
            {
                mat.BlendState.AlphaFunction = AlphaFunction.Always;
            }
            if (alphaFunc == "equal")
            {
                mat.BlendState.AlphaFunction = AlphaFunction.Equal;
            }
            if (alphaFunc == "lequal")
            {
                mat.BlendState.AlphaFunction = AlphaFunction.Lequal;
            }
            if (alphaFunc == "gequal")
            {
                mat.BlendState.AlphaFunction = AlphaFunction.Gequal;
            }
            if (alphaFunc == "less")
            {
                mat.BlendState.AlphaFunction = AlphaFunction.Less;
            }
            if (alphaFunc == "greater")
            {
                mat.BlendState.AlphaFunction = AlphaFunction.Greater;
            }
            if (alphaFunc == "never")
            {
                mat.BlendState.AlphaFunction = AlphaFunction.Never;
            }
        }