private InjectedHlslProgramType GetIncludeProgramType(InjectedHlslProgramType injectedHlslProgramType)
        {
            switch (injectedHlslProgramType)
            {
            case InjectedHlslProgramType.CGProgram:
                return(InjectedHlslProgramType.CGInclude);

            case InjectedHlslProgramType.HLSLProgram:
                return(InjectedHlslProgramType.HLSLInclude);

            default:
                return(InjectedHlslProgramType.Uknown);
            }
        }
        private IEnumerable <CppFileLocation> GetIncludesLocation(IPsiSourceFile sourceFile, InjectedHlslProgramType type)
        {
            if (type == InjectedHlslProgramType.Uknown)
            {
                return(EnumerableCollection <CppFileLocation> .Empty);
            }

            return(Map[sourceFile]
                   .Where(d => d.ProgramType == type)
                   .Select(d => d.ToCppFileLocation()));
        }
        private IEnumerable <CppFileLocation> GetIncludes(IPsiSourceFile sourceFile, InjectedHlslProgramType type, bool isSurface)
        {
            var includeType = GetIncludeProgramType(type);

            var includeList = new List <CppFileLocation>();

            includeList.Add(new CppFileLocation(myCppExternalModule, mySolution.SolutionDirectory.Combine(Utils.ShaderConfigFile)));

            if (includeType != InjectedHlslProgramType.Uknown)
            {
                var includes = GetIncludesLocation(sourceFile, includeType);
                foreach (var include in includes)
                {
                    includeList.Add(include);
                }
            }

            var cgIncludeFolder = CgIncludeDirectoryTracker.GetCgIncludeFolderPath(myUnityVersion);

            if (cgIncludeFolder.ExistsDirectory)
            {
                if (type == InjectedHlslProgramType.CGProgram)
                {
                    var hlslSupport = cgIncludeFolder.Combine("HLSLSupport.cginc");
                    if (hlslSupport.ExistsFile)
                    {
                        includeList.Add(new CppFileLocation(myCppExternalModule, hlslSupport));
                    }

                    var variables = cgIncludeFolder.Combine("UnityShaderVariables.cginc");
                    if (variables.ExistsFile)
                    {
                        includeList.Add(new CppFileLocation(myCppExternalModule, variables));
                    }


                    // from surface shader generated code
                    if (isSurface)
                    {
                        var unityCG = cgIncludeFolder.Combine("UnityCG.cginc");
                        if (unityCG.ExistsFile)
                        {
                            includeList.Add(new CppFileLocation(myCppExternalModule, unityCG));
                        }

                        var lighting = cgIncludeFolder.Combine("Lighting.cginc");
                        if (lighting.ExistsFile)
                        {
                            includeList.Add(new CppFileLocation(myCppExternalModule, lighting));
                        }

                        var unityPbsLighting = cgIncludeFolder.Combine("UnityPBSLighting.cginc");
                        if (unityPbsLighting.ExistsFile)
                        {
                            includeList.Add(new CppFileLocation(myCppExternalModule, unityPbsLighting));
                        }

                        var autoLight = cgIncludeFolder.Combine("AutoLight.cginc");
                        if (autoLight.ExistsFile)
                        {
                            includeList.Add(new CppFileLocation(myCppExternalModule, autoLight));
                        }
                    }
                }
            }

            return(includeList);
        }
Exemple #4
0
 public InjectedHlslLocationInfo(FileSystemPath path, TextRange range, InjectedHlslProgramType programType)
 {
     FileSystemPath = path;
     Range          = range;
     ProgramType    = programType;
 }