0
\$\begingroup\$

Currently I'm doing the following:

spriteBatch.Begin(effect: effect);

// Draw stuff normally

effect.Parameters["flag"].SetValue(true);
effect.CurrentTechnique.Passes[0].Apply();

// Draw stuff with flag

effect.Parameters["flag"].SetValue(false);
effect.CurrentTechnique.Passes[0].Apply();

// Draw stuff normally

But this doesn't work. The flag stays false even after I apply the changes.

\$\endgroup\$

2 Answers 2

0
\$\begingroup\$

i believe it's because of how SpriteBatch works. the effect is being run when all the sprites are submitted to the gpu. You have to either call spriteBatch.End() or set SpriteSortMode to Immediate or Texture

\$\endgroup\$
0
\$\begingroup\$

You shouldn't need to pass the effect to spritebatch begin. You are handling it all yourself.

EDIT: Because you call effect.CurrentTechnique.Passes[0].Apply(); You don't need to pass the effect to the Begin function

\$\endgroup\$
2
  • 1
    \$\begingroup\$ I suggest you elaborate your answer. \$\endgroup\$ Aug 18, 2017 at 0:15
  • \$\begingroup\$ That doesn't really answer my question \$\endgroup\$
    – Bálint
    Aug 18, 2017 at 7:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .