Home Technical Talk

vertex colors vs bitmap texture - cost/performance considerations?

hero character
Offline / Send Message
thomasp hero character
just wondering if there's any general rule when it comes to the performance/memory overhead for using vertex colors over a bitmap in materials.

there's currently a single 2048 texture that i'm using in a hair material. it contains two 8bit/greyscale channels, one for a painted texture overlay that supplies strand detail, the other is the alpha mask. i combine that with vertex colors stored in the mesh (around 9500 vertices) and am able to multiply a color value on top of this in the material itself.

the approach seems pretty handy to me because when modeling hair you always end up reusing geometry and a color texture on the same UV set just makes that very obvious. vertex colors on the other hand help to give the strands a unique look and are more quickly doodled onto the mesh than creating a texture.

like so:

 
in my mind using vertex colors must be a lot cheaper than loading in another bitmap to define the strand color but is there a way (preferably in unreal) to profile this or do we have a general rule of thumb for 2016-era engines/hardware? everything i can find regarding vertex color seems to be pretty old and possibly outdated.

in my case the mesh would obviously have to be animated, whichever way, if that changes things. also, in this example it's broken up into an object that casts shadows and a much smaller one sharing the same material that does not.

needless to say - i've looked at a fair few assets from various games and nobody seems to be using vertex color this way.

