Home Unity

FX overdraw in Unity for iOS

polycounter lvl 9
Offline / Send Message
shxsy polycounter lvl 9
So I've ran into the problem of overdraw in Unity while working on a game for iOS. My solution has been to bake out sprite sheets of FX from either After FX or Maya. This however is really time consuming. Are there any other work arounds aside from keeping particle count low and the aforementioned solution? I have access to pretty good compression tools, but I imagine at some point, memory will become a factor.

Replies

  • Elyaradine
    Offline / Send Message
    Elyaradine polycounter lvl 11
    What kind of effect is it?
  • shxsy
    Offline / Send Message
    shxsy polycounter lvl 9
    Generally, explosions, fire, blasts, ground impacts. Very few magical effects.
  • Elyaradine
    Offline / Send Message
    Elyaradine polycounter lvl 11
    I asked because with our fx we control overdraw in different ways depending on the effect. Many of our fx (especially firey ones) have shaders that use noise textures and ramp lookups to give a sort of a procedural look, while keeping it down to 1-5 particles. Also keeps our memory usage down, and allows you to re-use different ramps and noise textures, combine them in different ways, for variations of an effect.

    For many effects that seem as if they'd naturally have a lot of layers (like explosions), I try to create the main shape of the effect using just one layer of mesh. An explosion, for example, might just be a rounded cube or sphere that scales up over time. If it's got a nice-looking shader on it, it gives you the main body of the effect, and you can decorate it with smaller bits (rubble, sparks, etc.), and fake the look of something quite complex while not resorting to having many layers of large particles.

    Otherwise, I try to have my textures as opaque as possible without it looking crap, so that I can get away with fewer layers of particles.

    Lastly, I tend to throw a few more verts at my meshes, cutting them so that bits that would be fully transparent are cut out. If you rolled your own particle system, it'd be helpful to have the system have the option to use octogons as particles instead of quads, as many fx input textures are circular rather than square.
  • cccprobot
    Elyaradine wrote: »
    If you rolled your own particle system, it'd be helpful to have the system have the option to use octogons as particles instead of quads, as many fx input textures are circular rather than square.

    Well, you can do that in Unity by using a mesh renderer and adding your own mesh yes? That said I've always wondered about any performance differences between the default billboard renderer and any user-input mesh renderer (other than vert count of course)
  • Elyaradine
    Offline / Send Message
    Elyaradine polycounter lvl 11
    I haven't played with it extensively, but from what I remember the last time I tried to do that, if you used any custom meshes as your particles, the ParticleSystem would stop billboarding regardless of what your settings were.

    I'd be keen to hear if there are ways to get around that. I imagine you could script the particles array in your ParticleSystem and force them to face the camera, though that sounds super inelegant and inefficient. Otherwise, maybe you'd have to roll a custom shader to do the billboarding transforms, but I failed to get to what I wanted the last time I tried it. :P
  • shxsy
    Offline / Send Message
    shxsy polycounter lvl 9
    Elyaradine wrote: »
    An explosion, for example, might just be a rounded cube or sphere that scales up over time. If it's got a nice-looking shader on it, it gives you the main body of the effect, and you can decorate it with smaller bits (rubble, sparks, etc.), and fake the look of something quite complex while not resorting to having many layers of large particles.

    So this is just essentially a prefab? I'm actually really interested in doing something like this. A similar solution was suggested to me though, I don't really have a background in scripting/coding. Are there any tutorials that speak directly to this kinda of solution? Thanks for the replies. Awesome feedback!
  • Warhawk,
    Offline / Send Message
    Warhawk, polycounter lvl 11
    As far as overdrawing goes for particles in Unity. Just have in mind to not have huge particles covering each other at the same time. Try to use short life cycles. For instance, if you have many explosions at the same time on screen. Don't use too much layers. Sometimes the simplest solution is the best one. For general explosions it is cheaper to bake fire burst animation onto texture and play texture animation with quick frame rate so you don't need more than 16 frames of animation. Simple 2 or 3 particles should be enough for the effect. Than just make quick scale for blast particle and a few for quick burst into each direction . The smaller, the quicker they are the less overdraw there will be. Avoid using fullscreen effects it will eat your frame rate.
  • Elyaradine
    Offline / Send Message
    Elyaradine polycounter lvl 11
    shxsy wrote: »
    So this is just essentially a prefab? I'm actually really interested in doing something like this. A similar solution was suggested to me though, I don't really have a background in scripting/coding. Are there any tutorials that speak directly to this kinda of solution? Thanks for the replies. Awesome feedback!
    Yeah, pretty much. The effect ends up as a combination of animated meshes (with the appropriate shaders) and particles.

    I'm afraid I learnt all of my shader-wrangling on the job under the watchful eye of a senior graphics programmer, but the general idea for the explosions I've done in the past is to use a shader that has a fresnel falloff (to soften the edge of the mesh, so it doesn't look like an obvious mesh) and a scrolling texture to make it look as if the explosion's rippling outward.

    It looks kinda crap on its own, but I feel it provides a nice base for the shape, and is super cheap to render, so as I said you can add a lot of smaller bits to it to give it nuance and personality, while keeping it quite cheap. (I end up with a few more draw calls because of the different pieces, but very few layers of overdraw, so depending on what else is happening in the game, I might still opt for a flipbook. Depends on where our bottleneck is.)
Sign In or Register to comment.