Randomize properties of material per MeshInstance3D

Godot Version

Godot_v4.4.1-stable_win64

Question

How can I get a unique value to each MeshInstance3D inside a shader?

I have a project where I am randomly generating many mesh instance 3D nodes each with it’s custom material so it can have a different color.

I am trying to optimize this by instead of having a new material for each segment only having one with a custom shader that interpolates between two colors, but to keep the variety of each segments color I need something consistent to each mesh instance 3D to seed a random number range.

I have tried using the instance_id input inside the visual shader but that appears to be inconsistent and flicker when you increase the number of meshes with the material or move the camera.

1 Like

Thank you!!!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.