xna - Where to call SetRenderTarget? -
i'd change rendertargets between spritebatch.begin , spritebatch.end. know works:
graphicsdevice.setrendertarget(target1); spritebatch.begin() spritebatch.draw(...) spritebatch.end() graphicsdevice.setrendertarget(target2); spritebatch.begin() spritebatch.draw(...) spritebatch.end() but i'd make work:
spritebatch.begin() graphicsdevice.setrendertarget(target1); spritebatch.draw(...) graphicsdevice.setrendertarget(target2); spritebatch.draw(...) spritebatch.end() i've ever seen doing this, didn't find reason why.
edit: little more why want this:
in project, use spritesortmode.immediate (to able change blendstate when want), , iterate through sorted list of sprites, , draw them all. want apply mutli passes shader on sprites, not all! i'm quite new shaders, understood, have draw sprite on intermediate 1 using first pass, , draw intermediate sprite on final render target using second pass. (i'm using gaussian blur pixel shader). that's why i'd draw on target want, using desired shader, without having make new begin/end.
the question is: why want change render target there?
you won't have performance improvements, since batch have split anyways when render target (or other render state) changes.
spritebatch tries group sprites common attributes, example texture when spritesortmode.texture used. means sprites sharing texture drawn in same draw call (batch). having less batches can improve performance. you can't change gpu state during draw call. when change render target bound use 2 draw calls anyways.
ergo, if second example work, number of batches same.
Comments
Post a Comment