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
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
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..)
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.
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.
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
Could you explain the calculation for this estimate ?
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
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/