[英]Going back to SpriteBatch.Draw() after using GraphicsDevice.DrawUserPrimitives()
[英]Using Color specified in SpriteBatch.Draw with Custom shader
通常,當您執行SpriteBatch.Draw
您可以指定顏色。 但這是問題所在。 如果我使用自定義着色器,他們會忽略SpriteBatch.Draw
傳遞的顏色......
我該如何考慮到這一點? 我的意思是SpriteBatch.Draw
究竟是如何傳遞顏色的? 如果我知道它我可以在我的着色器中使用它。
到目前為止我所擁有的(相關部分):
float4 NoEffects(float2 coords: TEXCOORD0) : COLOR0
{
return tex2D(s0, coords);
}
technique Default
{
pass Pass1
{
PixelShader = compile ps_2_0 NoEffects();
}
}
您需要檢索通過頂點着色器的顏色,並在計算最終輸出時使用它:
float4 NoEffects(float4 color : COLOR0, float2 coords : TEXCOORD0) : COLOR0
{
return tex2D(s0, coords) * color;
}
您可以使用EffectParameter將值傳遞給效果。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.