我目前正在为我的XNA游戏学习效果文件的语言“HLSL”。然而;我遇到了将效果应用到我的SpriteBatch的问题。
我的效果文件看起来像这样,并使渲染的纹理为白色。 :]2D Passes.apply()XNA 4.0
float4 PSFunction(float2 coord : TEXCOORD0) : COLOR0
{
return float4(0, 0, 0, 1); // Return a white pixel
}
technique Sample
{
pass pass0
{
PixelShader = compile ps_2_0 PSFunction();
}
}
它,它应该工作,当我开始我的SpriteBatch具有以下参数:
SpriteBatch.Begin(0, null, null, null, null, SampleEffect);
然而, SpriteBatch.Begin方法不接受多个效果。因此,我打过电话
SpriteBatch.Begin();
但没有happend之前做
SampleEffect.CurrentTechnique.Passes[0].Apply();
,因此我尝试几个diffrend方法。如
SampleEffect.CurrentTechnique.Passes["pass0"].Apply();
但它仍然没有工作。 因此,我使用object.ReferenceEquals函数验证了效果已附加到正确的GraphicsDevice,但它等于正确的graphicsDevice。 我在做什么错?我将如何将多个效果附加到我的SpriteBatch?
由于提前,拉斯穆斯:]
我想补充一点,这种技术叫做[multipass lightning](https://www.google.com/search?q=multipass%20vs%20deferred%20lighting)。 – AgentFire