Home Technical Talk

Most efficient way to add a stripe to a building?

burroh
polycounter lvl 6
Offline / Send Message
burroh polycounter lvl 6
Looking for some advice on the most efficient way to add a stripe to a building. 
Constraints I'm working with: Unity URP, mobile platform. Low texture budget, have to keep instructions in a material low. 

These are the potential options I've come up with so far, and I'm interested in some thoughts/ feedback.

-Have two different tiling materials, one with stripe and one without. Assign to asset in engine. (I'm not super familiar with mobile perf restrictions on number of materials per asset so I'm not sure how efficient this is?)
-Use a decal to project the stripe 
-Make a trim sheet with red stripe as a trim (so this whole building would only be 1 material draw call)




Example (from TF2):

Replies

  • Klunk
    Offline / Send Message
    Klunk ngon master
    what does the geometry "look" like and can it be changed ?
  • poopipe
    Offline / Send Message
    poopipe grand marshal polycounter
    with the caveat that a decal is almost always the most expensive option... 

    What you should do is entirely dependent on context 

    Assuming you add a second material to the mesh, 
    if you have 4 of these things on screen you introduce 4 extra draw calls  - which is not very many
    if you have 100 of these things on screen you introduce 100  - which might be enough to cause a problem

    The number of draw calls a mesh provokes is not useful information in isolation. 

    If we go by the example image then neither material based option is a problem and you should concern yourself far more with how you can re-use textures or make your life as a modeller easier
  • okidoki
    Offline / Send Message
    okidoki greentooth
    Like so ??
     

    Maybe via a shader trick. Using a texture with an marked area (not only one color but color "corection" red / 2.. so there are still some details):



    and comparing the color  to get a "mask" while changing the hie/saturation for this part only (via mix color) like so (here with animated hue/sat)  teh coloring "disapears" when saturation becomes 0.0 :



    (very quick implementation of the idea.. could be improved..)
  • burroh
    Offline / Send Message
    burroh polycounter lvl 6
    Klunk said:
    what does the geometry "look" like and can it be changed ?
    I haven't made the geo yet, I'm still in the planning stage! If you have any suggestions for good geo I'd love to hear them. 

    This is for an FPS map, roughly similar size to a typical COD map. I'm planning on making a modular building kit for it (it'll mostly be similar styled warehouse-like buildings, nothing too complicated). 

    The main thing I'm trying to wrap my head around is the material restrictions (can't use too many different materials, even something like vertex painting might be too expensive to use too often since they want to target older phones for min spec). Well planned out geo is a must as well.
  • Klunk
    Offline / Send Message
    Klunk ngon master
    that's "easy" then just be thought full of where you place your horizontal subdivisions and have the optional stripe in a trim sheet.
  • Noors
    Offline / Send Message
    Noors greentooth
    Performance wise, having 2 materials on one object is equivalent to have 2 "splitted" objects with 1 material.
    Usually i only use this for easier maintenance, as editing several objects in a 3d software could be a bit more of work if they're meant to be "welded"
    Unity can batch together objects with the same material (static batching) or even with the same shader (srp batching).
    On mobile, I would be more concerned about extra texture in ram and extra texture sampling.

    For this particular case, on mobile, i would add 2 cuts to the building geometry and vertex color as mask, so you can drive the stripe color in your material.
    or a mask texture if you want something less sharpy (in the alpha of your albedo for instance)
    Vertex color is very cheap, basically free. Hence it was heavily used on PS1/N64 and beyond.
    Certainly not a projected (screen space) decal. You shouldn't use the depth pass with forward rendering on mobile as it is an extra render pass and costs a lot. Better use mesh decals.
  • poopipe
    Offline / Send Message
    poopipe grand marshal polycounter
    Vertex color isn't cheap - its 32 bits per vertex and can't be shared as readily as texture information. 
    It really only makes sense if you are applying unique information to sparse geometry or have a fixed limit on texture samplers and have run out. 

    For reference, the vertex color data on a 500 triangle mesh is roughly equivalent to adding a 64x64 3 channel dxt1 texture.
    EDIT: : Correction that's a 2000 triangle mesh not 500

    This isn't much on it's own but start multiplying that by the number of unique assets in a level and it doesn't take long before you could have paid for quite a big texture and used it in your shaders

    Not to say that vertex color isn't the right choice here - i just wanted to frame the cost

  • pior
    Offline / Send Message
    pior grand marshal polycounter
    "For reference, the vertex color data on a 500 triangle mesh is roughly equivalent to adding a 64x64 3 channel dxt1 texture"

    Could you explain the calculation for this estimate ?
  • poopipe
    Offline / Send Message
    poopipe grand marshal polycounter
    ah well, now you mention it - i did my sums wrong. well spotted

    dxt1 is 4 bits per pixel
    vert color 32 bits per vertex

    64 * 64  = 4096 pixels
    *4bits = 16384
    32/4 = 8 pixels per vertex
    16384 / 8 = 2048


  • Noors
    Offline / Send Message
    Noors greentooth
    You have to add the cost of texture sampling.
    It's really for the sake of science as imo the difference should be small.
    https://forum.unity.com/threads/performance-implications-between-vertex-colors-vs-textures.671698/
  • Klunk
    Offline / Send Message
    Klunk ngon master
    if your objects already come with per  vertex shading then the hit comes at the seams/hard edge as that requires another set of verts at the seam in the engine (which would also occur with a mapping seam btw) so the overall hit is usually quite small but it's worthy of consideration.
Sign In or Register to comment.