public static void Render(FMAT material)
        {
            bool edited = false;

            var renderState = material.Material.RenderState;

            if (ImGui.CollapsingHeader("Culling", ImGuiTreeNodeFlags.DefaultOpen))
            {
                edited |= ImGuiHelper.ComboFromEnum <FMAT.CullMode>("Cull Mode", material, "CullState");
            }
            if (ImGui.CollapsingHeader("Alpha Control", ImGuiTreeNodeFlags.DefaultOpen))
            {
                edited |= ImGuiHelper.ComboFromEnum <RenderStateFlagsMode>("Render State", renderState, "FlagsMode");
                edited |= ImGuiHelper.InputFromBoolean("Alpha Test Enabled", renderState.AlphaControl, "AlphaTestEnabled");
                edited |= ImGuiHelper.ComboFromEnum <GX2CompareFunction>("Depth Function", renderState.AlphaControl, "AlphaFunc");
                edited |= ImGuiHelper.InputFromFloat("Alpha Reference", renderState, "AlphaRefValue");
            }
            if (ImGui.CollapsingHeader("Blend Control", ImGuiTreeNodeFlags.DefaultOpen))
            {
                edited |= ImGuiHelper.ComboFromEnum <RenderStateFlagsBlendMode>("Blend Mode", renderState, "FlagsBlendMode");

                ImGui.LabelText("Color Calculation", CreateBlendMethod(
                                    renderState.BlendControl.ColorSourceBlend,
                                    renderState.BlendControl.ColorCombine,
                                    renderState.BlendControl.ColorDestinationBlend));

                edited |= ImGuiHelper.ComboFromEnum <GX2BlendFunction>("Color Source", renderState.BlendControl, "ColorSourceBlend");
                edited |= ImGuiHelper.ComboFromEnum <GX2BlendCombine>("Color Combine", renderState.BlendControl, "ColorCombine");
                edited |= ImGuiHelper.ComboFromEnum <GX2BlendFunction>("Color Destination", renderState.BlendControl, "ColorDestinationBlend");

                ImGui.LabelText("Alpha Calculation", CreateBlendMethod(
                                    renderState.BlendControl.AlphaSourceBlend,
                                    renderState.BlendControl.AlphaCombine,
                                    renderState.BlendControl.AlphaDestinationBlend));

                edited |= ImGuiHelper.ComboFromEnum <GX2BlendFunction>("Alpha Source", renderState.BlendControl, "AlphaSourceBlend");
                edited |= ImGuiHelper.ComboFromEnum <GX2BlendCombine>("Alpha Combine", renderState.BlendControl, "AlphaCombine");
                edited |= ImGuiHelper.ComboFromEnum <GX2BlendFunction>("Alpha Destination", renderState.BlendControl, "AlphaDestinationBlend");

                ImGuiHelper.InputFromUint("Blend Target", renderState, "BlendTarget");
            }
            if (ImGui.CollapsingHeader("Color Control", ImGuiTreeNodeFlags.DefaultOpen))
            {
                edited |= ImGuiHelper.InputFromBoolean("ColorBuffer Enabled", renderState.ColorControl, "ColorBufferEnabled");
                edited |= ImGuiHelper.InputFromBoolean("MultiWrite Enabled", renderState.ColorControl, "MultiWriteEnabled");
                edited |= ImGuiHelper.InputFromByte("Blend Enable Mask", renderState.ColorControl, "BlendEnableMask");
                edited |= ImGuiHelper.ComboFromEnum <GX2LogicOp>("Logic Op", renderState.ColorControl, "LogicOp");
            }
            if (ImGui.CollapsingHeader("Depth Control", ImGuiTreeNodeFlags.DefaultOpen))
            {
                edited |= ImGuiHelper.InputFromBoolean("Depth Test Enabled", renderState.DepthControl, "DepthTestEnabled");
                edited |= ImGuiHelper.InputFromBoolean("Depth Write Enabled", renderState.DepthControl, "DepthWriteEnabled");
                edited |= ImGuiHelper.ComboFromEnum <GX2CompareFunction>("Depth Function", renderState.DepthControl, "DepthFunc");
            }

            if (edited)
            {
                ReloadMaterial(material);
            }
        }
        static void LoadProperties(TexSampler sampler)
        {
            var flags = ImGuiTreeNodeFlags.DefaultOpen;

            if (ImGui.CollapsingHeader("Wrap Mode", flags))
            {
                ImGuiHelper.ComboFromEnum <GX2TexClamp>("Wrap X", sampler, "ClampX");
                ImGuiHelper.ComboFromEnum <GX2TexClamp>("Wrap Y", sampler, "ClampY");
                ImGuiHelper.ComboFromEnum <GX2TexClamp>("Wrap Z", sampler, "ClampZ");
            }
            if (ImGui.CollapsingHeader("Filter", flags))
            {
                ImGuiHelper.ComboFromEnum <GX2TexXYFilterType>("Mag Filter", sampler, "MagFilter");
                ImGuiHelper.ComboFromEnum <GX2TexXYFilterType>("Min Filter", sampler, "MinFilter");
                ImGuiHelper.ComboFromEnum <GX2TexZFilterType>("Z Filter", sampler, "ZFilter");
                ImGuiHelper.ComboFromEnum <GX2TexMipFilterType>("Mip Filter", sampler, "MipFilter");
                ImGuiHelper.ComboFromEnum <GX2TexAnisoRatio>("Anisotropic Ratio", sampler, "MaxAnisotropicRatio");
            }
            if (ImGui.CollapsingHeader("Mip LOD", flags))
            {
                ImGuiHelper.InputFromFloat("Lod Min", sampler, "MinLod", false, 1);
                ImGuiHelper.InputFromFloat("Lod Max", sampler, "MaxLod", false, 1);
                ImGuiHelper.InputFromFloat("Lod Bias", sampler, "LodBias", false, 1);
            }
            if (ImGui.CollapsingHeader("Depth", flags))
            {
                ImGuiHelper.InputFromBoolean("Depth Enabled", sampler, "DepthCompareEnabled");
                ImGuiHelper.ComboFromEnum <GX2CompareFunction>("Depth Compare", sampler, "DepthCompareFunc");
            }
            if (ImGui.CollapsingHeader("Border", flags))
            {
                ImGuiHelper.ComboFromEnum <GX2TexBorderType>("Border Type", sampler, "BorderType");
            }
        }
