Having trouble with dotproduct2 terrain


(Moonkey) #1

I’m sure the problem is something pretty obvious, but I can’t see it.

http://homepages.ihug.co.nz/~moonkey/terraintest.jpg

Using plain colours to see what’s going on - green undercoat with red and blue blends. The red and blue textures both have ~85% bright alpha.

There is some blending going on (the colours showing up are blends of the texture colours), its just totally sharp.

Compiling with latest q3map2.5.14 (dev build, the original gave different, weird results)

shader:


textures/terraintest/terrain 
{ 
	qer_editorimage textures/terraintest/terrain.tga 
	q3map_nonplanar 
	q3map_shadeAngle 179 
	q3map_tcGen ivector ( 512 0 0 ) ( 0 512 0 ) 
	q3map_tcMod rotate 33 
	q3map_lightmapAxis z 
	q3map_lightmapSampleOffset 8 
	q3map_alphaMod dotproduct2 ( 0 0 .85 ) 
	
	{ 
		map textures/terraintest/green.tga 
		rgbGen identity 
	} 
	
	{ 
		map textures/terraintest/red_alpha.tga 
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA 
		alphaFunc GE128 
		rgbGen identity 
		alphaGen oneMinusVertex 
	} 
	
	{ 
		map textures/terraintest/blue_alpha.tga 
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA 
		alphaFunc GE128 
		rgbGen identity 
		alphaGen vertex 
	} 
	
	{ 
		map $lightmap 
		blendFunc GL_DST_COLOR GL_ZERO 
	} 
}

Any ideas? :bored:


(rgoer) #2

Try playing with the vector values… maybe check out ( 0 0 1.0 ) just for starters

And play with the brightness of your alpha channels… you can keep your images open in photoshop while you have quake in a window, then just vid_restart every time you make a change to your alpha channels…


(ydnar) #3

You’ll also need a more complex terrain mesh than that to see subtle blending effects.

Note that alphaFunc GE128 is what products the hard edge between different stages. The 2 and 3 texture dp2 example shaders have mottled, non-solid alpha channels to avoid this exact issue. Try using gaussian-blurred noise in the alpha channel of your textures instead of a flat 85%.

y


(Moonkey) #4

Thanks guys :slight_smile:

I’ve been playing around with what you’ve suggested.

Things are looking alot better now.
http://homepages.ihug.co.nz/~moonkey/terraintest3.jpg

I’m trying to smooth out the transition so I removed the alphaFunc GE128.
Now my main question is whether it’s possible to get the alpha to change across the span of each tri, or whether each tri has a certain alpha value.
Basically I’m after a more rolling look than the panelled one I have now.

Also, I’m wondering if there are any keys that should be used with this sort of terrain. I’m just using a plain func_group.


(ratty redemption) #5

the alpha is calculated at compile time by the dp2 (dotproduct2) at each vertex and saved into the bsp.

if the all the verts of a tris are the same height then they would result in no blend across that tris, similar to using a shader alphagen const value, on the brush face, but with dp2, if the verts vary in height then blends will happen across the tris.

the values you posted of ( 0 0 .85 ) are good ones for most terrain, but I personally find it easier to then tweak a few of the brushes verts in radiant then try to get a dp2 value to work perfectly for the entire terrain.

also you can use alphamod volume brushes to control the exact vertex alpha, if need be.


(Moonkey) #6

Ok, cool

so in this pic:
http://homepages.ihug.co.nz/~moonkey/terraintest4.jpg

there should be a seamless blend at that vertex? (well, every vertex)

I take it I’m still doing something wrong :S


(ydnar) #7

Make sure you’re compiling with -meta. If you don’t, none of the nonplanar/blending/phong shading code is enabled.

Always BSP your maps with -meta.

y


(Moonkey) #8

Gah, q3map2build tricked me… I thought I’d been using meta all along.

That’s exactly the obvious thing I was talking about :twak:

Thanks heaps, perfectly smooth now :slight_smile:


(ratty redemption) #9

at least you`ve got good results now :slight_smile: