dotproduct2 terrain problem (blending) *SOLVED*


(Beza) #1

i have some problem with blending terrain surfaces:

terrain shaders:

textures/trench/ter_crate2mud
{
	q3map_nonplanar
	q3map_shadeangle 100
	q3map_tcGen ivector ( 348 0 0 ) ( 0 348 0 )
	q3map_alphaMod dotproduct2 ( 0.0 0.0 0.75 )
	q3map_lightmapSampleSize 8
	{
		map textures/rail/ground_crate.jpg
		rgbGen identity
	}
	{
		map textures/rail/ter_mud1.tga
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
		alphaFunc GE128
		rgbGen identity
		alphaGen vertex
	}
	{
		map $lightmap
		blendFunc GL_DST_COLOR GL_ZERO
		rgbGen identity
	}
}

textures/trench/ter_groundmud
{
	q3map_nonplanar
	q3map_shadeangle 90
	q3map_tcGen ivector ( 348 0 0 ) ( 0 348 0 )
	q3map_alphaMod dotproduct2 ( 0.0 0.0 0.75 )
	q3map_lightmapSampleSize 8
	{
		map textures/test_map/ground_old.jpg
		rgbGen identity
	}
	{
		map textures/rail/ter_mud1.tga
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
		alphaFunc GE128
		rgbGen identity
		alphaGen vertex
	}
	{
		map $lightmap
		blendFunc GL_DST_COLOR GL_ZERO
		rgbGen identity
	}
}

textures/trench/alpha_000	
{
	q3map_alphaMod volume
	q3map_alphaMod set 0
	surfaceparm nodraw
	surfaceparm nonsolid
	surfaceparm trans
}

textures/trench/alpha_100	
{
	q3map_alphaMod volume
	q3map_alphaMod set 1.0
	surfaceparm nodraw
	surfaceparm nonsolid
	surfaceparm trans
}

