alpha blend shadow problem


(eiM) #1

Hello there,

I’ve been working with alpha blending & dot product2 for long already and never had problems in my last projects. Though now I’ve come across something I really couldnt fix. I’ve created a simple shader for a stone to dirt blend which is also blending perfectly.
Only the lightmap seems to be ****ed up since the alpha blended brush is always alot brighter and ignores shadows which should be cast on it. I’ve added an example picture to this thread. The lightning works quite fine if there is no shadow casted on the brush, but once its in the shadow of e.g. a house its not getting any darker.

This is the shader I use:

textures/fischerdorf_terrain/marktpflaster_to_dirt
{
      qer_editorimage textures/fischerdorf/courtyard_brick2.tga
	surfaceparm landmine
	q3map_nonplanar
	q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 )
	q3map_alphaMod dotproduct2 ( 0.0 0.0 0.75 )
	q3map_shadeangle 120
	{
		map textures/fischerdorf/courtyard_brick2.tga
		rgbgen identity
		
	}
	{
		lightmap $lightmap
		blendFunc GL_DST_COLOR GL_ZERO
		rgbgen identity
	}
	{
		map textures/temperate_sd/dirt3.tga
		tcmod scale .5 .5
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
		rgbgen identity
		alphaGen vertex
	}
}

Please give me some tips =(

Those are the same brushes just copy&pasted into the shadowed area of the house…


(murka) #2

Could it for some reason be that you are rendering lightmap before the 2nd texture?(lightmap goes last)

textures/fischerdorf_terrain/marktpflaster_to_dirt
{
      qer_editorimage textures/fischerdorf/courtyard_brick2.tga
    surfaceparm landmine
    q3map_nonplanar
    q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 )
    q3map_alphaMod dotproduct2 ( 0.0 0.0 0.75 )
    q3map_shadeangle 120
    {
        map textures/fischerdorf/courtyard_brick2.tga
        rgbgen identity
        
    }
    {
        map textures/temperate_sd/dirt3.tga
        tcmod scale .5 .5
        blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
        rgbgen identity
        alphaGen vertex
    }
    {//Moved this last
        lightmap $lightmap
        blendFunc GL_DST_COLOR GL_ZERO
        rgbgen identity
    }
}

(Wezelkrozum) #3

[quote=murka10;198839]Could it for some reason be that you are rendering lightmap before the 2nd texture?(lightmap goes last)

textures/fischerdorf_terrain/marktpflaster_to_dirt
{
      qer_editorimage textures/fischerdorf/courtyard_brick2.tga
    surfaceparm landmine
    q3map_nonplanar
    q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 )
    q3map_alphaMod dotproduct2 ( 0.0 0.0 0.75 )
    q3map_shadeangle 120
    {
        map textures/fischerdorf/courtyard_brick2.tga
        rgbgen identity
 
    }
    {
        map textures/temperate_sd/dirt3.tga
        tcmod scale .5 .5
        blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
        rgbgen identity
        alphaGen vertex
    }
    {//Moved this last
        lightmap $lightmap
        blendFunc GL_DST_COLOR GL_ZERO
        rgbgen identity
    }
}

[/quote]

Yes that’s should fix it. The last texturemap is always on top. In this case, the lightmap.


(eiM) #4

thx mates that was a great help. I’ve created these based on sock’s shaders. Didnt think of that obviously. Working now


(eiM) #5

Since I dont want to open another thread for this. I’ve added surfaceparm’s to my shader now that the alphablending works. But somehow on three of these the landmine surfaceparm doesnt work properly.

The first two I have the surfaceparm landmine but CANT plant mines. The last one I dont have it and CAN plant mines. WTF did I mess up here?

textures/fischerdorf_terrain/normalgrass
{
	qer_editorimage textures/temperate_sd/grass_path1.tga
	surfaceparm landmine
	surfaceparm grasssteps
	q3map_shadeangle 120
	{
		map textures/temperate_sd/grass_path1.tga
	}
}


textures/fischerdorf_terrain/master_to_pathgrass
{
      qer_editorimage textures/temperate_sd/master_grass_dirt3.tga
	surfaceparm landmine
	surfaceparm grasssteps
	q3map_nonplanar
	//q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 )
	q3map_alphaMod dotproduct2 ( 0.0 0.0 0.75 )
	q3map_shadeangle 120
	{
		map textures/temperate_sd/grass_path1.tga
		rgbgen identity
		tcmod scale .125 .125		
	}
	{
		map textures/temperate_sd/master_grass_dirt3.tga
		tcmod scale .125 .125		
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
		rgbgen identity
		alphaGen vertex
	}
	{
		lightmap $lightmap
		blendFunc GL_DST_COLOR GL_ZERO
		rgbgen identity
	}

}



textures/fischerdorf_terrain/stone_to_sand
{
      qer_editorimage textures	emperate_sd\sand_bubbles_bright.tga
	surfaceparm stone
	q3map_nonplanar
	q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 )
	q3map_alphaMod dotproduct2 ( 0.0 0.0 0.75 )
	q3map_shadeangle 120
	{
		map textures	emperate_sd\sand_bubbles_bright.tga
		rgbgen identity
		
	}
	{
		map textures/fischerdorf/brownstone.tga
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
		rgbgen identity
		alphaGen vertex
	}
	{
		lightmap $lightmap
		blendFunc GL_DST_COLOR GL_ZERO
		rgbgen identity
	}

}

Good Luck finding my flaw :<


(Xterm1n8or) #6

Hello,

I’ve had a look at the stock shaders, because i couldn’t see anything wrong. Don’t know if this would make the slightest bit of difference but, it would seem that the surfaceparms always come after the q3map_ stuff. Worth a try.

Good luck mate :slight_smile:


(eiM) #7

thx for the tip but it doesnt help me at all at the listed shaders. I also noticed that all surfaceparm’s are being ignored and there are standard footsteps all over the place.

EDIT
Don’t ask me how but finally I got the landmines & footsteps working. So I can atleast plant the landmines.

But for some crazy reason once a landmine is planted at some textures its exploding directly, not with the usual delay. So an engi planting it is blown away. Anyone had this problem and knows a fix?


(Avoc) #8

In all my time using dot2prod, I’ve never witnessed any of your problems with the shader.
Perhaps you are having two overlapping brushes that are causing this problem?


(murka) #9

That’s weird indeed, i used your shader(replaced some textures) and it worked like it should, no probs.


(eiM) #10

Finally I let someone else try my shaders and even my compiled bsp. Its working for him and also on my server. So something with my ET Install must be broken, but I dont care about that now since its working once it leaves that install :smiley: thx for your input!