Decal z-fighting on walls

Discussion for Level editing, modeling, programming, or any of the other technical aspects of Quake
Post Reply
neoplan
Posts: 125
Joined: Thu Jun 05, 2008 9:47 pm

Decal z-fighting on walls

Post 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
}
}
obsidian
Posts: 10970
Joined: Mon Feb 04, 2002 8:00 am

Re: Decal z-fighting on walls

Post 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.
[size=85][url=http://gtkradiant.com]GtkRadiant[/url] | [url=http://q3map2.robotrenegade.com]Q3Map2[/url] | [url=http://q3map2.robotrenegade.com/docs/shader_manual/]Shader Manual[/url][/size]
neoplan
Posts: 125
Joined: Thu Jun 05, 2008 9:47 pm

Re: Decal z-fighting on walls

Post 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.
User avatar
mrd
Posts: 4289
Joined: Sat Mar 25, 2000 8:00 am

Re: Decal z-fighting on walls

Post 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:
Post Reply