Tiling off

Good evening,
I’ve started to create an universal unit shader for my project, but faced a problem: I can’t stop repetition of my decal. Despite I checked almost every node, I didn’t found way to create this decap properly. What nodes should I put to stop tile repetition?


By default textures repeat when sampled outside of the base 0.0 to 1.0 uv range.

The easiest solution is to disable repeating on your texture’s wrap settings. This can be done directly on the texture itself, or by using a sampler state node which you pipe into your Sample Texture node. The first option will work on all platforms, the later may not work on some mobile devices.

The next option is to generate a mask in the shader based on the UVs so that only regions inside the 0.0 to 1.0 are visible. This is a good option if your decal textures don’t have transparent edges.

Tiling Offset > Multiply by 2 > Subtract 1 > Absolute > Multiply by 1000 > Clamp 01 > Multiply with the alpha > Lerp or Blend

The last, and perhaps easiest option, is to clamp the UVs to a 0.0 to 1.0 range. Pipe the output of the Tiling and offset node into a Clamp 01 node before plugging it into the Sample Texture nodes. You may want to select your texture assets and click on the “Border Mip Maps” option which will ensure if you have transparent pixels around the border, all mip maps will also have fully transparent borders.

6 Likes

Thanks, the first one was pretty ok. but I’ve face a new problem: I can put on only one kind of decal.

4412800--401986--problem.jpg
4412800--401989--problem2.jpg
4412800--401992--problem3.png

Just do two overwrite blends. Base color, decal color, decal mask into the first Blend, then pipe the output of that into a second blend with the second decal color and mask as the second inputs.

Strangely it works for APC, but on other units decals are not shown at all.

I’ve also faced problems when I tried to introduce transparency in the shader. Somehow it inverted normals in models.

4417783--402739--zp8JaGz.jpg

Can you show your graph again?

Efficient and accurate sorting of arbitrary transparent geometry is an unsolved problem in real time rendering.

Do not use transparency on large, mostly opaque meshes. If you want to have areas that are fully hidden like holes, use a cutout shader. If you need something that is partially transparent like glass, split that off into another material & shader.

One last thing, is there a reason why you’re using separate decal color and mask textures? It’d be better to use a single texture with an alpha channel for the mask.

Graph is here.

Ok, I’ll try to do it through alpha.

4421701--403270--x25DQpB.jpg

You have one too many Blend nodes there.

I’m using a Lerp node here, and my tiling & offset properties are setup a little differently, but Blend Overwrite & Lerp are identical and the properties setup are just a personal preferences. How you’re doing it is just as valid.

And still for unknown reasons on APC it works perfectly, but when I am trying to make material on soldier or helicopter, at first Decals are visible, but when I choosing “Clamp” they are just dissapear.

Then your offset position likely just isn’t visible.

I tried different offsets and scales but it didn’t came visible yet in any ways.

It’s going to depend on how their UVs are setup. If the model’s UVs aren’t centered between 0.0 and 1.0, then the offsets for the decals will be a little harder to determine.

How should I check it out and fix?

Btw, is it possible to use PBR matrial on terrain object?

Open up your models in a modelling program and look at the UVs? Alternative hack would be to setup a shader that showed a color when outside the 0.0 to 1.0 range, or scale up the decal until it’s visible, then manually offset until things are lined up.

Of course they have UVs, but any parameters of offset or tiling does not appry to the model as long as decal uses “Clamp” property.