Terrain Blending Article based on q3map 2.5.16


(sock) #1

so here it is …

After a lot of writing and constant proof reading the Terrain Blending article is finished. It started life as a small collection of ideas and suggestions, but some how turned into a 7 page monster! The article does contain a lot of technical jargon but hopefully its presented in a nice and easily understandable format.

Example map for Q3 engines
Source files
Terrain Blending Article

The example map and terrain blending article are based on the latest version of q3map2 (2.5.16) from Shaderlab

Please note: The latest version of q3map2 (2.5.16) works differently to the previous version. (2.5.15) The order in which the alpha value for a vertex point is changed is DotProduct2 first and then Alpha Fade Brushes second. This allows the terrain to be blended first with the DotProduct2 system and then fine tuned afterwards with the Alpha Fade Brushes.

Sock
:moo:


(TFate) #2

the map looks unbelivable. I am totally speechless.
Can you please post this same thread on the General forum too. Not that many casual players visit this forum (unfortunately) and I’d hate for anyone too miss this.

EDIT: Seriously, nice job. :smiley:


(Chruker) #3

Yet another great article, this one and the rockwall tutorial are masterpieces :slight_smile:

Two notes:

  • On the last page the Next link is changed to a Finish link, which makes me expect yet another page. Perhaps just call it Index or Articles
  • Photoshop 7 has a nasty bug which causes it to not use the 4th channel for transparency information. This stopped my first attempts at using the DotProduct2 system. However there are an update at the Adobe site. IIRC its a new version of the tga export filter.

(sock) #4

Ummm finish usually means last thing, the end. Yeah PhotoShop 7 is stupid without the patch. But I assumed most people knew about the patch.
Thanks for the comments and feedback :slight_smile:

Sock
:moo:


(DAbell) #5

Hi. sock

nice article made for good if slightly confusing reading, i have tried working with the shaders inlcuded with your sample map to try and understand better how it works. I created some quite undulating terrain in a small map and applied one of your moss/mud dot product shaders and all i got was moss. I used the alpha fade shaders to fade in the secondary texture which worked great and looked really good. The question i have is what causes the blending on the normal dot product shaders is it the steepness of the triangle its acting over or is it something else.

I hope i’m not being really dense asking this question i just cant seem to get the results that this should produce.

Thanks

D


(thore) #6

hey sock. thanks for your articles and releasing the source files for POM. i’ve read your tut on man made rock
some month before and now i finally made it to include this technique into a map. i made all of my terrain now
with brush shearing technique and just love it. it looks so much more organic than alls this nasty easygen stuff.
will take a while until i touch the dotproduct2 terrain system though, but thanks in advance ^^

when reading your terrain tut i missed a little note on whats the primary and whats the secondary texture you
used for your pics… i think that would help me to understand faster. it’s always those tiny questions that make
nubs like me riddling :smiley: an additional comment on “how to decide which tex goes primary and which one goes
secondary” would have been nice too.

keep up the great work!
greets.


(nUllSkillZ) #7

Very nice and helpful tutorial + tutorial maps.
Thank you very much.

I’ve tried to do this on my own.
But I’ve failed.
All I get are hard transitions instead of smooth blending.

Here is what I’ve done:
I’ve created a terrain in Easygen and have exported it.
I’ve moved the terrain func_group into worldspawn and deleted the vertexremapshader key/value pair.

I’ve added an alpha channel (white) to some stock ET textures and have saved them with the name mud.tga and gravel.tga.

Shader:


textures/terrain_test_1/gravelmud
{
	qer_editorimage textures/terrain_test_1/ter_gravelmud.tga

	q3map_nonplanar
	q3map_shadeAngle 120

	q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 )

	q3map_alphaMod dotproduct2 ( 0.0 0.0 0.75 )

	// Primary texture
	{
		map textures/terrain_test_1/gravel.tga
		rgbGen identity
	}

	// Secondary texture (requires ALPHA-channel)
	{
		map textures/terrain_test_1/mud.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
	}
}

After texturing some brush-faces I’ve added some Alpha Fade brushes.

Have I missed something?
Is the terrain too steep/not steep enough?
What is my mistake?

Editor image:

Terrain (some alpha fade brushes deleted):


(Shaderman) #8

I’ve added an alpha channel (white) to some stock ET textures and have saved them with the name mud.tga and gravel.tga.

