您可以在效果定義不同的技術文件是這樣的:
// shading code ...
technique Technique1
{
pass Pass1
{
// VertexShader = ...
// PixelShader = ...
}
pass Pass2
{
// VertexShader = ...
// PixelShader = ...
}
// more passes if you want
}
technique Technique2
{
pass Pass1
{
// VertexShader = ...
// PixelShader = ...
}
// more Passes if you want ...
}
從你的C#代碼使用的效果文件,如下所示:
// declar your variable by loading the effect file from the content pipeline
Effect effect = ContentManager.Load<Effect>("NameOfMyEffectFile");
// use a particular technique
effect.CurrentTechnique = effect.Techniques["Technique1"];
// apply a particular pass
effect.CurrentTechnique.Passes[1].Apply();
// begin some drawing
effect.Begin();
// draw ...
// end some drawing
effect.End();
如果你想申請多遍,只要重複所有這些:
foreach(EffectPass p in effect.CurrentTechnique.Passes)
{
// begin some drawing
p.Begin();
// draw ...
// end some drawing
p.End();
}
哦,這是非常深奧的!非常感謝您解釋! – NewProger
不客氣:) –