Пример #1
0
        public void OnEnable()
        {
            envCube            = FindProperty(x => x.envCube);
            skyMat             = FindProperty(x => x.SkyBoxMat);
            hdrScale           = FindProperty(x => x.hdrScale);
            hdrPow             = FindProperty(x => x.hdrPow);
            hdrAlpha           = FindProperty(x => x.hdrAlpha);
            iblLevel           = FindProperty(x => x.iblLevel);
            iblLevel.intValue  = 1;
            lightmapShadowMask = FindParameter(x => x.lightmapShadowMask);
            shadowIntensity    = FindParameter(x => x.shadowIntensity);
            fogEnable          = FindProperty(x => x.fogEnable);

            roleLight0 = FindProperty(x => x.roleLight0);
            roleLight1 = FindProperty(x => x.roleLight1);

            shadowMapLevel    = FindProperty(x => x.shadowMapLevel);
            shadowBound       = FindProperty(x => x.shadowBound);
            lookTarget        = FindProperty(x => x.lookTarget);
            drawShadowLighing = FindProperty(x => x.drawShadowLighing);
            showObjects       = FindProperty(x => x.showObjects);
            debugMode         = FindProperty(x => x.debugContext.debugMode);
            debugDisplayType  = FindProperty(x => x.debugContext.debugDisplayType);
            splitAngle        = FindParameter(x => x.debugContext.splitAngle);
            splitPos          = FindProperty(x => x.debugContext.splitPos);

            AssetsConfig.RefreshShaderDebugNames();
        }
Пример #2
0
        protected virtual void FindProperties(MaterialProperty[] props)
        {
            baseColorMp          = null;
            shaderPropertyGroups = new List <ShaderGroupInstance>();
            hasDepency.Clear();
            for (int i = 0; i < AssetsConfig.GlobalAssetsConfig.ShaderGroupInfo.Count; ++i)
            {
                string groupName = AssetsConfig.GlobalAssetsConfig.ShaderGroupInfo[i];
                shaderPropertyGroups.Add(new ShaderGroupInstance()
                {
                    name = groupName
                });
            }

            Shader shader           = m_Material.shader;
            var    shaderFeatureMap = AssetsConfig.GetShaderFeatureList();

            for (int i = 0; i < AssetsConfig.GlobalAssetsConfig.ShaderInfos.Count; ++i)
            {
                var si = AssetsConfig.GlobalAssetsConfig.ShaderInfos[i];
                if (si.shader != null && si.shader.name == shader.name)
                {
                    for (int j = 0; j < si.shaderFeatures.Count; ++j)
                    {
                        string featurename = si.shaderFeatures[j];
                        AssetsConfig.ShaderFeature sf;
                        if (shaderFeatureMap.TryGetValue(featurename, out sf))
                        {
                            MaterialProperty mp = null;
                            if (!string.IsNullOrEmpty(sf.propertyName))
                            {
                                mp = FindProperty(sf.propertyName, props, false);
                            }
                            if (sf.type == AssetsConfig.ShaderPropertyType.CustomGroup)
                            {
                                for (int k = 0; k < sf.customProperty.Length; ++k)
                                {
                                    var cp = sf.customProperty[k];
                                    if (cp.valid && !string.IsNullOrEmpty(cp.desc))
                                    {
                                        ShaderGroupInstance sgi = null;
                                        if (string.IsNullOrEmpty(cp.subGroup))
                                        {
                                            sgi = shaderPropertyGroups[shaderPropertyGroups.Count - 1];
                                        }
                                        else
                                        {
                                            sgi = shaderPropertyGroups.Find((param) => { return(param.name == cp.subGroup); });
                                        }

                                        if (sgi == null)
                                        {
                                            sgi = new ShaderGroupInstance()
                                            {
                                                name = cp.subGroup
                                            };
                                            sgi.hasCustomGroup = true;
                                            shaderPropertyGroups.Add(sgi);
                                        }
                                        ShaderPropertyInstance spi = new ShaderPropertyInstance();
                                        spi.shaderFeature = sf;
                                        spi.property      = mp;
                                        spi.scp           = cp;
                                        spi.customIndex   = k;
                                        sgi.spiList.Add(spi);
                                    }
                                }
                            }
                            else
                            {
                                ShaderPropertyInstance spi = new ShaderPropertyInstance();
                                spi.shaderFeature = sf;
                                spi.property      = mp;
                                ShaderGroupInstance sgi = shaderPropertyGroups.Find((param) => { return(param.name == sf.shaderGroupName); });
                                if (sgi == null)
                                {
                                    sgi = shaderPropertyGroups[shaderPropertyGroups.Count - 1];
                                }
                                sgi.spiList.Add(spi);
                                if (sf.name == "Color")
                                {
                                    baseColorMp = spi.property;
                                }
                            }

                            if (sf.type == AssetsConfig.ShaderPropertyType.Keyword &&
                                !hasDepency.Contains(sf.name) &&
                                m_Material.IsKeywordEnabled(sf.propertyName))
                            {
                                hasDepency.Add(sf.name);
                            }
                        }
                    }
                    break;
                }
            }
            customFunc.Clear();
            customFunc.Add("BlendMode", BlendModePopup);
            customFunc.Add("Debug", DoDebugArea);
            AssetsConfig.RefreshShaderDebugNames();
            GameObject go = Selection.activeGameObject;

            if (go != null)
            {
                dd = go.GetComponent <DebugData>();
            }
            Update();
        }