@YGHTssk wrote:
I have just trying to add HLSL effect to SpriteBatch.Draw() method.
So,I tried like this;foreach (CustomComponent cr in cus) { foreach (var v in cr.func) _blurEffect.Parameters["E_" + v].SetValue(cr.funcCfg[v]); spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone, _blurEffect); cr.Draw(spriteBatch, camera, this.GraphicsDevice); spriteBatch.End(); }
note)"CustomComponent" is contains drawable objectives and "cus" is a list of its.
But, this code caused a problem, like this.
[PROBLEM IMG]And... change the codes, this problem can be fixed.
[FIXED CODE]foreach (var v in cus[0].func) _blurEffect.Parameters["E_" + v].SetValue(cus[0].funcCfg[v]); spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone, _blurEffect); foreach (CustomComponent cr in cus) { cr.Draw(spriteBatch, camera, this.GraphicsDevice); } spriteBatch.End();
[FIXED IMAGE]
I think this problem caused by spriteBatch.Draw(); inside foreach.
But, I can't use Effect per one sprite If I using fixed code.
So, How can I solve this problem?
Posts: 5
Participants: 3