Drawcalls - reducing them with a simple texture

I,m always looking for a way to reduce draw calls particularly for simple objects that maybe scattered around a scene. Here is one little trick I sometimes use :

2 cubes - one with six draw calls, one with only 1 draw call

The cube on the left (Cube in the inspector) has six draw calls - one for each material on each of six faces. The cube on the right (Cube.001 in the inspector) has only one draw call and uses a very very simple texture from this palette collection turned into a 16x16 pixel texture with GIMP. (See image below)

The trick comes with the UV mapping. Select each face in Blender in UV editing mode, select all the pixels in the UV window for that face, then S-> =0. You will get a dot of four vertices - now move them to the colour of choice.Repeat for each face. Now you have six colours on the cube right cube, but only one draw call. No multi-materials!

Stay Safe All, gryff :slight_smile:

The texture I used used 16x16 pixels - if you can see it - about 1kb download

3 Likes

Love it!

Not to one-up you, but did you know the Blender exporter can do that for you automatically? Here is a cube with a material on each side:

bakedCubePNG

If you check the force baking property on the mesh exporter properties:
mesh properties

You get a texture:

Well, actually I guess 2 sides were colored green, but I am not going back. I do not really promote this, because if one or more of the materials was already a texture, and it had alpha (think eye browse), then things get messed up. You can certainly do things more complicated than a square, though.

PBR is also not as do-able, since you cannot bake roughness / metal in Cycles (EVEE does not bake).

Quality can also be degraded compared with unbaked. You can also click ‘Need Alpha’. This will produce a PNG which is not lossy. Unchecked you get a JPG.

3 Likes

Naw, you are not “upping me” - always welcome your thoughts!

The conversion of those palettes from a long linear texture to a square in GIMP can be a pain - so creating a square palette in Blender is useful to know.

Stay Safe Jeff, gryff :slight_smile: