[TUTORIAL] Terrain blending on .ase model with Blender and Netradiant


(BackSnip3) #1

---------- SETUP ----------

This tutorial works with Netradiant, but I haven’t tested with GtkRadiant, it needs a special Q3map2 compiler which Netradiant has, maybe newer versions of GtkRadiant include this compiler, if so please let me know.

You will need this :

---------- INSPIRATION ----------

This tutorial is inspired by this tutorial and SimonOc’s terrain blending tutorial, I couldn’t have done this tutorial without these, so thanks!

---------- TUTORIAL ----------

The point of this tutorial is to make it easier for mappers to create terrain blending, with method inspired from SimonOc’s tutorial, instead of using the boring AlphaMod brushes on each terrain vertex, we will directly paint the terrain in a modelling editor, which is much easier!

STEP 1 : GETTING THE MESH DONE

There are many ways to create your terrain mesh, you can do it either completely with brushes from Radiant, or you can use any modelling editor that can export to .obj file format for importing to Blender at a later stage.

For example, I created my terrain mesh using Cinema4D:

But you can export brushwork from Radiant:




Once the model is done and you’re happy with it, you will need to adjust it’s UVmap in order for the textures to look correct on it. I will not cover this part, there are plenty of tutorials on the web and the method differs from a modelling editor to another one.

With Cinema4d, I could achieve this result with the model above:

STEP 2 : CREATING THE SHADER(S)

For this test, we will use textures from pak0.pk3:
Use this shadercode as a base for your shaders.



////////////////////////////////////////////////////////////////////////////////////////
// BackSnip3 terrain experiments				////		
// During colorpainting, black = primary & white = secondary		////
////////////////////////////////////////////////////////////////////////////////////////

models/terrain/sample_rock_snow
{
	qer_editorimage textures/sample_blending/rock_snow_editor.tga 	// texture for editor
	q3map_clipmodel                                          			// make model solid
	{
		map textures/temperate_sd/rock_ugly_brown.tga		// primary texture
		tcMod scale 4 4                                    			 // scale by 4x factor
	}
	{
		map textures/snow_sd/bigrock_rounded_faint.tga		// secondary texture
		tcMod scale 4 4                                     			// scale by 4x factor
		blendFunc blend                                   			// mix texture with primary texture
		alphaGen vertex                                  			// alpha channel determined by vertex color
	}
	{
		map $lightmap                                      			// apply lightmap to this surface
		blendFunc filter
		rgbGen identity
	}
}

Don’t forget to update your shader list when you create new shader files!

For the tutorial, one shader will be enough to demonstrate the blending effect.

STEP 3 : COLOR PAINTING

YAY!!!:penguin:
The following explanations should work for both versions of Blender detailed earlier.

Steps:

  • Import your model into Blender.

  • Apply a material to the model, give it the EXACT name of your shader path (ex: models/terrain/example)

  • Select vertex paint in object interaction selector:


Painting options are self-explanatory, on Blender 2.69 they appear on the left pane, on blender 2.49b they appear on the bottom pane, you also have more options if you press the N key.

Paint your model, just remember one thing -> black is primary texture only, white is secondary only.

I did something like this with my sample model:

Once you’re happy with your painting, export your model to .ase, don’t forget to select “Vertex Color” option before finishing the export.

With Blender 2.49b, material path can’t be longer than 21 chars, to solve this you have to manually edit the .ase file with Notepad to complete your shaderpath.

*MATERIAL_LIST {
	*MATERIAL_COUNT 1
	*MATERIAL 0 {
		*MATERIAL_NAME "models/terrain/sample_rock_snow"
		*MATERIAL_CLASS "Standard"

If you’ve managed to get all of this done, you’re nearly there!!

STEP 4 : USING THE MODEL INSIDE RADIANT

Create a misc_model entity, and import your .ase file.
Give your model “spawnflags 32” (insert key : spawnflag and value : 32)
If you didn’t put “q3map_clipmodel” inside your shader but still want collision ON, put spawnflags 34 instead.
You’re ready to compile!!

I managed to get something like this:





If you have any comments, please yourself!

SOURCE FILES

---------- NOTES ----------

You can change “tcMod scale” value inside your shader to scale your textures if they appear too big or too small.
You can also use AlphaFunc GE128, using a secondary texture which has an alpha layer, to generate cool effects as in SimonOc’s tutorial (screenshots to come).
You can use different shaders for one model, just separate each mesh for every shader and do the correct paintings to have seamless transitions
between meshes.
You can apply “surfaceparm” landmine, snowsteps etc inside your shader, it works too!
If lightmap isn’t accurate enough, you can use “q3map_lightmapSampleSize” with a value < 16 to achieve more accuracy, don’t abuse this as it can lead to massive lightmaps amount. I suggest you not to go under a value of 4.


(KeMoN) #2

Great tutorial! Sounds like a better alternative to those messy alpha-fade brushes!
Will test it as soon as I can. :slight_smile:


(.Chris.) #3

This explains the pm the other day.

Here’s a comparison between using brush based terrain with alpha blending and using the model method:

EDIT: link instead, image too big for forums:

http://www.battle-of-wolken.co.uk/images/ETMAP/blend_comparision.jpg

Model on left brushes on right.

I think what you need to be careful of though is to not make your model too complicated because your having to use the q3map_clipmodel thingy which I remember is not advised on complicated geometry and is why you normally use a simple clip brush for regular models. Considering terrains are typically simple in shape I guess you shouldn’t run into to much trouble.

Be good to see this used on a large scale, I never got around to finishing my own map with this.


(BackSnip3) #4

Yes I was planning on doing a tutorial because it could prove useful to many mappers who find SimonOc’s tutorial too complicated.
You’re right about q3map_clipmodel, but because of the model nature people can optimize the triangle amount with a lot more flexibility than with brushes, in my opinion.
I’m working on implementing this in Dingenskirchen map in the future. I find using models a lot easier than manipulating brushes, but that might just be me.
When I have time I’ll provide a map example which is only using .ase models and caulk brushes, to show people that models can be better than brushwork.


(Brandon C. Gainey {aka} [TfL]DoubleDragon) #5

Just wanted to update the ASE Export plugin that is missing for Blender 2.69 from the authors post

I found it here https://www.quake3world.com/forum/viewtopic.php?f=10&t=52074

The download is https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/ase-export-vmc/ASE251.zip

The installation instructions are included in the readme.rtf