Example #1
0
		private static void WritePixelInputStructs(EffectCodeGenerator generator, 
			TechniqueSymbol technique, TechniquePassSymbol pass, string uniquePassName)
		{
			generator.Writer.WriteLine("// -------- pixel input structures --------");

			SemanticGenerator semanticGenerator = new SemanticGenerator("TEXCOORD");
			pass.ForEachFragment(generator, (g, f, s) => WritePixelInputStructure(g, f, s, semanticGenerator));

			generator.Writer.WriteLine("struct {0}_PIXELINPUT", uniquePassName);
			generator.Writer.WriteLine("{");
			pass.ForEachFragment(generator, (g, f, s) => g.Writer.WriteLine("\t{0}_{1}_PIXELINPUT {1};", s, f.UniqueName));
			generator.Writer.WriteLine("};");
			generator.Writer.WriteLine();
			generator.Writer.WriteLine("static {0}_PIXELINPUT gPixelInput_{0};", uniquePassName);
			generator.Writer.WriteLine();
		}
Example #2
0
		private static void WritePixelOutputStructs(EffectCodeGenerator generator,
			TechniqueSymbol technique, TechniquePassSymbol pass, string uniquePassName)
		{
			ScriptTextWriter writer = generator.Writer;
			writer.WriteLine("// -------- pixel output structures --------");

			SemanticGenerator semanticGenerator = new SemanticGenerator("COLOR", 1);
			pass.ForEachFragment(generator, (g, f, n) => WritePixelOutputStructure(g, f, n, semanticGenerator));

			writer.WriteLine("struct {0}_PIXELOUTPUT", uniquePassName);
			writer.WriteLine("{");
			writer.WriteLine("\tfloat4 color : COLOR0;");
			pass.ForEachFragment(generator, (g, f, s) =>
			{
				if (f.FragmentNode.PixelOutputs != null && f.FragmentNode.PixelOutputs.VariableDeclarations.Any())
					writer.WriteLine("\t{0}_{1}_PIXELOUTPUT {1};", s, f.UniqueName);
			});
			writer.WriteLine("};");
			writer.WriteLine();
		}
Example #3
0
		public static void WriteVertexShaders(EffectCodeGenerator generator, 
			TechniqueSymbol technique, TechniquePassSymbol pass, string uniquePassName)
		{
			Dictionary<string, List<string>> exports = new Dictionary<string, List<string>>();
			pass.ForEachFragment(generator, (codeGenerator, symbol, s) => WriteVertexShader(codeGenerator, symbol, s, exports));

			ScriptTextWriter writer = generator.Writer;

			// Write one vertex shader for each technique pass.
			writer.WriteLine("// -------- technique {0}, pass {1} vertex shader entrypoint --------", technique.Name, pass.Name);
			writer.WriteLine("{0}_VERTEXOUTPUT {0}_vs(const {0}_VERTEXINPUT i)", uniquePassName);
			writer.WriteLine("{");
			writer.WriteLine("\tgVertexInput_{0} = i;", uniquePassName);
			writer.WriteLine();
			writer.WriteLine("\t{0}_VERTEXOUTPUT output = ({0}_VERTEXOUTPUT) 0;", uniquePassName);
			writer.WriteLine();

			pass.ForEachFragment(generator, (g, f, s) => g.Writer.WriteLine("\t{0}_{1}_vs(gVertexInput_{0}.{1}, output);", uniquePassName, f.UniqueName));

			writer.WriteLine();
			writer.WriteLine("\treturn output;");
			writer.WriteLine("}");
			writer.WriteLine();
		}
Example #4
0
		private static void WriteVertexInputStructures(EffectCodeGenerator generator, 
			TechniqueSymbol technique, TechniquePassSymbol pass, string uniquePassName)
		{
			ScriptTextWriter writer = generator.Writer;

			writer.WriteLine("// -------- vertex input structures --------");

			SemanticGenerator semanticGenerator = new SemanticGenerator("TEXCOORD");
			pass.ForEachFragment(generator, (g, f, s) => WriteVertexInputStructure(g, f, s, semanticGenerator));

			writer.WriteLine("struct {0}_VERTEXINPUT", uniquePassName);
			writer.WriteLine("{");

			pass.ForEachFragment(generator, (g, f, s) => g.Writer.WriteLine("\t{0}_{1}_VERTEXINPUT {1};", uniquePassName, f.UniqueName));

			writer.WriteLine("};");
			writer.WriteLine();
			writer.WriteLine("static {0}_VERTEXINPUT gVertexInput_{0};", uniquePassName);
			writer.WriteLine();
		}
Example #5
0
		private static void WriteVertexOutputStructs(EffectCodeGenerator generator, 
			TechniqueSymbol technique, TechniquePassSymbol pass, string uniquePassName)
		{
			ScriptTextWriter writer = generator.Writer;

			writer.WriteLine("// -------- vertex output structures --------");
			writer.WriteLine("struct {0}_VERTEXOUTPUT", uniquePassName);
			writer.WriteLine("{");
			writer.WriteLine("\tfloat4 position : POSITION;");
			pass.ForEachFragment(generator, (g, f, s) =>
			{
				if (f.FragmentNode.Interpolators != null && f.FragmentNode.Interpolators.VariableDeclarations.Any())
					g.Writer.WriteLine("\t{0}_{1}_PIXELINPUT {1};", uniquePassName, f.UniqueName);
			});
			writer.WriteLine("};");
			writer.WriteLine();
		}
Example #6
0
		private static void WritePixelShaders(EffectCodeGenerator generator, 
			TechniqueSymbol technique, TechniquePassSymbol pass, string uniquePassName)
		{
			Dictionary<string, List<string>> exports = new Dictionary<string, List<string>>();
			pass.ForEachFragment(generator, (codeGenerator, symbol, s) => WritePixelShader(codeGenerator, symbol, s, exports));

			ScriptTextWriter writer = generator.Writer;
			writer.WriteLine("// -------- technique {0}, pass {1} pixel shader entrypoint --------", technique.Name, pass.Name);
			writer.WriteLine("{0}_PIXELOUTPUT {0}_ps(const {0}_PIXELINPUT i)", uniquePassName);
			writer.WriteLine("{");
			writer.WriteLine("\tgPixelInput_{0} = i;", uniquePassName);
			writer.WriteLine();
			writer.WriteLine("\t{0}_PIXELOUTPUT output = ({0}_PIXELOUTPUT) 0;", uniquePassName);
			writer.WriteLine();
			pass.ForEachFragment(generator, (g, f, s) =>
			{
				ShaderCodeBlockNode shader = f.FragmentNode.PixelShaders.GetCodeBlock(generator.Context.TargetShaderProfile);
				if (shader != null)
					writer.WriteLine("\t{0}_{1}_ps(gPixelInput_{0}.{1}, output);", uniquePassName, f.UniqueName);
			});
			writer.WriteLine();
			writer.WriteLine("\treturn output;");
			writer.WriteLine("}");
			writer.WriteLine();
		}