XNA Creators Club Online
Page 1 of 1 (3 items)
Sort Posts: Previous Next

Swapping effect at runtime (one model, multiple effects)

Last post 2/1/2009 9:20 AM by Christian Herzog. 2 replies.
  • 1/31/2009 5:29 PM

    Swapping effect at runtime (one model, multiple effects)

    Does anybody have experience, how expensive it is if you swap the effects applied to a model during each draw call(especially when keeping the XBOX in mind)?

    I'm currently thinking if I should implement this feature, as we are developing a component based system at our University, and "users" could apply any shader to any model instance.
    To clarify it: lets say I got model A and need it multiple times in my level, yet with completely different effects, not just varying parameters.

    Is this rather a no no/performance killer?



  • 1/31/2009 9:24 PM In reply to

    Re: Swapping effect at runtime (one model, multiple effects)

    Swapping effects has a cost, but you can switch them out several times without much noticeable effect on a PC (xbox, I do not know).

    There are ways around it though.  You can keep the effect, but change the techniques.  Or, you can create multiple passes within a technique, and rather than changing effects or techniques you just use a different pass on each model.   You can also define an array of vertex and pixel shaders within one technique pass and select them with parameters passed at runtime (see the basiceffect shader in the education).

    However, if you search the forum for this (don't know what terms to use.. effect & performance & change and use the advanced options & find those words in posts written by Shawn Hargreaves...) you will find reports that swapping out entire effects sometimes is more efficient than other methods.   I believe some driver voodoo makes it hard to predict exactly.

    Best,
    Byron
    ..shaders make you feel... powerful, or very very stupid.
    http://drjbn.spaces.live.com/
  • 2/1/2009 9:20 AM In reply to

    Re: Swapping effect at runtime (one model, multiple effects)

    Thanks, I'll give it a try!

Page 1 of 1 (3 items) Previous Next