How to make a growing unique index (IntProperty) of the objects?
A collection of pointers
Can set up a collection on the scene with pointers to objects.
On an object set up a property to populate the collection and return the objects index in that collection.
Feel it's a little hacky to use context to get the scene within the getter method.
Example of setting up the props.
import bpy
from bpy.props import PointerProperty, CollectionProperty, IntProperty
from bpy.types import PropertyGroup, Object

class SceneObject(PropertyGroup):
    object : PointerProperty(type=Object)

def get_scene_object_index(self):
    from bpy import context
    scene = context.scene
    obs = [o.object for o in scene.scene_objects]
    for ob in set(scene.objects) - set(obs):
        o = scene.scene_objects.add()
        o.name = ob.name
        o.object = ob
        obs.append(ob)
        ob[&quot;scene_object_index&quot;] = len(obs)
    
    return self[&quot;scene_object_index&quot;]   


bpy.utils.register_class(SceneObject)

bpy.types.Scene.scene_objects = CollectionProperty(type=SceneObject)
Object.scene_object_index = IntProperty(get=get_scene_object_index)

def draw(self, context):
    layout = self.layout
    scene = context.scene
    ob = context.object
    self.layout.prop(ob, &quot;scene_object_index&quot;)
    for o in context.scene.scene_objects:
        layout.label(text=f&quot;{o.object.name}&quot;)    

bpy.types.OBJECT_PT_context_object.prepend(draw)

Added a little draw method to object props panel
Drive the pass_index
A driver using this prop can be added to the pass index of an object.  Adding a value input driver to a material node will require targeting a different object per material.
EDIT
Have edited to give each object a custom property. Needs a rethink re property name to have a unique value per scene.  It appears the driver &quot;auto updates&quot; better from the custom property rather than the read (getter) only property.
Will revisit and clean up if I have time, thinking a prop on scene with an update method.

Note at issue here is the collection property of the scene is giving the object a user. Deleting objects using operator will only unlink them from the scene, not remove them from the data.   Requires an edit to remove objects if they are only used by the collection.
If an object that is assigned to a pointer is removed from data the pointer will return None