Ejemplo n.º 1
0
        private bool isMatch(ShaderInfo shaderInfo)
        {
            switch (_mode)
            {
            case ShaderViewerMode.MaxLOD:
                return(MaxLOD == ViewerConst.GetLodIndex(shaderInfo.MaxLOD));

            case ShaderViewerMode.RenderQueue:
                return(RenderQueue == ViewerConst.GetRenderQueueIndex(shaderInfo.RenderQueue));

            case ShaderViewerMode.Pass:
                return(Pass == shaderInfo.Pass);

            case ShaderViewerMode.Instruction:
                return(Instruction == ViewerConst.GetInstructionIndex(shaderInfo.Instruction));

            case ShaderViewerMode.Variant:
                return(Variant == shaderInfo.Variant);

            case ShaderViewerMode.Property:
                return(Property == shaderInfo.Property);

            case ShaderViewerMode.SubShader:
                return(SubShader == shaderInfo.SubShader);

            case ShaderViewerMode.Sample:
                return(Sample == shaderInfo.Sample);

            case ShaderViewerMode.RenderType:
                return(RenderType == shaderInfo.RenderType);
            }
            return(false);
        }
Ejemplo n.º 2
0
 public ShaderViewerData(string mode, ShaderInfo shaderInfo)
 {
     _mode          = (ShaderViewerMode)Enum.Parse(typeof(ShaderViewerMode), mode);
     MaxLOD         = ViewerConst.GetLodIndex(shaderInfo.MaxLOD);
     MaxLODStr      = ViewerConst.LoadSizeStr[MaxLOD];
     RenderQueue    = ViewerConst.GetRenderQueueIndex(shaderInfo.RenderQueue);
     RenderQueueStr = ViewerConst.RenderQueueStr[RenderQueue];
     Pass           = shaderInfo.Pass;
     Instruction    = ViewerConst.GetInstructionIndex(shaderInfo.Instruction);
     InstructionStr = ViewerConst.InstructionSizeStr[Instruction];
     Variant        = shaderInfo.Variant;
     Property       = shaderInfo.Property;
     SubShader      = shaderInfo.SubShader;
     Sample         = shaderInfo.Sample;
     RenderType     = shaderInfo.RenderType;
 }
Ejemplo n.º 3
0
        public static ShaderInfo CreateShaderInfo(string assetPath)
        {
            if (!EditorPath.IsShader(assetPath))
            {
                return(null);
            }

            ShaderInfo shaderInfo = null;

            if (!_dictShaderInfo.TryGetValue(assetPath, out shaderInfo))
            {
                shaderInfo = new ShaderInfo();
                _dictShaderInfo.Add(assetPath, shaderInfo);
            }
            Shader shader     = AssetDatabase.LoadAssetAtPath <Shader>(assetPath);
            string shaderText = File.ReadAllText(assetPath);

            //ShaderUtil.OpenCompiledShader(shader, (int)ShaderPlatformModes.Custom, 1 << (int)ShaderUtil.ShaderCompilerPlatformType.D3D11, false);

            typeof(ShaderUtil).GetMethod("OpenCompiledShader", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, new object[] { shader, (int)ShaderPlatformModes.Custom, 1 << (int)ShaderCompilerPlatformType.D3D11, false });
            try
            {
                CompiledShaderInfo compiledShaderInfo = CompiledShaderInfo.CreateCompiledShaderInfo(shaderText);
                shaderInfo.Path = assetPath;
                //shaderInfo.MaxLOD = ShaderUtil.GetLOD(shader);
                //shaderInfo.Variant = ShaderUtil.GetVariantCount(shader, true);
                shaderInfo.Property    = ShaderUtil.GetPropertyCount(shader);
                shaderInfo.RenderQueue = shader.renderQueue;
                shaderInfo.Pass        = compiledShaderInfo.GetPass();
                shaderInfo.Instruction = compiledShaderInfo.GetInstruction();
                shaderInfo.SubShader   = compiledShaderInfo.GetSubShaderCount();
                shaderInfo.Sample      = compiledShaderInfo.GetSample();
                shaderInfo.RenderType  = compiledShaderInfo.GetRenderType();
                shaderInfo.CompiledShaderInfoList.Add(compiledShaderInfo);
            }
            catch (Exception ex)
            {
                Debug.LogError(ex.Message);
                return(null);
            }
            return(shaderInfo);
        }
Ejemplo n.º 4
0
        public static List <ShaderInfo> GetInfoByDirectory(string dir)
        {
            List <ShaderInfo> shaderInfoList = new List <ShaderInfo>();
            List <string>     list           = new List <string>();

            EditorPath.ScanDirectoryFile(dir, true, list);
            for (int i = 0; i < list.Count; ++i)
            {
                string assetPath = EditorPath.FormatAssetPath(list[i]);
                string name      = System.IO.Path.GetFileName(assetPath);
                EditorUtility.DisplayProgressBar("获取Shader数据", name, (i * 1.0f) / list.Count);
                ShaderInfo shaderInfo = CreateShaderInfo(assetPath);
                if (shaderInfo != null)
                {
                    shaderInfoList.Add(shaderInfo);
                }
            }
            EditorUtility.ClearProgressBar();
            return(shaderInfoList);
        }
Ejemplo n.º 5
0
 private void addObject(ShaderInfo shaderInfo)
 {
     _object.Add(shaderInfo);
     Count++;
 }