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\$
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

| improve this answer | |
\$\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

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ I suggest you elaborate your answer. \$\endgroup\$ – S. Tarık Çetin Aug 18 '17 at 0:15
  • \$\begingroup\$ That doesn't really answer my question \$\endgroup\$ – Bálint Aug 18 '17 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.