I want the behavior of PerInstanceRandom, except I want it for each StaticMesh instance of a particular material I’ve built.
I do not want to turn the mesh into a blueprint and have a construction script that creates a dynamic instance for each and configures the random number if I can avoid it.
Given that each render of a given shader needs per-instance updates anyway (for things like world position, light positions, etc) then this should be possible without slowing down the renderer or requiring significantly more resources.
What I want to use it for is making procedural materials not all animate in sync.
Hi jwatte -
I may need some clarification for what you are trying to do, but taking your mesh placing it into a blueprint and adding a dynamic material instance through a construction script will not incur more processes at render time than anything else you are talking about. Or am I miss understanding what you are looking for?
I want some variation between each instance of a mesh (or, really, material on mesh.) I could create a blueprint, and make the construction script clone the material to a MID, and set some “variation” parameter to a random value on the material instance. But that’s a lot of work – given that we already have, say, “Time” as an input, why can’t we have “instance random” as an input for regular materials? (We already have it for instanced static meshes; this could just be extended to be supported for all kinds of materials.)
Hi jwatte -
I think I have a better handle on what you are trying to do, here is one option by using an overlayed texture which is setup via Object Position (WS) so it will change based on where the static mesh is placed in the world. One caveat on the material, I have masked out RG from Object Position so the mesh only response to left to right movement and not up and down. You can change this based on what you mask out of the Object position.
Hope this helps you out, or at least gets you started -
Thanks! That’s one way of doing it if I don’t mind the value of the random to shift across the surface. In my case, think of placing rocks all over the level, and having each rock randomly taking a particular color (which could change between runs) that would be different from its neighbor.
Currently, I’m solving this with a blueprint; I’m just proposing something which I think would be easy to implement and would slightly improve the workflow.
This would be a cool feature and can be done with reasonable performance, since there are already per-component properties being passed to the shaders. We’ll add it to the list. In the meantime, seeding with WorldPosition as Eric showed is your best bet.
Is there any news on a random node in the material editor?