Daemon icon indicating copy to clipboard operation
Daemon copied to clipboard

Translucent texture rendered above fog

Open illwieckz opened this issue 5 years ago • 1 comments

First seen in https://github.com/Unvanquished/Unvanquished/issues/799

See the ice stalactites on the gauntry (in background):

translucent on fog

illwieckz avatar Apr 12 '20 03:04 illwieckz

This might be some incorrectly set shader sort since we do depth->opaque->fog->translucent. Or maybe we just need another pass before fog and after opaque, since stalactites probably are translucent.

VReaperV avatar Oct 18 '24 10:10 VReaperV

I decided to check if it's still true...

image

On the bright side, it's no longer rendered above fog.

VReaperV avatar Oct 26 '24 22:10 VReaperV

Confirming the original bug is still there.

VReaperV avatar Oct 26 '24 22:10 VReaperV

This might be some incorrectly set shader sort since we do depth->opaque->fog->translucent. Or maybe we just need another pass before fog and after opaque, since stalactites probably are translucent.

So the stalactites are, in fact, translucent.

VReaperV avatar Oct 26 '24 23:10 VReaperV

The implicitMask is indeed not working, because the alpha threshold is being set to 1.5, i. e. the default value.

VReaperV avatar Oct 26 '24 23:10 VReaperV

Looks like the shader gets sorted as opaque and I'm not seeing it being used when stepping through the RB_RenderDrawSurfaces() code for translucents, but I see it being rendered after the global fog in a frame debugger...

VReaperV avatar Oct 27 '24 07:10 VReaperV

They also don't write to depth, even though they should.

VReaperV avatar Oct 27 '24 07:10 VReaperV

Oh wait, I was looking at the wrong shader lol.

VReaperV avatar Oct 27 '24 08:10 VReaperV

So this is the shader in question:

surfaceparm alphashadow
cull none
{
    map textures/snow/alpha_ice2s.tga
    blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
    rgbGen vertex
}

It might be that alphashadow is supposed to turn alpha testing on here, but it doesn't.

VReaperV avatar Oct 27 '24 09:10 VReaperV

I've watched some wolf ET videos and it seems the icicles there are also rendered above fog, the only difference is ours are rendered darker for some reason (on the original screenshot the ones closer to the view are rendered as they should, unlike the ones on the gantry, now both are like the ones on the gantry).

VReaperV avatar Oct 27 '24 09:10 VReaperV

The shader is set to do rgbgen vertex, and these are the vertex colours used by those surfaces: With default overbright settings: image With r_overbrightDefaultClamp on: image

So this has something to do with overbright.

VReaperV avatar Oct 27 '24 10:10 VReaperV

The first screenshot has the original vertex colours, so they're being rendered correctly based on that.

VReaperV avatar Oct 27 '24 10:10 VReaperV

Closing since the original issue is a map/shader bug, not an engine one.

VReaperV avatar Oct 27 '24 10:10 VReaperV

The bug we were looking for was that he global fog was rendered twice, that is fixed with:

  • https://github.com/DaemonEngine/Daemon/pull/1740

While the stalactites were always rendered above the fog (which is wrong), this did not looked bad unless we rendered the fog twice, and then the fog being too-much opaque, it became obviously visible that the stalactites were rendered above it.

Before:

Image

After:

Image

Before:

Image

After:

Image

Before:

Image

After:

Image

illwieckz avatar Aug 11 '25 15:08 illwieckz