Layering with render to texture

edited March 2015 in Help request
Hi,
so time has come to implement the layering system (composite sprites) :). As I have described in my very first thread I need to draw some parts of the sprites on top on each other. For instance soldier will be divided to torso, head, left arm, right arm, legs. Now I need to draw each part it on top of each other.

The first solution is to do micro adjustment to the Z position of the object.

The second solution that was recommended in the aforementioned thread is to use render to texture (RTT). But I don't know if it really is that simple. How would I do it with RTT? Because from the API it looks like I would need to create the bitmap of the whole screen size (or do I?), draw it there and then use this texture as graphics. Is this right approach?

Thank You

Comments

  • edited March 2015
    Hi!

    Well you have a few different approaches for RTT, with different levels of automation. :)

    I'd personally recommend going with the data-driven approach instead of a more programmatical one, but that's my personal taste.

    In any case, you won't need an intermediate texture as big as the screen, albeit that is an option which is very easy to setup but won't bring the best performances.

    Before anything else, can you give us more details about your actual setup? How many entities will require that treatment at the same time (ie. how many of those will get rendered in the same screen)?
    Is that number fixed or unbounded?
    Will they need to be rendered at the same "depth" in your main scene or will they be at different Z values?

    If they're going to be rendered at the same depth, setting up the RTT is very easy and won't require more than a line or two of code. If they are at different depths in the main scene, I'd recommend using relative offsets (having all your gears as children of your character and having tiny Z values to them). That also mean that you can set those values once and for all in config on your gears and never touch them later on.

    The RTT itself is usually more interesting when one want to do extra processing on the intermediate texture (blur, post-FX, ...).
  • edited March 2015
    Thanks for the reply,

    iarwain wrote:
    How many entities will require that treatment at the same time (ie. how many of those will get rendered in the same screen)?
    Is that number fixed or unbounded?
    Will they need to be rendered at the same "depth" in your main scene or will they be at different Z values?

    After reading it second time I don't know If you're talking about the composite sprite as whole (the soldier composed of the legs, torso, ....) or about the solo parts (legs only, torso only, ...)

    The number of the parts (legs, torso, accessories, ...) rendered at the same time would vary but there is and lower and upper bound. The lower bound is 5, the upper bound shouldn't be more than a 10. The each part should have its own depth. To be it more complicated, the depth value for some parts of the body would be changing based on the current frame of the animation.

    The number of composited entities/objects (the soldier composited sprite) that would be render at same time is unbounded but it should be not more than 30 on the screen.
    If they're going to be rendered at the same depth, setting up the RTT is very easy and won't require more than a line or two of code. If they are at different depths in the main scene, I'd recommend using relative offsets (having all your gears as children of your character and having tiny Z values to them). That also mean that you can set those values once and for all in config on your gears and never touch them later on.

    Hmm, I see. So If I understand it correctly, it is better to use each part as solo object and adjust the Z position (as a workflow number 2 in my original post?), right? Or did I misunderstood it?
    The RTT itself is usually more interesting when one want to do extra processing on the intermediate texture (blur, post-FX, ...).

    Yes, I was aware of the RTT usage for this kind of stuff.
  • edited March 2015
    After reading it second time I don't know If you're talking about the composite sprite as whole (the soldier composed of the legs, torso, ....) or about the solo parts (legs only, torso only, ...)

    Sorry, it wasn't very clear, I meant composite entities as a whole.
    The number of the parts (legs, torso, accessories, ...) rendered at the same time would vary but there is and lower and upper bound. The lower bound is 5, the upper bound shouldn't be more than a 10. The each part should have its own depth. To be it more complicated, the depth value for some parts of the body would be changing based on the current frame of the animation.

    You can use animation custom events to handle the changes of depth.
    The number of composited entities/objects (the soldier composited sprite) that would be render at same time is unbounded but it should be not more than 30 on the screen.

    In that case, if they were all at the same depth, I'd recommend using an intermediate texture the same size as the screen. But I feel like they're all going to be at different scene depths, aren't they? :)
    Hmm, I see. So If I understand it correctly, it is better to use each part as solo object and adjust the Z position (as a workflow number 2 in my original post?), right? Or did I misunderstood it?

    I think so. Most of the offsets will be set once, I believe, and the special cases (changes of depth in given animations) can be handled with animation custom events.

    RTT itself is pretty easy to setup, but I don't think it'll be handy in your situation.
  • edited March 2015
    iarwain wrote:
    In that case, if they were all at the same depth, I'd recommend using an intermediate texture the same size as the screen. But I feel like they're all going to be at different scene depths, aren't they? :)
    Yes, you're right
    I think so. Most of the offsets will be set once, I believe, and the special cases (changes of depth in given animations) can be handled with animation custom events.

    RTT itself is pretty easy to setup, but I don't think it'll be handy in your situation.

    I see. Thanks for informations.
Sign In or Register to comment.