Random face color in Cycles NOT based on normal direction I'd like to have random (different) color for each face of object. Objects has different shapes, but there are mostly flat so solution should be not based on normal direction. I tried various ways including vector transform without any luck. Is there any OSL solution for that?

edit: looking for node (material) solution for that.
Would a vertex color layer do?

If you select all the objects you want to treat this way, and run this script:

import bpy
import random


for obj in bpy.context.selected_objects:

    mesh = obj.data
    if not 'Rnd_face' in mesh.vertex_colors:
        mesh.vertex_colors.new(name='Rnd_face')     

    color_layer = mesh.vertex_colors['Rnd_face']

    for poly in mesh.polygons:
        rgba = [random.random() for _ in range(3)] + [1.0]
        for idx in poly.loop_indices:
            color_layer.data[idx].color = rgba


..and assign a material which accesses the vertex color layer through an Attribute node..



here, on a bunch of subdivided planes ...



(you could use the per-face values in all sorts of other ways, in the node tree)