Distorted Seams with parallax oclussion shaders

Hello,

I’m trying to find a solution to create depth in heightmaps. I’ve tried the URP parallax occlusion as well as custom one from the asset store, and it had the same issue. The issue is that the border of the mesh with the texture applied will create a blurry, distorted and streched seam, as seen in the picture below. What is causing this and what solutions are available? Thanks!

Which mesh did you apply the texture, shader and material to? Try the unity plane or cube first. It might be due to incorrect normals. Is your height map correct? Look for seams or borders, maybe upload it, if possible. Can you link the used shaders?

I really need more info to help.

Could be a problem with the normals, but I doubt it. Could be a problem with the mesh UVs, but that’s unlikely too.

I suspect the issue is the texture you’re using is set to Wrap Mode → Clamp. Parallax effects for shaders always push into the surface, as it’s impossible to use a fragment shader to expand the coverage of a surface. However they generally also expect a repeating texture whereas I’m guessing you want the image to end if it goes beyond the bounds of the base texture UVs.

There’s two ways you can go about doing that. You can setup your texture to have a 1 pixel transparent edge and check Border Mip Maps in the import settings to make sure that transparent edge shows up in all mip levels, and then set your material to be alpha tested. Or you can use a custom shader that sets the alpha to 0.0 outside of the UV range to do the same thing. The advantage of the texture based approach is you don’t have to do anything special to the shader, but it does mean your texture has to have an alpha channel, and may visible “shrink” away from the edge in some cases due to mip mapping.

Thanks for your replies!

I gave the border mip maps a try but they ended up giving me a black seam distortion. I ended up giving Amplify’s parallax occlusion shader a try. They had an option to remove the edges, but it instead creates an issue where you can look through the seams now. I attached a link to a screen capture to show the issues better.

Are there any good alternatives to parallax shaders?

Well, yeah. That’s what I was saying about fragment shaders can’t expand the coverage of the surface. You can only see the texture in the screen pixels the original mesh covered. Think of each mesh as a “window” that you can see that mesh’s texture in, but no others.

You could plausibly use a cube instead of a quadwith single orthographic UV, but that won’t really work since the mesh tangents the effect relies on will be wrong for this purpose. Or you can expand the quads to cover way more area and scale the UVs down, but that’ll only delay the problems unless every quad covers the full area. And honestly you’ll probably still see seams. The only real solution for the setup you have is for all of the quads need to know of and raymarch (what parallax occlusion is doing) against all of the textures, and that’ll get real expensive fast. Realistically you have to limit yourself to a single texture for this to work instead of cutting it up into multiple tiles.

The better alternative is to use vertex displacement on a highly tessellated mesh, preferably one that’s using dynamic tessellation using a tessellation shader. You’ll still get some seams … there’s no way to avoid that really without much more advanced setups, and it’s a lot slower if you want the same level of fine details, but it will work.

This makes sense. Yea, we tried the tessellation but it didn’t work out so well either.
We’ll have to try something else, it’s a shame that the parallax just doesn’t quite work here.

Thanks so much for you answers, they were very helpful and informative!