我在Monogame中做过类似的事情:
我的问题是,我需要做些什么才能将光照效果仅绘制在支柱而不是背景上?使用BlendState.Additive
时是否有忽略某些精灵的东西?那会怎么样?以下是我现在如何绘制它。
//draw background
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque);
spriteBatch.Draw(Background, Vector2.Zero, Color.White);
spriteBatch.End();
//draw pillar
spriteBatch.Begin(SpriteSortMode.Deferred);
spriteBatch.Draw(Texture, new Rectangle(PillarX, PillarY, Width, Height), Color.White);
spriteBatch.End();
//draw lighting sprite in additive mode
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive);
spriteBatch.Draw(LightTexture, pos, null, Color.OrangeRed, 0f, Vector2.Zero,
scale, SpriteEffects.None, 0f);
spriteBatch.End();
答案 0 :(得分:2)
基本上,您有两个选择:
我不会详细解释这一点,因为在gamedev stackexchange的this question广泛解释了这两种方式。