★ TouchArcade needs your help. Click here to support us on Patreon.

unity questions - vertex colors/"overlays," textures vs polys

10-21-2012, 04:08 AM
#1
Joined: Jun 2009
Location: Hollywood, CA
Posts: 1,869
unity questions - vertex colors/"overlays," textures vs polys

posted this on the unity forum but not sure what to expect for a response (long story) so I thought I'd post over here since there seem to be more than a couple of friendly and knowledgeable people about

I am googling for help for awhile now but already realizing that there's no easy super-noob friendly answers for the solutions I seek (although these issues aren't particularly complex)

I am seeking a solution in unity where I can assign a simple solid color to be semi-transparently laid over a texture. Say I have a generic "cement" texture, and I want to apply it all over the place on different objects to save tex memory, but run a color filter over it to make it appear varied. In some cases just use it for cement - then slap a blue filter over it for a park bench seat - a red texture for some trim on a bldg, etc.

It looks like there may be a few ways to do this, not sure which is best. I am hoping to avoid an instance where i have to get code-y with it (though looks like such things are probably normal in unity)

Ideally I want to find a solution where I can effectively "additive Color" over it and still be able to do vertex lighting on top of that, if I am going to bake lights that way.

Also, curious what people's thoughts are regarding best lighting solution for an mobile app with speedy-framerate requirements. Baked lightmaps look very nice of course, but that's adding a bunch of tex memory which could probably be better spent elsewhere (or sacrifice altogether for framerate actually). again I am thinking baking vertex lights, and cutting shadows into geometry/making floaters like in the PS2 days. And in all of these cases, I realize that unity will still have to do another pass on the geo for as many x filters as are applied, as opposed to unique textures, so I am curious if that's a (general) significant performance hit one way (drawing geo) vs the other way (loading more textures into memory, but drawing less geo)

thanks for your help!
10-21-2012, 05:24 AM
#2
Joined: Mar 2011
Posts: 122
Seems like the best way to go is to use a "Diffuse Detail" shader. The main texture slot is filled with a moderately low resolution color texture, to define the object's shape/color, while the second slot gets a tiled texture to look decent on the close-ups. The main color texture is multiplied by the detail texture.
I think it would require some modification if you want to bake the lighting to vertices.
I don't know your specific case, but I myself have a really bad experience with vertex baking and geometry shadows (low flexibility + high time consumption in creating/modifying assets). The lightmaps in Unity are working pretty good, so maybe that's worth some in-depth checking out. Another thing - when are you due to release the game? Maybe the low-memory devices will be obsolete by then?
Now, as for the drawing of the geometry - I've run a 100k polygon scene on iPad 1 with steady 30 fps (not all scene visible at once). Newer devices can do much better, so the vertex count isn't really a problem. At least as long as the geometry is drawn once - meaning no transparencies, no blending, per-pixel specular/normal maps in the shaders, etc. You can, of course, use these things but keep in mind that's the bottleneck od the mobile devices. Two textures blended in a diffuse shader are no biggie, though.