Пример #3
0
        private void LoadLightingUI(LightingObj lighting)
        {
            var colorFlags = ImGuiColorEditFlags.HDR | ImGuiColorEditFlags.Float;

            ImGuiHelper.InputTKVector4Color4("Upper Color", lighting, "ColorHemiUpper", colorFlags);
            ImGuiHelper.InputTKVector4Color4("Lower Color", lighting, "ColorHemiLower", colorFlags);
            ImGuiHelper.InputTKVector4Color4("Direction Color", lighting, "DirectionalColor", colorFlags);
            ImGuiHelper.InputTKVector3("Direction", lighting, "Direction");
            ImGuiHelper.InputFromFloat("Lower Angle", lighting, "ColorHemiLowerMaxRotDegrees");
            ImGuiHelper.InputFromFloat("Upper Angle", lighting, "ColorHemiUpperMaxRotDegrees");
        }
        public static bool RenderProperies(AmbientLight ambLight, string id)
        {
            bool edited = false;

            edited |= ImGuiHelper.InputFromBoolean($"Enable{id}", ambLight, "Enable");

            edited |= EditColor($"Color", $"{id}_0", ambLight, "Color");
            edited |= ImGuiHelper.InputFromFloat($"Intensity{id}", ambLight, "Intensity");

            return(edited);
        }
        public static bool RenderProperies(DirectionalLight dirLight, string id)
        {
            bool edited = false;

            edited |= ImGuiHelper.InputFromBoolean($"Enable{id}", dirLight, "Enable");

            edited |= EditColor($"Diffuse Color", $"{id}_0", dirLight, "DiffuseColor");
            edited |= EditColor($"Backside Color", $"{id}_1", dirLight, "BacksideColor");

            edited |= ImGuiHelper.InputFromFloat($"Intensity{id}", dirLight, "Intensity");

            edited |= EditVector3($"Direction{id}", dirLight, "Direction");

            return(edited);
        }
        public static bool RenderProperies(HemisphereLight hemi, string id)
        {
            bool edited = false;

            edited |= ImGuiHelper.InputFromBoolean($"Enable{id}", hemi, "Enable");

            edited |= EditColor($"Sky Color", $"{id}_0", hemi, "SkyColor");
            edited |= EditColor($"Ground Color", $"{id}_1", hemi, "GroundColor");

            edited |= ImGuiHelper.InputFromFloat($"Intensity{id}", hemi, "Intensity");

            edited |= EditVector3($"Direction{id}", hemi, "Direction");

            return(edited);
        }