I think the reason is the plain alpha channel you use. Give the alpha channel a structure like sock described on the last page of his tutorial (http://www.planetquake.com/simland/pages/articles/terrain1_7.htm) to get a better blending.


(nUllSkillZ) #9

Thnx for the link.

As I’ve started I made a mistake with the alpha channel.
I’ve increased the brightness and also the contrast.
This hasn’t worked either.
Then I’ve changed to a totally white alpha channel.

Now I’ve only increased brightness and I’ve only used “alpha_100” fade brushes.
And it looks much better.


(sock) #10

The first thing I would recommend is check to see if the sample maps work and compile ok with your setup. Then at least you know your shaders/compiler is setup correct.

The initial blending on the terrain is done via the dotproduct2 system. This will create alpha values for the vertex points based on the angles of the normals. (The steepness of the terrain) The alpha fade brushes are then used to fine tune the terrain so you get the blends and path/routes how you want them. Always use the minimum amount of alpha fade brushes so you preserve the original DotProduct2 blends.

The article is very condensed and does not really repeat anything but it tries to give as much new information as possible. The primary/secondary thing is mentioned a couple of times but yes I did not really go into it much. The order of the textures is dictated by what alpha channel you want and the order in which you want to blend things.

When blending I always planned them out on paper first and created a little system for it. I would draw out the blends and write in the primary textures used for each area. Then I would decide on what texture I would use for the blend/edges and that process would decide the order of the textures. So you end up with something like this:

P ----- S ----- P ------ S ----- P
Rock - Mud - Grass - Mud - Dirt

I sort of called it the PSP rule as it always made sure I did not create a wacky blend and end up with trying to blend a Primary to a Primary. I wanted to add something into the article about this but lack of space and information overload stopped me.

Did you compile the sample maps to see if the system works first?
No blends at all usually means the alpha channels are not being set by the compiler properly. It can be a path issue or shader. Partly why I ask did the original sample maps work bec then you know your compiler set it right.

One other thing to remember is that the blends are extremely sensitive to alpha channels and I have a sample map to show you what I mean.

http://www.planetquake.com/simland/files/blend_test1.zip
(This zip file needs textures from the POM map)

The above zip has 2 examples showing you why sometimes the Alpha Fade brushes don’t work how you expect them to. Its all down to the alpha channel and if not setup correctly you will not get the right results. I spent weeks tweaking the alpha channels of my textures and its not something that will work straight away, you will need to experiment.

Sock
:moo:


(nUllSkillZ) #11

Thank you very much for your help.
The sample maps have worked.

So I will take a look at the alpha channels,
Thansks again.


(DAbell) #12

Ok i’m getting it a little bit more, can i just present a scenario and try and get some clarification on how these shaders should work.

Say i create a small box map sky blah blah blah and generate some undulating terrain using the gen surf tool in radiant and on to this terrain i apply the shader say mudmoss from your sample map. when i compile using the latest q3map2 should there be any blending of textures on the terrain if the angles of some of the slopes are over say 45 degrees. I know the alpha channels are working ok because if i was to put some alpha fade brushes in the secondary texture will blend through in those areas. (and they are your shaders and textures)

Or is it that you need 2 shaders to blend at the areas where they meet.

Thanks

D


(Loffy) #13

Hi!
I tried dotproduct2 and alpha blend terrain in my current map project. But I noticed that the FPS dropped to 40, due to the large area. I’ll try to reduce the area (with these special Sock and ydnar shaders) for my next compile. At the moment, it seems these awesome terrain blends cannot be used on large open terrain areas because the FPS will drop. (The engine has to draw several “layers” - textures - when these shaders are used.)
// Loffy


(Shaderman) #14

Loffy I’m interested in using this d2a terrain on larger areas in my map, too. Could you please tell me how large your terrain is and something about the brush size you used (maybe roughly in square units)? And how did you make your terrain? Is it a easygen-shader-extension or handmade?

Thanks in advance


(Loffy) #15

Hi!
Have you played mp_tram (RtCW or ET)? The map with three castles: A lower castle, where allies first spawn, a middle castle (axis first spawn) and a top castle. There is a large open are between castle one and two (and an equally large open area between castle two and three).
To answer your question: My terrain is about the same size as this area between castle one and two. I do not know the grid-size.
My terrain is all hand-made. The terrain brush-sizes are rather big.
In sum: I applied a dotproduct2 shader on all of this terrain. Compiled. It looked nice. But the FPS dropped. I did a Find & Replace and replaced this dotproduct2 shader with a single-texture´. Recompiled. And the FPS became higher.
My next step is to put single-texture all over, and only use dotproduct2 and alpha blend in certain areas.
The hard part is to make a nice looking terrain, with a nice mix between single-texture, the dotproduct2 and alpha blend areas (no sharp edges).
// Loffy

PS. See Socks reply below, which came while I wrote the above.

Btw Sock, I dl POM and ran around in it in Q3A and the maps looks very organic and the sound sfx are just perfect. (i noticed a moo.wav file inside the pk3 :slight_smile: ). I like the big brown mushrooms in the map!

Closing though: About the DP2 and Alpha fade, I think the key thing here, is the thing Sock talked about eariler, that it takes weeks to tweak it to perfection.


(sock) #16

It will probably be easier if everyone asked questions about this in one thread in one forum. Have a look at this thread as it might help you with your question.

http://www.splashdamage.com/index.php?name=pnPHPbb2&file=viewtopic&t=10277

It all depends on how many triangles you are using for the terrain and what hardware you are working with. The DP2+Alpha Fade system only uses 3 layers per shader and if you want large open areas then you will have to comprise on detail and triangle count with the current technology. The trick to using the dp2+alpha fade system is only use blends when you need them in a large landscape and not coat a whole map in terrain blends.

Sock
:moo:


(nUllSkillZ) #17

I’ve managed now by tweaking the alpha channel to produce a nice result:

But I’ve ran into another problem:
Around the dotproduct2 texture there’s the texture I’ve made the secondary texture from.

There are alpha fade brushes (100% = secondary) at the edges of the dotproduct2 textured terrain.

BTW I’ve had the idea to use the inverted primary texture as alpha channel for the secondary texture.

Edit:

Yeah!

Some nice results:

From top of the picture:
Source for primary-1, primary-1, secondary-1, secondary-2, primary-2

Transition between source of primary-1 and primary-1 is not noticeable.
Also the transition between secondary-1 and secondary-2 is not noticeable.


(Loffy) #18

here are some terrain blending by Loffy:

Area A has this shader:


textures/loffys_1_tex/dotprod_pri_snowbig_sec_mxsnow  // New main snow tex. Used on all ground snow brushes.
{
	qer_editorimage textures/loffys_1_tex/snowbig_dot2_q3map2.tga
	q3map_nonplanar
	q3map_shadeangle 45 // Originally 120
	q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 )
	q3map_alphaMod dotproduct2 ( 0.0 0.0 0.75 )

	{
		map 	textures/snow_sd/snow_var01_big.tga  // Primary, used to be ter_moss1.tga
		//tcMod scale 0.125 0.125
		rgbGen identity
	}
	{
		map textures/loffys_1_tex/sd_mxrock4b_snow_loffy.tga  // Secondary, used to be ter_mud1.tga
		//tcMod scale 0.125 0.125
		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
	}
}

Area B has this shader:


textures/loffys_1_tex/sd_bigsnow_loffy1  // big snow
{
	q3map_nonplanar
	q3map_shadeangle 45
	nopicmip
	nomipmaps
	qer_editorimage textures/snow_sd/snow_var01_big.tga
	{
		map $lightmap
		rgbGen identity
	}
	{
		map textures/snow_sd/snow_var01_big.tga   // big snow
		blendFunc filter
	}
}

// Loffy


(The Wanderer) #19

@Loffy both areas(A and B) should have the same z-projection so that there’s no seam between them.
Add q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 ) to the B shader as well. This will eliminate the seam. (actually you might wanna increase the tiling to 512 for both of them in stead of 256 cause it looks like it’s tiling a lot right now)


(Loffy) #20

The Wanderer, thanks! Much better now!:

I’ve used q3map_tcGen ivector 1024.

Now, I have to work on those annoying sharp shadows between brushes.
The _lightmapscale is 5 for that piece of terrain.
I´ll lower the lightmapscale to 1 (or 0.5) in my next compile.
If that doesn´t work, I´ll try a lower (or higher?) q3map_shadeangle than 45.
(If all fails, I’ll throw in a couple of spot lights.)

// Loffy