Home Technical Talk

Is Colour vertex Heavy for IOS and why

polycounter lvl 6
Offline / Send Message
rorozilla polycounter lvl 6
Hey there guys! I'm working on a unity game right now, and starting to do optimisation to make the game run as smoothly as possible. I'm not really the computer wiz so a lot of the technical side of the optimisation i dont always get. i was wondering if any of you would be able to help me understand some concepts:

Is color vertex something that is heavy for a machine ( i this case, IOS platforms) and if so, is there a way of optimizing without loosing the ability to use the RBG?( i could do without alpha, since of what i understood, this was one of the reasons the color vertex was deemed very heavy).

Right now, we are using a mix of texture maps (psds) with alphas and colours vertex ( in the same shader) to give more colours variety to our game. but with the optimization pass, we will be loosing the colours vertex...

So my questions are: Is colours vertex heavy, If so Why and how could i go around using it more efficiently.

Replies

  • passerby
    Offline / Send Message
    passerby polycounter lvl 12
    vertex colour data is very cheap, including the alpha, the expensive bit is how you use the data, since translucency is expensive. but if your just using the vertex colour for a texture blend, or for actual colour it is very cheap.

    just costs a little more memory for the mesh, since it needs to store a additional 3 4 values on each vertex.
  • rorozilla
    Offline / Send Message
    rorozilla polycounter lvl 6
    I always thought the info was aways stored in the vertices no mater what, they where just set to 0.0.0 and 100% opacity alpha as default. Is that wrong?

    so basically, the heavy part of it all, is having big translucent gradients trough out the game, even if the mesh is just a simple rectangle (2 triangles)? because that it really what makes your graphics card sweat: it tries to calculate the interpolation between the two colours you set on your vertices?

    Is it the same thing with Gradients between solid colours?

    So, would if be able to make your shader ignore the colours vertex alpha, without ignoring the texture maps alpha, and if it works, would it make the game any lighter?

    Thank you so much for your help! im kinda clueless when it comes to the technicality of things! im hoping to get better at understanding these things!

    In the same train of thoughts, would you recommend any kind of documentation on the subject of optimization i could get my hands on?

    Thanks again! :D
  • passerby
    Offline / Send Message
    passerby polycounter lvl 12
    ya sorry your correct the vertex alpha and colour data is always there no matter what.

    No ignoring the colour really wouldn't make it any noticeable lighter, colour is cheap, it is the translucency that will cost you the most.

    the expensive part isnt the gradient in the alpha either, the reason why translucency is more expensive than most things is because of z-sorting, and having to make the GPU work harder to figure out what order things render in to display correctly with translucency. the interpolation between colours or alphas is cheap to calculate, it is sorting things out by there z-depth that costs the most gpu time with translucency.

    the cost of alpha will hit no matter what if it's used, doesn't matter if it;s coming from a texture, or from vertex alpha or a other source.

    hopefully one of the shader guys will pop into the topic to help you out, someone like Laurens Corijn(xoliul) has a pretty massive amount of knowledge about shaders and could better guide you.
  • LoTekK
    Offline / Send Message
    LoTekK polycounter lvl 17
    Basically as passerby has pointed out, vertex color, whether that's RGB or A, is simply a value; some data that can be used. It's what you do with that data that determines how performant something will be.

    Vertex alpha, just like texture-based alpha, doesn't directly translate into transparency. If you want, your shader could use your texture's red channel to determine an object's transparency, instead of the alpha channel; same goes with vertex colors/alpha.

    You're correct that alpha transparency is something that can cause performance issues if not dealt with carefully. However, your apparent assumption that using texture-based transparency will be cheaper is incorrect. The vertex shader, especially on scenes/objects with few triangles, is always going to be faster than the pixel shader simply due to not having to run its calculations as often (per vertex, instead of per pixel).
  • rorozilla
    Offline / Send Message
    rorozilla polycounter lvl 6
    Thank you so much guys! this really clears up colors vertex subject for me!

    So just to be sure, if i am to use colors vertex, i really just need to make sure to use the Alpha as little as possible? then i wont be over loading the graphic card to deal with the z-sorting?

    is having two alpha values also one of the things that could be heavy? or dos it not make a difference at all.

    So shader-wise, is there a way of ignoring the alpha channel in the vertex so there is no possible way it could calculate it ( say i put a 95 percent value on some vertex by accident).


    Thank you so much LoTekK and Passerby!! you guys are reall life savers!!
  • cupsster
    Offline / Send Message
    cupsster polycounter lvl 11
    I would actually encourage you to use vertex colors whenewer you can cause this information is always stored in model for free. At least by my limited knowledge :) Vertex colors definietly pay back on mobile devices.
  • passerby
    Offline / Send Message
    passerby polycounter lvl 12
    ya shaders can be setup to ignore alpha or use the data for a other purpose., the data is called vertex colour and vertex alpha, but it dosnt need to be used for those 2 purposes, it's just values applied to the verts, you can write your shader to do anything wit the data that you want.

    EDIT:

    you should prolly get a look at your framerate and fillrate, and whatnot before you go and over optimize, and decide on what is a aspect frame rate on what device, for your and your team.

    got to treat it like a balancing act, dont want a game that runs fast as hell but looks bad, and was serverly limiting to it;s artist, nor do you want it running unplayable slow, but looking pretty.
  • rorozilla
    Offline / Send Message
    rorozilla polycounter lvl 6
    Thank you so much all of you! we finally came to an agreement on the team, unfortunately, they still found that colours vertex was still to heavy for some reason, but they allowed me for more textures, so i think ill be able to make the game pretty but still playable at a decent frame rate!

    Thanks all of you for helping me figuring out all the technical side of it all! you guys really saved my hide! i always sound like a dummy asking questions to my team, without knowing the names of anything or what they do (like fill-rate and all that mambo jumbo!) But now i know! Thanks to you!


    I'm guessing all those terms you learn either by going to school for a long time ( masters in numeric art i suppose?) or working in the industry for a while?
  • Noors
    Offline / Send Message
    Noors greentooth
    Looking at max channel infos, on a 8066 vertices sphere mesh.

    mesh : 419kb
    vsel : 32kb (don't know what this is)
    alpha : 193kb
    illum : 193kb
    vc : 774kb
    map: 294kb


    so alpha+illum+vc = 1.13Mb

    total : 1.86Mb

    More than half of the model weight is dedicated to the vertex color and alpha, so maybe that's what they mean by heavy.
  • Kurt Russell Fan Club
    Offline / Send Message
    Kurt Russell Fan Club polycounter lvl 9
    If you have a lot of tranparency on iOS then you will lose performance regardless of whether it's from alpha or from vertex colours. That's because the iphone/ipad use graphics chips that do sonething a little like deferred shading or raytracing.

    If everything's opaque then it just processes one colour per pixel - too many layers, or too much of your screen with transparency, and it'll bog down.

    Usually removing vertex colours will save some speed - any engine worth its salt won't send the extra info unless your mesh requires it (and Unity is worth its salt)

    But like passerby said, you should profile and know why it's running slowly before you optimise. Otherwise you could waste your time optimising the 80% that is already fast enough, or (even worse) slow it down more
  • rorozilla
    Offline / Send Message
    rorozilla polycounter lvl 6
    Would you have any kind of pointers on what or where to start profiling? i was told this was done by the programers so im kinda just dealing with whatever recommendation they give me, so up till now I've lived and seen my colleges remake up to 4 times the same assets (which i think is normal right, to an extent). So if there is a way of kinda predicting what is more efficient on a artist point of view, then i am all up for it.

    I know the basics for sure. like not to much polygones, not to much textures and not to big, but i never learned the reasons to why they where heavy!

    So if you guys have any idea as to where i could start learning all these things and get better at optimising, you would really be saving my life!

    Thank you so much for all the help you already gave me! you guys are awesome! :D
  • Kurt Russell Fan Club
    Offline / Send Message
    Kurt Russell Fan Club polycounter lvl 9
    Well you shouldn't be doing it, your programmers should be :) They will run the app on the phone and connect it to their profiling tools on their Macs.

    If it's running *slow* then they shouldn't be looking at vertex colours because that's going to reduce *memory*. Caching means there's a link between memory and speed, but that's not a good enough reason to drop vertex colours.

    You shouldn't need to remake assets too many times, unless the specs of the game are changing dramatically. Your programmers can run tests where they take a small number of initial assets and place hundreds of them down to simulate the final game, then test speed by changing the rendering properties - adding/removing shaders, changing percentage of alpha, larger models on screen, more vertices, etc. They can do this at the start of the project (or tell them to do it now if they haven't already). Unless you're making a sequel, where all your budgets and specs have been well established, your programmers should do this for every new game.
Sign In or Register to comment.