I was thinking of giving my units and tiles and stuff their own little render-targets, with the normal spritesheet or texture stamped on , so their textures can change from damage and acid and stuff…
Would also be good for per-rendered lighting/shading.
Are render-targets something I can just use by the hundreds, like textures, or are they to be used sparingly?
I have all sorts of ideas for blendstates and rendertargets, but I dont know if its good to do tens or hundreds of such calls… Is it costly to switch between render-targets?
I’m probably not the one best suited for an answer here, but at least I’m still up… so here it goes…
I don’t think that that’s a good idea because it turns out, as you’ve said yourself, that switching rendertargets is very expensive. I’ve tried that approach in my engine and I maxed out at about 200 per frame.
But as far as I understand it depends on the size and format as well.
Thanks! Even if only 50 or so render-targets doesn’t sound outrageous, that’s probably more than enough for my needs, with a little planning…
Switching rendertargets and using rts as textures is a completely different thing though.
In theory it shouldn’t matter much whether you use rts or regular textures, after all rts are just a subclass of textures with additional optional properties.
Size might be an issue for “hundreds” of RTs since they are uncompressed. If you use them as textures in 3D remember to enable mip maps for them (only viable if you don’t update them constantly)
I have never seen a game with so many rendertargets, even 50…
The UE4, with all it can do, uses less than 20 RTs (and some are only used to visualize in the editor for ex the number of lights impacting pixels, not used ingame) by reusing them/sharing them between effects.
Moreover, the more RTs you have, the more RAM the app require.
It would be better to think of what you need before using so many RTs. For ex, pack the rendered units onto RGB, using the alpha channel as a material ID to tell the shader which texture to use (damaged by fire, acid, etc)
You can also use MRT (Multi Render Target) to draw at most onto 4 RTs (Nowadays graphics cards limit, I have not checked this) RTs in a single pass. But the more RTs the slower the app (MRT w 2RTs is fater than 4) will run.
My Search Phrase
Not really answering the question but some useful information regarding RTs and MRTs
Found some more with a focused question
that helped me find this gem
This is cool:
Is it possible to use this with MonoGame?
An extremely handy optimisation page:
You should read that for sure…
All that found using this search phrase:
Enjoy and I hope any of it was useful in this discussion aside from the limit, though it does seam memory is a limiting factor and thus 32/64 bit limitations apply too…
Wall of responses! Good points made, loads of links provided.
I think you could do this, because once an enemy has its sprite-sheet on a render-target, it doesn’t need to draw TO that render-target until something interacts…
Like cosmonautgames puts it, actually drawing the rts is no problem. So as long as we only switch between them “rarely” it will be alright…
The cool thing is the extreme variation to the textures, and you wont need all sorts of pre-made texture tags… Spray mud, acid, blood, snow, scorch marks, even bullet holes…
Remember to use an active list of objects to update and not update idle objects…