PDA

View Full Version : dotproduct2 terrain problem (blending) *SOLVED*


Beza
19th August 2005, 19:56
i have some problem with blending terrain surfaces:

http://first-encounter.com/anex3d/Beza/trench_x.jpg


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
20th August 2005, 05:46
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
20th August 2005, 10:21
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
20th August 2005, 12:42
Have you tried to vary the shadeangle?

Beza
20th August 2005, 14:46
Have you tried to vary the shadeangle?
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 :)

The Wanderer
20th August 2005, 16:54
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
20th August 2005, 18:22
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
20th August 2005, 20:54
here are more pics showing problem in detail

http://first-encounter.com/anex3d/Beza/trench_x_d01.jpg

http://first-encounter.com/anex3d/Beza/trench_x_d01vhe.jpg

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)

http://first-encounter.com/anex3d/Beza/trench_x_d02.jpg

http://first-encounter.com/anex3d/Beza/trench_x_d03.jpg


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

http://first-encounter.com/anex3d/Beza/trench_x_d04.jpg


* vertices are on the same cordiantes

* removing alphaFunc GE128 has no effect

carnage
20th August 2005, 21:02
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
20th August 2005, 21:02
Hey, which game is this? Call of duty/Mohaa? :|

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
20th August 2005, 21:06
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
20th August 2005, 21:25
Hmmm... Seems this is not in the shadermanual then.

Could check it out...

carnage
20th August 2005, 21:36
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
21st August 2005, 00: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
21st August 2005, 08:55
Concentrate on the q3map_tcGen ivector and q3map_alphaMod dotproduct2 commands(the other commands won't really affect much).
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 ;)

so again, thx for all comments