Alphablending trouble


(]UBC[ McNite) #1

Well since the search is borked… here we go with another thread about alpha blend trouble.

This is the shader for decal blending from socks simland stuff:

textures/terrain_example/dcl_moss1		// Decal blending
{
        qer_editorimage textures/terrain_example/ter_moss1.tga
	q3map_nonplanar 
	q3map_shadeangle 120 
	surfaceparm trans 
	surfaceparm nonsolid 
	surfaceparm nomarks
	polygonoffset
	{
		map textures/terrain_example/ter_moss1.tga
		alphaFunc GE128
		rgbGen identity
		alphaGen vertex
	}
	{
		map $lightmap
		blendFunc GL_DST_COLOR GL_ZERO
		rgbGen identity
		depthFunc equal
	}
}

If I use the map textures stage like that, I get a solid surface, and no fading against the markers since I use the stock tex temerate_sd/grass_dense1.tga (no difference if used with a 32bit and white alphachannel or just like it shipped with ET). I figure this is due to the totally white alphachannel or the fact that i used a 24 bit tga.

If I remove the alphaFunc like this:

	{
		map textures/temperate_sd/grass_dense1_a.tga
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
		//alphaFunc GE128
		rgbGen identity
		alphaGen vertex
	}

I do get a smooth fading against the markers. Only it seems that the decal triangles don’t get a lightmap from the q3mapsun_ext from the skyshader (its emitting a blue light). The grass isn’t dark enough as you can see here:

So the question of the day is: How can I talk the non-transparent part of the blended stage into getting the same lightmap as the other terrain so I have the grass in the same blue-ed color?
Removing the depthfunc line does that trick, somehow… only the transparent areas of the blend will get the blue from the sky as well then, and the result are some dark blue triangles, which doesnt really look cool.

Any help is seriously appreciated!


(Shallow) #2

Sounds like you haven’t tried an alpha channel with the right sort of brightness range yet, and possibly not one with any detail at all? Getting the alpha channel right is important, it needs to contain grainy data (usually based on the RGB part of the texture) and be pretty bright overall. It shouldn’t be a uniform shade though - that will do nothing.

Reading http://simland.planetquake.gamespy.com//pages/articles/terrain1_7.htm again may help. Look at the alpha channels in sock’s sample textures too.

BTW looking at that shot, maybe you should put the alpha on the rocks and swap the stage order? That way you might be able to wangle a nice effect with the grass growing more in the cracks of the rock.


(carnage) #3

hes not using an image alpha channel but generating alpha values from vertice alpha values

the problem here is that there are two lightmap stages being drawn and since the grass blendins into nothing the lightmap is still draw on the transparent part of the tris so it apears to have been drawn twise making the areas darker blue then they should be

AFAK McNite has already implemeted a work around


(]UBC[ McNite) #4

Yepp since there was no solution to the problem, I removed the blends and did it without them in that place.


(BigBadWolf) #5

Just as a note, brushwork affects how well the alpha blending works too.