cbuffer cbGlobals
{
float4 emissive;
};
struct VS_IN
float4 pos : POSITION;
float4 col : COLOR;
struct PS_IN
float4 pos : SV_POSITION;
PS_IN VS( VS_IN input)
PS_IN output = (PS_IN)0;
output.pos = input.pos;
//<VertexColor>
output.col += input.col;
//</VertexColor>
//<NotVertexColor>
output.col += 0.1;
//</NotVertexColor>
//<EmissiveColor>
output.col += emissive;
//</EmissiveColor>
return output;
}
float4 PS( PS_IN input ) : SV_Target
return input.col;
technique10 Render
pass P0
SetGeometryShader( 0 );
SetVertexShader( CompileShader( vs_4_0, VS() ) );
SetPixelShader( CompileShader( ps_4_0, PS() ) );
static string ProcessCode(string code, string var, bool value)
if (!value)
Regex exp = new Regex(string.Format(@"(//\<{0}\>(.(?!//</{0}>))+.//\</{0}\>)", var),
RegexOptions.Singleline);
code = exp.Replace(code, "");
else
Regex exp = new Regex(string.Format(@"(//\<Not{0}\>(.(?!//</Not{0}>))+.//\</Not{0}\>)", var),
return code;
string code = File.ReadAllText("MiniTri.fx");
code = ProcessCode(code, "VertexColor", false);
code = ProcessCode(code, "EmissiveColor", true);
var effect = Effect.FromString(device, code, "fx_4_0", ShaderFlags.None,
EffectFlags.None, null, null);
//<Texture>
float3 tex : TEXCOORD0;
//</Texture>