Relief mapping is not applied on alpha mask / depth computation
Relief mapping is not applied on depth computation, hence alpha-tested textures using depth write (like grids) displays a bit of void. It's possible to workaround this by disabling the depth computation on those textures, but it would be better to fix the bug.
Maybe the proper implementation is to render the heightmap (basically blend the alphaterrain heightmaps) somewhere in memory in a way it can be reused multiple time (basically on depth map and on diffuse/lightmap stage).
Another proposed solution (and easier to implement at first) would be to just redo the relief computation on the depth mask as well…
To illustrate the problem, the white garbage is filling the space between the displaced diffuse and the non-displaced depth mask:
Another proposed solution (and easier to implement at first) would be to just redo the relief computation on the depth mask as well…
Checking the alpha channel in lightMapping_fp would probably be faster. Some extra texture reads, but no extra divergence introduced in depth shader then. It would also avoid writing depth in it, which would otherwise disable early-z optimisations.
Instead of disabling relief mapping, we should disable the depth shader for the affected shader. Depth shaders are not essential to render correctly: see #1412.
@slipher the screenshot in the comment above was taken in test-pbr map from https://github.com/UnvanquishedAssets/UnvanquishedTestAssets/releases/tag/v2.1
I'd prefer a proper fix here rather than disabling things.
A proper fix is likely slower: what I understand is that it would require to compute relief mapping in the depth shader…
I mean, if by disabling we mean disablign depth.
If we mean disabling relief mapping, we better not do that yes.
Since relief mapping is known to be very expensive, maybe skipping the depth pass could actually be optimal in any case? For an sufficiently expensive shader, the cost of running it twice would outweigh the savings of using less memory bandwidth.
Since relief mapping is known to be very expensive, maybe skipping the depth pass could actually be optimal in any case?
I do believe it, yes.
A proper fix is likely slower: what I understand is that it would require to compute relief mapping in the depth shader…
I believe we can just use alpha mask with relief mapping instead.
My concern with skipping depth here is that it might lead to incorrect results, since it would probably break any effects that rely on depth. It might not be noticeable if it's only done on surfaces that look like swiss cheese, though.
If we skip depth, what would happen if there are more than one texture like this in the line of sight?
If we skip depth, what would happen if there are more than one texture like this in the line of sight?
It probably wouldn't look worse than if there was only one of them in line of sight, but performance would suffer as relief mapping is quite heavy.
I tried the approach with alpha-testing in relief shader, but it creates too much of a slowdown.
