Page 1 of 1

Decal z-fighting on walls

Posted: Sat Mar 29, 2014 1:30 pm
by neoplan
Decals are awesome,
but I run into one problem that I can't figure out why it happens. Dependant on the players vie angle, some decals in my map start to show z-fighting.
This usually only happens on axial walls and not on floors. Anyone has similar experience or in idea how to solve this?

Image

Here is the shader:

textures/amt-fs5_decal/cretebase3_decal
{
qer_editorimage textures/amt-fs5_decal/cretebase3_decal.tga
qer_trans 1
surfaceparm trans
surfaceparm nomarks
surfaceparm nonsolid
polygonOffset
{
map textures/amt-fs5_base/cretebase3.tga
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
rgbGen identity
}
{
map $lightmap
rgbGen identity
blendFunc filter
}
}

Re: Decal z-fighting on walls

Posted: Sat Mar 29, 2014 3:20 pm
by obsidian
polygonOffset works best with blendFunc add, filter, GL_DST_COLOR GL_ZERO (multiplicative), or GL_ZERO GL_ONE_MINUS_SRC_COLOR (inverse-multiplicative). So these blendFuncs are best for burn marks on walls, glowing bits, etc. It doesn't like multi-staged shaders with alpha-channels very much.

You can try using a sort value (try 6 or 7) and see if that works for you.

Otherwise, you might be better off leaving polygonOffset out and make the decal a "floater", sticking it on a detail brush or patch and floating the surface just above the wall behind it. You'll be venturing into less than 1 grid sizes, so if using a brush make sure to set it DETAIL.

Generally it's a good idea to add "surfaceparm detail" to your decal shaders anyway.

Re: Decal z-fighting on walls

Posted: Sat Mar 29, 2014 5:28 pm
by neoplan
Thanks for your suggestions. I tried different blend modes but the result was always too dark or it was fullbright.

The sort values have the problem that weapon marks will be drawn behind the decals.

Re: Decal z-fighting on walls

Posted: Sat Mar 29, 2014 8:50 pm
by mrd
obsidian wrote: Otherwise, you might be better off leaving polygonOffset out and make the decal a "floater", sticking it on a detail brush or patch and floating the surface just above the wall behind it. You'll be venturing into less than 1 grid sizes, so if using a brush make sure to set it DETAIL.
This is what I always did, worked fine for me. :ducky: