I’m trying to set up an opaque broken window material to apply on destroyed building windows.
I don’t want every window to be broken in exactly the same way, so I’m trying to randomly rotate and pan my broken window texture by a fixed random number, before applying it on the rest of my material.
To achieve this I’m using the PerInstanceRandom node, the only random node usable in materials. Weird thing is, it doesn’t seem to work.
If I use a constant instead, the texture pans and rotates as intended, but as soon as I plug in the random node, the texture resets to its default position.
Does anyone have a clue about what the problem is here? I tried to change the default speed of the rotator and panner nodes, to multiply my random number by diverse constants… Whatever I do, it doesn’t seem to work.
I see this is an old post but I just came across it looking for more info on PerInstanceRandom.
Your problem might be that your not using instanced meshes. That node seems to only work if you apply it to an instanced mesh, otherwise it stays it’s default value. But it worked for me by applying it to an InstancedStaticMesh component in a blueprint.
Yeah I figured as much later. Worse than that, I wanted a random number for each repetition of the texture, not each mesh instance. I found there’s no way to do that, which seems pretty logical now that I’ve had time to think about it.
To solve this problem then, unless I missed a functionality I don’t know, you’d have to forget about having random rotation and to manually rotate the window UVs directly in your 3D modeling software, to make them appear random.
I was looking for a fast way to do it since it was for a jam submission and the mesh was quickly built from BSPs, so there was no solution for me.
Old post but I’ll add this anyway. Another way you could probably do this that doesn’t rely on instances is to use the world position to offset the UVs, used here just to make a bunch of objects not flash in sync.