示例#1
0
        private void WritePostFxScript(ShaderOutputInfo info)
        {
            string textures = "";

            for (int i = 0; i < RegisterDict.Count; i++)
            {
                textures += "   texture[" + RegisterDict.Values.ElementAt(i) + "] = \"" + RegisterDict.Keys.ElementAt(i) + "\";\r\n";
            }

            StreamWriter SW = new StreamWriter(info.scriptPath + info.scriptFilename + ".cs");

            SW.Write(@"singleton ShaderData( PFX_" + info.outputFilename + @" )  
{     
   DXVertexShaderFile   = ""shaders/common/postFx/postFxV.hlsl"";  // bare-bones postFxV.hlsl
   DXPixelShaderFile    = """ + info.outputPath + info.outputFilename + @".hlsl"";  // new pixel shader   
   
   pixVersion = 3.0;  
};");
            SW.WriteLine();
            SW.Write(@"singleton PostEffect(" + info.outputFilename + @")  
{
   isEnabled = true;

   renderTime = ""PFXAfterDiffuse"";  

" + textures + @"
   shader = PFX_" + info.outputFilename + @";  
   stateBlock = PFX_DefaultStateBlock;    
};");
            SW.Close();
        }
示例#2
0
        private void WritePostFxScript(ShaderOutputInfo info)
        {
            string textures = "";
             for(int i = 0; i < RegisterDict.Count; i++)
             {
            textures += "   texture[" + RegisterDict.Values.ElementAt(i) + "] = \"" + RegisterDict.Keys.ElementAt(i) + "\";\r\n";
             }

             StreamWriter SW = new StreamWriter(info.scriptPath + info.scriptFilename + ".cs");
             SW.Write(@"singleton ShaderData( PFX_" + info.outputFilename + @" )
            {
               DXVertexShaderFile   = ""shaders/common/postFx/postFxV.hlsl"";  // bare-bones postFxV.hlsl
               DXPixelShaderFile    = """ + info.outputPath + info.outputFilename + @".hlsl"";  // new pixel shader

               pixVersion = 3.0;
            };");
             SW.WriteLine();
             SW.Write(@"singleton PostEffect(" + info.outputFilename + @")
            {
               isEnabled = true;

               renderTime = ""PFXAfterDiffuse"";

            " + textures + @"
               shader = PFX_" + info.outputFilename + @";
               stateBlock = PFX_DefaultStateBlock;
            };");
             SW.Close();
        }
示例#3
0
        public void Compile(ProgramGraph graph, CompilerOutputInfo info)
        {
            if (!(info is ShaderOutputInfo))
            {
                return;
            }
            ShaderOutputInfo outputInfo = info as ShaderOutputInfo;

            RegisterDict = new Dictionary <string, int>();
            for (int i = 0; i < graph.getMaxDepth(); i++)
            {
                foreach (Vertex v in graph.getVerticesForLayer(i))
                {
                    foreach (NodeItem outputItem in v.Data.Items.Where(item => item.Output.Enabled))
                    {
                        if (outputItem.OutputData is ShaderTypes.sampler2D)
                        {
                            ShaderTypes.sampler2D Sampler = (ShaderTypes.sampler2D)outputItem.OutputData;
                            if (!RegisterDict.ContainsKey(Sampler.path))
                            {
                                RegisterDict.Add(Sampler.path, RegisterDict.Count);
                            }
                        }
                    }
                }
            }
            mCompiler = new HLSLCompiler(new Dictionary <object, string>(), RegisterDict);
            WritePostFxScript(outputInfo);
            if (mCompiler == null)
            {
                return;
            }
            mCompiler.Compile(graph, outputInfo);
        }
示例#4
0
 private void CompileButton_Click(object sender, EventArgs e)
 {
     GraphModel model = new GraphModel(new FileDependencyParserStrategy(), new DelimiterSerializationStrategy(), (List<Node>)graphControl.Nodes);
      Compiler compiler = new T3DPostFxCompiler();
      ShaderOutputInfo outInfo = new ShaderOutputInfo();
      outInfo.outputFilename = "compiledFile";
      outInfo.outputPath = "output/";
      outInfo.scriptFilename = "compiledScriptFile";
      outInfo.scriptPath = "outputScript/";
      compiler.Compile(new ProgramGraph(model), outInfo);
 }