How to add randomness into shader?

I’m building shader for floating islands and they actually float with power of sine and WP offset, however, they float simultaneously, which looks weird.
How can I get random(or not so random, but per object) per object data?
World position gives me different data for each vertex, which just scales my mesh :frowning:

Sure, you can use object position which would return the center of the actors sphere bounds or actor location which would return the location of the actor in the world by pivot.

You can get pseudo randomness by doing things like taking the x component, dividing by some crazy randomly picked scalar value, and then taking frac of that. That will get you randomish results that go between 0-1. Then you constantbiasscale that to be -1-1 and multiply to your max desired randomness value. You can also add in a bit of the y or z axis too with a different divisor before the frac to ensure some randomness occurs on both axes in the world.

1 Like

Works like a charm, thank you very much! :slight_smile:

Very cool :slight_smile:

One additional thing I did in the zen demo case: some of the islands had 2 or 3 smaller sub islands that were close by connected by some vines and part of the same mesh. I used the vertex red channel and painted each island on the same mesh to be a slightly different solid color value. Ie, Main island I left at 1.0, the smallest connected island 0.28, the other 0.7333, then in the vertex shader you add a bit of that vertex red color into the object position data and you can introduce sub movement within the same mesh. Just make sure there are no unpainted verts on any parts as it could make the mesh go crazy.

Oh, you made these beautiful islands? I’ve decide to make a scene with floating islands after I’ve seen yours in Zen demo! :smiley:
Thanks, it’s a good idea actually, more visible variance is always better!

not just me, a few people worked on those. Rick Kohler made the actual rock meshes from another project. Paul Mader started by making one quick island with a bunch of speedtrees painted onto it using the foliage tool. I took that, made a rock/moss shader and a bunch of variants and imported them as cards etc and then started placing them. He later did some more variants again with specific lighting directions etc.