Пример #7
0
        public void LoadEditor(BfresMaterialAnim anim)
        {
            if (string.IsNullOrEmpty(SelectedMaterial))
            {
                SelectedMaterial = anim.AnimGroups.FirstOrDefault().Name;
            }

            if (ImGui.CollapsingHeader("Header"))
            {
                ImGuiHelper.InputFromText("Name", anim, "Name", 200);
                ImGuiHelper.InputFromFloat("FrameCount", anim, "FrameCount");
                ImGuiHelper.InputFromBoolean("Loop", anim, "Loop");
            }

            if (ImGui.BeginCombo("Material", SelectedMaterial))
            {
                foreach (var group in anim.AnimGroups)
                {
                    bool isSelected = group.Name == SelectedMaterial;
                    if (ImGui.Selectable(group.Name) || isSelected)
                    {
                        SelectedMaterial = group.Name;
                    }

                    if (isSelected)
                    {
                        ImGui.SetItemDefaultFocus();
                    }
                }
                ImGui.EndCombo();
            }

            foreach (var group in anim.AnimGroups)
            {
                bool isSelected = group.Name == SelectedMaterial;
                if (isSelected)
                {
                    RenderMaterial(anim, (BfresMaterialAnim.MaterialAnimGroup)group);
                }
            }
        }