i did that way all the terrain on all my maps and with 95% of terrain i have no problems, but there are some places (like on the picture) which ruin the whole map :’(

i would be thankful for any advice…


(Loffy) #2

Hi!
I am not an expert in shaders, and willing to admit that I really do not know what I am talking about.
Given that, this is the shader I used for terrain in my map duplex towers:


textures/terrain_example/ter_dirtmud
{
	qer_editorimage textures/terrain_example/ter_dirtmud.tga
	q3map_lightmapaxis z // Project lightmap on z axis (up/down)
	q3map_lightmapmergable // Merges all terrain into one seamless lightmap (no seams)
	q3map_lightmapsamplesize 32 // Sets lightmap sample size to 2x normal to save mem
	q3map_nonplanar
	q3map_shadeangle 120
	surfaceparm landmine
	q3map_tcGen ivector ( 512 0 0 ) ( 0 512 0 ) // ( X Y Z ). The axis with 0 in both groups = projection axis.
	q3map_alphaMod dotproduct2 ( 0.0 0.0 0.75 )

	{
		map textures/terrain_example/ter_dirt1.tga // Primary
		rgbGen identity
	}

	{
		map textures/terrain_example/ter_mud1.tga	// Secondary
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
		alphaFunc GE128
		rgbGen identity
		alphaGen vertex

	}

	{
		map $lightmap
		blendFunc GL_DST_COLOR GL_ZERO
		rgbGen identity
	}
}

Thing that differs, are:
q3map_lightmapaxis z // Project lightmap on z axis (up/down)
and
q3map_lightmapmergable // Merges all terrain into one seamless lightmap (no seams).

And I have q3map_shadeangle 120.
Maybe you could try all or some of these settings and see what happens?

//Loffy


(kamikazee) #3

The q3map_lightmapmergable is certainly advised for terrains.
The q3map_lightmapaxis z is not required, but I believe it fastens up lighting since it will not check the underside of the terrain.
And the last one is used for phong smooting, this improves the smooth apeareance of the terrain as it smooths out the lightmap. This takes some more compile time though.


(nUllSkillZ) #4

Have you tried to vary the shadeangle?


(Beza) #5

yes i did (40-120), as well as trying another parameters (adding q3map_lightmapmergable, q3map_lightmapaxis z) but all of these params involve lightmaps… and thats definetely not my problem - i can even turn off LMs (or simply dont use any light source) and i still have my problem

im using similar textures (brown ground and dark brown dirt) so it may look like lightmap problem, but im sure, its due to bad blending these 2 similar textures

anyway thanks for your ideas and i hope more will come :slight_smile:


(The Wanderer) #6

A few questions first:
Which shader is being used on the orange portion of the terrain and which one on the green.
Also are all those alphamod brushes 0%

From the pictures it looks like it’s a bad shadowing problem, but you’re saying it’s bad blending. Maybe you should post a better close up of the problem(preferabley done in -meta only compile and maybe another shot with r_showtris 1 enabled.)

Currently the two shaders you’ve posted do not and cannot blend with each other(unless you’re using them on a completely flat surface), but it looks like your problem is that there are seems on terrain with the same shader on.

Post the info i told you and I’ll try to help you some more.


(carnage) #7

q3map_nonplanar

well it cant be a problem with ur blending ither since ur veritices are merged and averaged, if you have vertices that are acidently not on the same cordiantes that can cause this kida effect

look realy close in the game and see if u can see a tiny gap or sparkel lines between these blends

alphaFunc GE128 u might want to take this out, sock had this but i though it kinda makes the seconds layer apearfloating slightly over the first when u look close also it has some effect when drawing at distance + think its cos more to draw the layer. without it the belnd with apear much smoother


(Beza) #8

here are more pics showing problem in detail

inner alphamode brushes are 0% and the rest (brushes between shaders) are 100% (due to dot product2 i just blend 2nd layer of shaders - ter_mud1.tga)

here you can see shot from the same map, using same shaders/alphamod brushes, but no problem at all

  • vertices are on the same cordiantes

  • removing alphaFunc GE128 has no effect


(carnage) #9

can i just say thoes screens look realy impresive, the way the fog semi colours the hill its superb, the colours and the lighting are great, how does the lightgrid make the player look? it would be a shame if they apreard to be the worong colour for the scene

GE128 will not have an effect in fixing ur problem, it means only draw if the point in the alpha chanle is greater than 128 or equil to it, without it u get a smooth belnd with it it creates a crisp line withing the texture (look at the tress in fueldump) its more calcualations tho so if u can avaoid i would recormend u do

could you take out a small section of the map with the problem in and put it up for dl so i can get a better look at it?


(kamikazee) #10

Hey, which game is this? Call of duty/Mohaa? :expressionless:

Haven’t seen any of those alphamod brushes/entities/whatevers yet, I believe I can’t help you since I’m more an ET mapper.


(carnage) #11

alpha mod brushes are for the q3map2 compiler so they are very much part of ET, would recorment leanring dot2product terrian as a method for making terrain its a lot better than writng the old shaders and u can get some realy nice hand tweked result

also it has potential do do many more things if u put ur mind to it, a good example is wen someone used it to creat a cool water scene where it water changed coloyr at differnt depths


(kamikazee) #12

Hmmm… Seems this is not in the shadermanual then.

Could check it out…


(carnage) #13

http://www.planetquake.com/simland/pages/articles/terrain1_1.htm

some parts of it can be a bit confusing untill u can do it, and its a lot eaier to do it that to understand how it works


(The Wanderer) #14

that is very peculiar. There should be no seams on those portions …I’m not sure what can be causing it. The only thing i can think of is the textures themselfs might not be entirely seamless, although I’m sure you’ve checked that already(doesn’t hurt to double check though).

My only advice is for you to first isolate the problem. Copy the problematic portions and paste them in a new map. Then start making changes to the shader to see what, if anything, has any effect. This way you don’t have to recompile the whole map each time.
Concentrate on the q3map_tcGen ivector and q3map_alphaMod dotproduct2 commands(the other commands won’t really affect much). Keep making changes to these until get something better, or at least get some clue as to what is causing the problem.


(Beza) #15

damn right - changing just one value of q3map_tcGen ivector solved it all… thank you


btw this is our own game runnig on our own engine (quake-like)… i was afraid if its problem of bad implementation some quake-like functions to engine, but fortunately our programmer did good job :wink:

so again, thx for all comments