Replies

  • thomasp
    Offline / Send Message
    thomasp hero character
    some points that were mentioned to me that would aid in discouraging the use of this method are cases where the vertex color channel is already blocked for masking effects like strand movement or in the event where the mesh needs to be reused on different characters in the same scene but you want to have unique haircolors vs instance rendering for performance.
    still, preferable for unique assets it would seem. time and texture space saved. literally a 5 minute quickie - 9200 vertices, 256 texture for AO, normals, mask -

  • GlowingPotato
    Offline / Send Message
    GlowingPotato polycounter lvl 10
    Vertex color is always faster. Always.
    But, there are some limitations that you already pointed.

    What can be a little more expensive, is how you use the vertex color data, for example, alphas. But still faster than textures.
  • cptSwing
    Offline / Send Message
    cptSwing polycounter lvl 11
    (nothing useful to add - i use vcols for coloring stuff on mobile all the time - but that's some very pretty hair, especially on the last character!)
  • radiancef0rge
    Offline / Send Message
    radiancef0rge ngon master
    In terms of memory vertex color is way cheaper. 2048 is like what 4 mb for a dds? I know that uncompressed but vert color is basically free as its already a component of the mesh.

    But yeah sometimes vert color is used for other stuff in the shader, like offset of the verts or AO etc. 
  • thomasp
    Offline / Send Message
    thomasp hero character
    this all sounds pretty good, thanks for the confirmation guys. faster to apply and change color, less textures needed - i think for my way of working i can reduce it down to a single texture file now: channels R/G used for normal map data where needed, B used for greyscale overlay, A is the mask). that's quite a lot coming from a standard color/normal/spec workflow and yet enables more control.

  • Eric Chadwick
    I'm also using vertex color a ton on mobile. It's a huge savings there. But just for customization/masks it can't be beat, using a texture for masks is a waste since you would often need unique non-overlapping UVs (2nd uv channel adds to the vertex count). Also if you're only using one channel of the bitmap, that's a waste.

    Packing your textures into RGBA can give you some bad compression artifacts though, depending on the platform. Especially if trying to pack a normal map and other data together. DXT5 for example is pretty ugly with normal maps.
  • thomasp
    Offline / Send Message
    thomasp hero character
    good call about compression settings eric. i was pointed to this: http://oliverm-h.blogspot.de/2014/03/ue4-quick-tip-dxt1dxt5-normal-maps.html

    seems i need to come up with a name for my method quickly so it can be credited properly in some soon (...) to be shipped game. ;)
  • Eric Chadwick
    We've got more info here about those compression methods. Check out the PDF for a deeper dive, with nice pics.
    http://wiki.polycount.com/wiki/Normal_Map_Compression

    I call it Channel Packing. Nobody's got a final term though, lots of variants out there.
    http://wiki.polycount.com/wiki/ChannelPacking

    I've heard some artists call it Swizzling, but that's a bit of a different thing... basically re-ordering the color channels, red into alpha, green into blue, etc.
  • pmiller001
    Offline / Send Message
    pmiller001 greentooth
    a lot of cool info here guys, most of which i dont understand, 
    Here are some questions I have
    -How did you get your vertex on to your hair planes? I read that they're stored into the mesh, so does that mean you painted the haircards in zbrush? 
    -You mentioned in your artstation post that it was based on fiber mesh then refined manually, Could you explain that a bit more @thomasp ?


    @Eric Chadwick
    The way I'm understanding everything above is that Thomas used Channel Packing to get his results by putting the detail in a grey scale channel, and the alpha in the only other channel, then pointed to those channels in the shader in marmoset. And that Channel Packing saves memory, at the expense of Draw calls?

    Also is there any way I could get my hand on some of the files used to make this project? I have an easier time understanding whats going on if I can "reverse-engineer" it. If not, is there a nother source I can see or practice on? 
  • pmiller001
    Offline / Send Message
    pmiller001 greentooth
    BTW, what i mean by Point to those channels is, changing it in your shader, in a drop down menu like this. Am I saying this right? 

  • Eric Chadwick
    thomasp talked about his process some in his sketchbook, some more great examples in there too, inspirational work... http://polycount.com/discussion/83970/sketchbook-thomasp/p1

    Greyscale isn't a channel, at least in game art usage. You can store a texture in two channels (grey + alpha) but the graphics card will always convert a runtime texture to RGBA, so you're only saving space on disk not in-game.

    Yes, Toolbag can extract individual channels.

    Channel packing saves memory because you can pack 3 or 4 grey textures into one RGB or RGBA file.

    RGBA uses more memory than RGB, depending on the game texture format (lots of different compression options out there). In the game I'm currently working on, I'm using RGB instead of RGBA to pack my greyscale terrain tiles because it's about 1/2 the texture memory, and multiplied by a bunch of terrains in our game that ends up a big savings.

    Draw calls depend on a lot of things... how the shader is setup (how many different effects there are, are you using alpha blending, etc.), how the game rendering is setup (forward vs. deferred, etc.), how many different materials you have in a scene, etc. I think in general, channel packing doesn't change the number of draw calls. I haven't looked into that tbh. The memory savings can be huge though.

    I show some more examples of channel packing in my sketchbook. If you don't mind looking at shader graphs.
  • pmiller001
    Offline / Send Message
    pmiller001 greentooth
    I don't mind at all. thank you for the share.  and also thank you for the link to the sketchbook, it's already becoming more clear. 
    as far as two channels. I guess I have to convert my image to Grey scale for me to see the grey channel. cause right now I'm only seeing red Green and blue channels and the alpha. am I understanding this correctly?
  • Eric Chadwick
    If you have a grey image, each RGB channel will show the same grey contents, so no need to convert. Just pick which channels you want to store which images, and paste them in as needed.
  • thomasp
    Offline / Send Message
    thomasp hero character
    a lot of cool info here guys, most of which i dont understand, 
    Here are some questions I have
    -How did you get your vertex on to your hair planes? I read that they're stored into the mesh, so does that mean you painted the haircards in zbrush? 
    -You mentioned in your artstation post that it was based on fiber mesh then refined manually, Could you explain that a bit more @thomasp ?


    re: vertex colors - you could use zbrush for that, yes. however, trying to alter colors or layering is a bit of a challenge in there IMO. but you can transfer the mesh with polypaint intact into other applications (e.g. i recall a script for max for doing that).

    personally i used a custom blender compile with a few extra features/fixes for vertex color painting that someone over at the blenderartists was kind enough to provide (default blender did not paint 'through' the mesh). i had to alter the colors a couple times because they looked completely different in marmoset so with zbrush handling it and then transferring to a rigged model prior to re-export this would have been nasty if done with pixologic's "advanced polypainting". ;)


    re: fiber mesh - i've experimented with that with the aim to just transfer over geometry or curves and almost have it 1-click, without the endless tweaking.  not successful though. what i settled on instead was to export fibermesh as curves, bring that into the 3d app and use it as source for creating some of the geometry and for the main strands as guides to conform prepared alpha cards along them. then tweak vertices manually excessively.
    it saves time early on over doing everything manually to get volume and silhouette right and you can use some of it to generate geometry from splines but the bulk of the work is still all manual if you want this to look tight and not like a generated thing. still use mainly this technique.

    perhaps in a few years when we are able to throw six-figure polycounts just at hairstrips (without a programmer chasing us around the office with a baseball bat) can the whole thing finally be handled by styling in fibermesh or a hairsystem and then more or less just converting that.
  • pmiller001
    Offline / Send Message
    pmiller001 greentooth
    I tried using your fiber mesh method, by transferring over the curves, and its gotten me the best results I've ever gotten. They're still not good but I really gotta thank you for showing me a different way. 
    As for the vertex colors, it took me a second, but I learned how to do it in Modo, the program I use. 
    This is the result I got. 

    Theres some weird stuff going on about the top of the hairs, I'm not sure why its appearing. :/ 
Sign In or Register to comment.