Пример #8
0
        private void DrawViewportMenu()
        {
            if (ImGui.BeginMenu("View Setting"))
            {
                if (ImGui.BeginMenu("Background"))
                {
                    ImGui.Checkbox("Display", ref DrawableBackground.Display);
                    ImGui.ColorEdit3("Color Top", ref DrawableBackground.BackgroundTop);
                    ImGui.ColorEdit3("Color Bottom", ref DrawableBackground.BackgroundBottom);
                    ImGui.EndMenu();
                }
                if (ImGui.BeginMenu("Grid"))
                {
                    ImGui.Checkbox("Display", ref DrawableFloor.Display);
                    ImGui.ColorEdit4("Grid Color", ref DrawableFloor.GridColor);
                    ImGui.InputInt("Grid Cell Count", ref Toolbox.Core.Runtime.GridSettings.CellAmount);
                    ImGui.InputFloat("Grid Cell Size", ref Toolbox.Core.Runtime.GridSettings.CellSize);
                    ImGui.EndMenu();
                }
                if (ImGui.BeginMenu("Bones"))
                {
                    ImGui.Checkbox("Display", ref Runtime.DisplayBones);
                    ImGui.InputFloat("Point Size", ref Runtime.BonePointSize);
                    ImGui.EndMenu();
                }

                if (ImGui.Checkbox("Mesh Picking", ref Pipeline._context.ColorPicker.EnablePicking))
                {
                    if (!Pipeline._context.ColorPicker.EnablePicking)
                    {
                        Pipeline._context.Scene.ResetSelected();
                    }
                }
                ImGui.Checkbox("Wireframe", ref Toolbox.Core.Runtime.RenderSettings.Wireframe);
                ImGui.Checkbox("WireframeOverlay", ref Toolbox.Core.Runtime.RenderSettings.WireframeOverlay);
                ImGui.Checkbox("Bounding Boxes", ref Toolbox.Core.Runtime.RenderBoundingBoxes);
                ImGui.Checkbox("Enable Bloom", ref Pipeline._context.EnableBloom);


                ImGui.EndMenu();
            }

            if (ImGui.BeginMenu($"Shading: [{Runtime.DebugRendering}]"))
            {
                foreach (var mode in Enum.GetValues(typeof(Runtime.DebugRender)))
                {
                    bool isSelected = (Runtime.DebugRender)mode == Runtime.DebugRendering;
                    if (ImGui.Selectable(mode.ToString(), isSelected))
                    {
                        Runtime.DebugRendering = (Runtime.DebugRender)mode;
                    }
                    if (isSelected)
                    {
                        ImGui.SetItemDefaultFocus();
                    }
                }
                ImGui.EndMenu();
            }

            if (ImGui.BeginMenu("Camera"))
            {
                if (ImGui.Button("Reset Transform"))
                {
                    Pipeline._context.Camera.ResetViewportTransform();
                }

                ImGuiHelper.ComboFromEnum <Camera.FaceDirection>("Direction", Pipeline._context.Camera, "Direction");
                if (ImGuiHelper.ComboFromEnum <Camera.CameraMode>("Mode", Pipeline._context.Camera, "Mode"))
                {
                    Pipeline._context.Camera.ResetViewportTransform();
                }

                ImGuiHelper.InputFromBoolean("Orthographic", Pipeline._context.Camera, "IsOrthographic");
                ImGuiHelper.InputFromBoolean("Lock Rotation", Pipeline._context.Camera, "LockRotation");

                ImGuiHelper.InputFromFloat("Fov (Degrees)", Pipeline._context.Camera, "FovDegrees", true, 1f);
                if (Pipeline._context.Camera.FovDegrees != 45)
                {
                    ImGui.SameLine(); if (ImGui.Button("Reset"))
                    {
                        Pipeline._context.Camera.FovDegrees = 45;
                    }
                }

                ImGuiHelper.InputFromFloat("ZFar", Pipeline._context.Camera, "ZFar", true, 1f);
                if (Pipeline._context.Camera.ZFar != 100000.0f)
                {
                    ImGui.SameLine(); if (ImGui.Button("Reset"))
                    {
                        Pipeline._context.Camera.ZFar = 100000.0f;
                    }
                }

                ImGuiHelper.InputFromFloat("ZNear", Pipeline._context.Camera, "ZNear", true, 0.1f);
                if (Pipeline._context.Camera.ZNear != 0.1f)
                {
                    ImGui.SameLine(); if (ImGui.Button("Reset"))
                    {
                        Pipeline._context.Camera.ZNear = 0.1f;
                    }
                }

                ImGuiHelper.InputFromFloat("Zoom Speed", Pipeline._context.Camera, "ZoomSpeed", true, 0.1f);
                if (Pipeline._context.Camera.ZoomSpeed != 1.0f)
                {
                    ImGui.SameLine(); if (ImGui.Button("Reset"))
                    {
                        Pipeline._context.Camera.ZoomSpeed = 1.0f;
                    }
                }

                ImGuiHelper.InputFromFloat("Pan Speed", Pipeline._context.Camera, "PanSpeed", true, 0.1f);
                if (Pipeline._context.Camera.PanSpeed != 1.0f)
                {
                    ImGui.SameLine(); if (ImGui.Button("Reset"))
                    {
                        Pipeline._context.Camera.PanSpeed = 1.0f;
                    }
                }

                ImGuiHelper.InputFromFloat("Key Move Speed", Pipeline._context.Camera, "KeyMoveSpeed", true, 0.1f);
                if (Pipeline._context.Camera.PanSpeed != 1.0f)
                {
                    ImGui.SameLine(); if (ImGui.Button("KeyMoveSpeed"))
                    {
                        Pipeline._context.Camera.KeyMoveSpeed = 1.0f;
                    }
                }

                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Reset Animations"))
            {
                TimelineWindow.Reset();
                ImGui.EndMenu();
            }

            ImGui.AlignTextToFramePadding();
            ImGui.Text("Active Model(s)");
            ImGui.SameLine();

            ImGui.PushItemWidth(250);
            if (ImGui.BeginCombo("##model_select", selectedModel))
            {
                bool isSelected = "All Models" == selectedModel;
                if (ImGui.Selectable("All Models", isSelected))
                {
                    selectedModel = "All Models";
                    ToggleModel();
                }
                if (isSelected)
                {
                    ImGui.SetItemDefaultFocus();
                }

                foreach (var file in Pipeline.Files)
                {
                    foreach (var model in file.Renderer.Models)
                    {
                        string name = $"{file.Renderer.Name}.{model.Name}";
                        isSelected = name == selectedModel;

                        if (ImGui.Selectable(name, isSelected))
                        {
                            selectedModel = name;
                            ToggleModel();
                        }
                        if (isSelected)
                        {
                            ImGui.SetItemDefaultFocus();
                        }
                    }
                }
                ImGui.EndCombo();
            }
            ImGui.PopItemWidth();
        }
Пример #9
0
        static object DisplayParam(string key, object value)
        {
            switch (ParamProperty.ParamType)
            {
            case ShaderParamType.Float:
            {
                float output = (float)value;
                if (ImGui.DragFloat(key, ref output))
                {
                    return(output);
                }
                break;
            }

            case ShaderParamType.Float2:
            {
                Vector2 output = (Vector2)value;
                if (ImGui.DragFloat2(key, ref output))
                {
                    return(output);
                }
                break;
            }

            case ShaderParamType.Float3:
            {
                Vector3 output = (Vector3)value;
                if (isColor)
                {
                    if (ImGui.ColorEdit3(key, ref output, ImGuiColorEditFlags.HDR | ImGuiColorEditFlags.Float))
                    {
                        return(output);
                    }
                }
                else
                {
                    if (ImGui.DragFloat3(key, ref output))
                    {
                        return(output);
                    }
                }
                break;
            }

            case ShaderParamType.Float4:
            {
                Vector4 output = (Vector4)value;
                if (isColor)
                {
                    if (ImGui.ColorEdit4(key, ref output, ImGuiColorEditFlags.HDR | ImGuiColorEditFlags.Float))
                    {
                        return(output);
                    }
                }
                else
                {
                    if (ImGui.DragFloat4(key, ref output))
                    {
                        return(output);
                    }
                }
                break;
            }

            case ShaderParamType.TexSrtEx:
            case ShaderParamType.TexSrt:
            {
                TextureSRT output = (TextureSRT)value;

                //6 columns
                bool edited = false;
                edited = edited || ImGuiHelper.ComboFromEnum <TexSrtMode>(key + "C0", output, "Mode", ImGuiComboFlags.NoArrowButton);
                ImGui.NextColumn();
                edited = edited || ImGuiHelper.InputFromFloat(key + "C1", output, "ScaleX", true, 0);
                ImGui.NextColumn();
                edited = edited || ImGuiHelper.InputFromFloat(key + "C2", output, "ScaleY", true, 0);
                ImGui.NextColumn();
                edited = edited || ImGuiHelper.InputFromFloat(key + "C3", output, "Rotate", true, 0);
                ImGui.NextColumn();
                edited = edited || ImGuiHelper.InputFromFloat(key + "C4", output, "TranslateX", true, 0);
                ImGui.NextColumn();
                edited = edited || ImGuiHelper.InputFromFloat(key + "C5", output, "TranslateY", true, 0);

                if (edited)
                {
                    return(output);
                }
                break;
            }
            }
            return(null);
        }
Пример #10
0
        static void LoadParamUI(ShaderParam param, string label = "", bool drag = false)
        {
            switch (param.Type)
            {
            case ShaderParamType.Bool:
            {
                ImGuiHelper.InputFromBoolean(label, param, "DataValue");
            }
            break;

            case ShaderParamType.Int:
            {
                ImGuiHelper.InputFromInt(label, param, "DataValue", 1, drag);
            }
            break;

            case ShaderParamType.UInt:
            {
                ImGuiHelper.InputFromUint(label, param, "DataValue", 1, drag);
            }
            break;

            case ShaderParamType.Float:
            {
                ImGuiHelper.InputFromFloat(label, param, "DataValue", drag);
            }
            break;

            case ShaderParamType.Float2:
            {
                ImGuiHelper.InputFloatsFromVector2(label, param, "DataValue", drag);
            }
            break;

            case ShaderParamType.Float3:
            {
                if (param.Name.Contains("color") || param.Name.Contains("Color"))
                {
                    ImGuiHelper.InputFloatsFromColor3(label, param, "DataValue");
                }
                else
                {
                    ImGuiHelper.InputFloatsFromVector3(label, param, "DataValue", drag);
                }
            }
            break;

            case ShaderParamType.Float4:
            {
                if (param.Name.Contains("color") || param.Name.Contains("Color"))
                {
                    ImGuiHelper.InputFloatsFromColor4(label, param, "DataValue", ImGuiColorEditFlags.AlphaBar | ImGuiColorEditFlags.AlphaPreviewHalf);
                }
                else
                {
                    ImGuiHelper.InputFloatsFromVector4(label, param, "DataValue", drag);
                }
            }
            break;

            case ShaderParamType.Srt2D:
            {
                Srt2D value = (Srt2D)param.DataValue;
                var   pos   = new Vector2(value.Translation.X, value.Translation.Y);
                var   scale = new Vector2(value.Scaling.X, value.Scaling.Y);
                var   rot   = value.Rotation;

                bool edited0 = ImGui.DragFloat2("Scale", ref scale);
                bool edited1 = ImGui.DragFloat("Rotate", ref rot, 0.1f);
                bool edited2 = ImGui.DragFloat2("Translate", ref pos);
                if (edited0 || edited1 || edited2)
                {
                    param.DataValue = new Srt2D()
                    {
                        Scaling     = new Syroot.Maths.Vector2F(scale.X, scale.Y),
                        Translation = new Syroot.Maths.Vector2F(pos.X, pos.Y),
                        Rotation    = rot,
                    };
                }
            }
            break;

            case ShaderParamType.TexSrt:
            case ShaderParamType.TexSrtEx:
            {
                TexSrt value   = (TexSrt)param.DataValue;
                bool   edited3 = ImGuiHelper.ComboFromEnum <TexSrtMode>("Mode", value, "Mode");
                var    pos     = new Vector2(value.Translation.X, value.Translation.Y);
                var    scale   = new Vector2(value.Scaling.X, value.Scaling.Y);
                var    rot     = value.Rotation;

                bool edited0 = ImGui.DragFloat2("Scale", ref scale);
                bool edited1 = ImGui.DragFloat("Rotate", ref rot, 0.1f);
                bool edited2 = ImGui.DragFloat2("Translate", ref pos);
                if (edited0 || edited1 || edited2 || edited3)
                {
                    param.DataValue = new TexSrt()
                    {
                        Mode        = value.Mode,
                        Scaling     = new Syroot.Maths.Vector2F(scale.X, scale.Y),
                        Translation = new Syroot.Maths.Vector2F(pos.X, pos.Y),
                        Rotation    = rot,
                    };
                }
            }
            break;
            }
        }