z-buffering alpha texture problem... ?


(IndyJones) #1


looks like z-buffering problem. here is a shader i’m using. basically you can see leaves of other trees thru other texture… i tried diffrent number of sort - same problem. any idea guys?

models/path/texture
{
	cull disable
	nopicmip
	nomipmaps
	surfaceparm nomarks
	surfaceparm alphashadow
	surfaceparm pointlight
	surfaceparm trans
	surfaceparm nonsolid
	tessSize 1
	sort 16
	{
		map models/path/texture.tga
		blendfunc blend
		rgbGen identity
	}
}

(Berzerkr) #2

Only guessing, maybe you have to add depthWrite to the shader?
I would also try implicitMask -

From the Q3A Shader Manual

6.7 depthFunc <func>
This controls the depth comparison function used while rendering. The default is “lequal” (Less than or equal to) where any surface that is at the same depth or closer of an existing surface is drawn. This is used for textures with transparency or translucency. Under some circumstances you may wish to use “equal”, e.g. for lightmapped grates that are alpha tested (it is also used for mirrors).

6.8 depthWrite
By default, writes to the depth buffer when depthFunc passes will happen for opaque surfaces and not for translucent surfaces. Blended surfaces can have the depth writes forced with this function.

BTW: Thought first you posted a photo.


(IndyJones) #3

implicitMask - helped, but then it texture became very sharp in game, just like leaves circled on pic… that’s what i want to avoid.


(ailmanki) #4

some wild guesses:

I think sort should be removed, as all the trees will have same sort applied.

and along the next 3 keywords the solution should be…
http://www.racer.nl/reference/shadereng.htm#depthfunc


(Wezelkrozum) #5

I think the command depthWrite will do the thing. But thats a wild guess


(Pande) #6

sort 16
remove that, i had same problem with that sort thing too when making a row of fences.


(IndyJones) #7

removing sort 16 didn’t help…

current shader:

models/path/texture
{
  qer_editorimage models/path/texture.tga
  surfaceparm alphashadow
	cull twosided
	{
		map models/path/texture.tga
    //depthwrite
    blendfunc blend
    //blendfunc GL_ONE_MINUS_SRC_ALPHA gl_src_alpha
    //blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
    //blendFunc add
    //alphaFunc GE128
		rgbGen vertex
	}
}


as you can see on right side - it still has buffering (?) problem…


(pazur) #8

I had the problem (don’t laugh - 6 years ago :smiley: - just looked up: Posted: Thu Jul 03, 2003 3:47 am) and discussed it back then in the Tram Design forum. I ended up using alphafunc instead of blendfunc. Here is the link to the Tram Design forum: http://www.tramdesign.net/forums/viewtopic.php?t=708&highlight=

Maybe it’s simply not possible having blendfunc in the shader for leaves of trees?