コード例 #1
0
        public void Draw(Light l)
        {
            AdditionalLightData ald = l.GetComponent <AdditionalLightData>();

            Debug.Assert(ald != null, "Light has no valid AdditionalLightData component attached.");

            GPUShadowType shadowType;

            ShadowUtils.MapLightType(ald.archetype, l.type, out shadowType);

            // check if this has supported shadows
            if ((int)shadowType >= ShadowConstants.Counts.k_GPUShadowType)
            {
                return;
            }

            int  shadowAlgorithm;
            int  shadowVariant;
            int  shadowPrecision;
            bool globalOverride = m_GlobalOverrides[(int)shadowType].enabled;

            if (globalOverride)
            {
                shadowAlgorithm = (int)m_GlobalOverrides[(int)shadowType].algorithm;
                shadowVariant   = (int)m_GlobalOverrides[(int)shadowType].variant;
                shadowPrecision = (int)m_GlobalOverrides[(int)shadowType].precision;
            }
            else
            {
                ald.GetShadowAlgorithm(out shadowAlgorithm, out shadowVariant, out shadowPrecision);
            }

            DrawWidgets(l, shadowType, (ShadowAlgorithm)shadowAlgorithm, (ShadowVariant)shadowVariant, (ShadowPrecision)shadowPrecision, globalOverride);
        }
コード例 #2
0
ファイル: ShadowBase.cs プロジェクト: clientbase/Schussskizze
        public bool GetGlobalShadowOverride(GPUShadowType shadowType, ref GPUShadowAlgorithm algo)
        {
            if (m_GlobalOverrides[(int)shadowType].enabled)
            {
                algo = ShadowUtils.Pack(m_GlobalOverrides[(int)shadowType].algorithm, m_GlobalOverrides[(int)shadowType].variant, m_GlobalOverrides[(int)shadowType].precision);
            }

            return(m_GlobalOverrides[(int)shadowType].enabled);
        }
コード例 #3
0
ファイル: ShadowBase.cs プロジェクト: clientbase/Schussskizze
        void DrawWidgets(Light l, GPUShadowType shadowType, ShadowAlgorithm shadowAlgorithm, ShadowVariant shadowVariant, ShadowPrecision shadowPrecision, bool globalOverride)
        {
#if UNITY_EDITOR
            var          dict        = m_Entries[(int)shadowType];
            int[]        algoOptions = new int[dict.Count];
            GUIContent[] algoDescs   = new GUIContent[dict.Count];
            int          idx         = 0;

            foreach (var entry in dict)
            {
                algoOptions[idx] = (int)entry.Key;
                algoDescs[idx]   = new GUIContent(entry.Value.algorithmDesc);
                idx++;
            }

            using (new UnityEditor.EditorGUI.DisabledGroupScope(globalOverride))
            {
                UnityEditor.EditorGUI.BeginChangeCheck();
                shadowAlgorithm = (ShadowAlgorithm)UnityEditor.EditorGUILayout.IntPopup(new GUIContent("Shadow Algorithm"), (int)shadowAlgorithm, algoDescs, algoOptions);
                if (UnityEditor.EditorGUI.EndChangeCheck())
                {
                    shadowVariant = 0;
                }
            }

            UnityEditor.EditorGUI.indentLevel++;
            Entry e = dict[shadowAlgorithm];

            int          varsAvailable = e.variantsAvailable;
            int[]        varOptions    = new int[varsAvailable];
            GUIContent[] varDescs      = new GUIContent[varsAvailable];

            idx = 0;
            for (int writeIdx = 0; writeIdx < varsAvailable; idx++)
            {
                if (e.variantDels[idx].low != null || e.variantDels[idx].high != null)
                {
                    varOptions[writeIdx] = idx;
                    varDescs[writeIdx]   = new GUIContent(e.variantDescs[idx]);
                    writeIdx++;
                }
            }

            UnityEditor.EditorGUILayout.BeginHorizontal();

            using (new UnityEditor.EditorGUI.DisabledGroupScope(globalOverride))
            {
                shadowVariant = (ShadowVariant)UnityEditor.EditorGUILayout.IntPopup(new GUIContent("Variant + Precision"), (int)shadowVariant, varDescs, varOptions);

                if (e.variantDels[(int)shadowVariant].low != null && e.variantDels[(int)shadowVariant].high != null)
                {
                    GUIContent[] precDescs   = new GUIContent[] { new GUIContent("High"), new GUIContent("Low") };
                    int[]        precOptions = new int[] { 0, 1 };
                    shadowPrecision = (ShadowPrecision)UnityEditor.EditorGUILayout.IntPopup((int)shadowPrecision, precDescs, precOptions, GUILayout.MaxWidth(65));
                }
                else
                {
                    using (new UnityEditor.EditorGUI.DisabledScope())
                    {
                        GUIContent[] precDescs   = new GUIContent[] { new GUIContent(e.variantDels[(int)shadowVariant].low == null ? "High" : "Low") };
                        int[]        precOptions = new int[] { e.variantDels[(int)shadowVariant].low == null ? 0 : 1 };
                        UnityEditor.EditorGUILayout.IntPopup(precOptions[0], precDescs, precOptions, GUILayout.MaxWidth(65));
                        shadowPrecision = (ShadowPrecision)precOptions[0];
                    }
                }
            }

            AdditionalShadowData asd        = l.GetComponent <AdditionalShadowData>();
            GPUShadowAlgorithm   packedAlgo = ShadowUtils.Pack(shadowAlgorithm, shadowVariant, shadowPrecision);
            int[] shadowData = null;
            if (!GUILayout.Button("Reset", GUILayout.MaxWidth(80.0f)))
            {
                shadowData = asd.GetShadowData((int)packedAlgo);
            }

            UnityEditor.EditorGUILayout.EndHorizontal();

            if (shadowPrecision == ShadowPrecision.Low)
            {
                e.variantDels[(int)shadowVariant].low(l, shadowAlgorithm, shadowVariant, shadowPrecision, ref shadowData);
            }
            else
            {
                e.variantDels[(int)shadowVariant].high(l, shadowAlgorithm, shadowVariant, shadowPrecision, ref shadowData);
            }
            asd.SetShadowAlgorithm((int)shadowAlgorithm, (int)shadowVariant, (int)shadowPrecision, (int)packedAlgo, shadowData);

            UnityEditor.EditorGUI.indentLevel--;
#endif
        }