Texture bombing?

Hi, are there any features built-in to Babylon to reduce texture tiling at a large scale? I have heard of (but not used) this technique, but it seems to require some shader work:

My other idea is to fade the diffuse or bump texture in or out based on worldspace position (I am texturing a large sports field) OR to use a second set of uv coordinates to somehow blend in a second, lower freuqency texture for breakup. Although I’m not sure where I would start with the blending, that seems like a large amount of work.

Not that specific technique (that I know of), but you could take a look at:

Even just combining diffuse, bump, metallic/roughness at different scales and offsets, using a single set of UV coordinates, is often enough to break up the repetition.

Thank you!

So I think I actually do want to try bombing – it doesn’t seem as complicated as I thought, just doing a bit of math on the uv coordinates in the fragment shader.

I wonder though, since I haven’t done this before if it makes more sense to modify

vAlbedoUV
vBumpUV
vReflectanceUV

Right before they are used (not sure where that is, didn’t see an equivalent to CUSTOM_SHADER_FRAGMENT_UV or anything like that).

Or if there is another shader injection point that is more appropriate for this task (simply modifying the values of the incoming UVs, not adding any other features).

1 Like

Hmm, I’m a little stuck figuring out where to do my UV hijacking. I am using a PBR material so it seems like these examples I see using Fragment_Custom_Albedo are the way to go for the albedo UV manipulation. But of course I need to use the same exact manipulation for the bump UV as well as the roughness UV.

Is there an equivalent to this, like Fragment_Custom_Bump or Fragment_Custom_Roughness?

EDIT: I see the roughness hook, but still not seeing where to modify bump texture lookup

This would not be that simple but I think it could be a great feature to add. It would nevertheless require pretty much updating all the texture samples in the PBR/Standard materials.

1 Like

Just modifying the uv is not enough, you have to make multiple sampling of the texture. Also, these variables are “varying” variables, so can’t be modified.

What you can do is use a material plugin and apply some regexp to replace the bump/albedo/… sampling with the new sampling method:

3 Likes

Awesome! Thanks so much! Is there a list of the sampler names (I need to add metallic as well) or do I need to take a peek in git?

I was also thinking of regex, but more like requesting and modifying the entire shader string, I didn’t realize you could do targeted regex like that.

No, there’s no list, you will have to check directly in the source code. You can also use Spector to take a snapshot of your scene rendering and see what the shaders are.

1 Like