As a general rule, parallax will not make your graphics look good. And having no parallax is better than having a bad parallax. But sometimes a texture would be just a bit too close to the player's eye and we just want to hide those pixels a bit.

Let's start with the texture that does not have a parallax:

And give it our standard parallax offset:

It is all ok near the camera but gets ugly further away, at a lower angle. So let us fix that. If the angle is lower, we'll get less parallax. I use rawFresnel calculated from Normal which comes from vertex input. We haven't sampled the BumpMap at this point:
float rawFresnel = saturate(1 - dot(viewDir, i.normal.xyz));
float offsetAmount = (1 + rawFresnel * rawFresnel * 4);
_ParallaxForce /= offsetAmount;
Looks slightly better:

But we can still see the pixels. So let us smudge those pixels a bit. Let's sample our BumpMap and use its value to offset UVs a bit:
float3 tnormal = UnpackNormal(tex2D(_BumpMap, uv));
uv -= tnormal.rg * _MainTex_TexelSize.xy;
And here we go. A slightly better, but still kind of ugly parallax)

Comments