chapter 2: using volume blending to reduce tiling patterns on terrain
image 269 shows one of my dotproduct blended rock faces.
I`ll post the shader later on, but for now just note the shader used a q3map_tcmod rotate 33 which is why the grain of the rock is at a slant, ie off axis, not lying directly north, south, west or east.
and even though their is some topographic distortion, the tex patterns are already becoming obvious.
the rock tex used here is 512x512 size and scaled to repeat every 512 units in game, the larger the tex the further from the camera before the tiling patterns start to look unnatural, but at certain distances even the largest tex would be prone to this.
image 253 shows what that scene looks like in radiant.
the light gray shader is the main rock one.
textures/_ratty_terrain/base3
{
q3map_lightmapsampleoffset 16
q3map_shadeangle 178
q3map_tcmod rotate 33
q3map_nonplanar
q3map_forcemeta
q3map_alphamod dotproduct2 ( 0 0 0.84 )
q3map_tcgen ivector ( 512 0 0 ) ( 0 512 0 )
}
textures/_ratty_terrain/dirt_rock_blend // rock wall, dirt transition
{
qer_editorimage textures/_ratty_terrain/grey_terrain.tga
q3map_baseshader textures/_ratty_terrain/base3
surfaceparm grasssteps
{
map textures/_ratty_terrain/ratty_dirt_m03.tga // dirt transition
tcgen vector ( 0.00390625 0 0 ) ( 0 0.00390625 0 ) // 256
//rgbgen const ( 0.6 0 0 ) // uncomment to debug
}
{
map textures/_ratty_terrain/ratty_cliff_m05dcon.tga // rock wall
alphagen oneminusvertex
alphafunc ge128
}
{
map $lightmap
blendfunc filter
}
}
the brown shader is the multi stage blend between the grass and rock shaders… the reason I do this is to save fps, by reducing shader stages on areas that dont need them, ie the majority of the grass areas dont need any rock stages, and vise versa.
textures/_ratty_terrain/dirt_grass_rock_blend // grass floor, rock wall, dirt transitions
{
qer_editorimage textures/_ratty_terrain/brown_grey_terrain.tga
q3map_baseshader textures/_ratty_terrain/base3
surfaceparm gravelsteps
{
map textures/_ratty_terrain/ratty_dirt_m03.tga // dirt transition
tcgen vector ( 0.00390625 0 0 ) ( 0 0.00390625 0 ) // 256
//rgbgen const ( 0.6 0 0 ) // uncomment to debug
}
{
map textures/_ratty_terrain/ratty_mxrock0b.tga // grass floor
alphafunc ge128
alphagen vertex
}
{
map textures/_ratty_terrain/ratty_cliff_m05dcon.tga // rock wall
alphagen oneminusvertex
alphafunc ge128
}
{
map $lightmap
blendfunc filter
}
}
the green shader is… you guessed it, the grass shader 
textures/_ratty_terrain/grass
{
qer_editorimage textures/_ratty_terrain/green_terrain.tga
q3map_lightmapsampleoffset 16
q3map_lightmapmergable
q3map_shadeangle 178
q3map_tcmod rotate 33
q3map_nonplanar
q3map_forcemeta
q3map_tcgen ivector ( 512 0 0 ) ( 0 512 0 )
surfaceparm grasssteps
{
map textures/stone/mxrock0b.tga
}
{
map $lightmap
blendfunc filter
}
}
note, this isn`t a dotproduct shader as it only needs an image and lightmap stage.
image 254 shows a 2nd darker grey rock shader added to some of the brushes …in game the shaders look very similar, but it`s easier to construct if the qer_editorimages are distinctive.
textures/_ratty_terrain/base6
{
q3map_lightmapsampleoffset 16
q3map_shadeangle 178
q3map_nonplanar
q3map_forcemeta
}
textures/_ratty_terrain/rock2
{
qer_editorimage textures/_ratty_terrain/grey_white_terrain.tga
q3map_baseshader textures/_ratty_terrain/base6
q3map_tcmod rotate -66
q3map_tcgen ivector ( 512 0 0 ) ( 0 512 0 )
surfaceparm grasssteps
{
map textures/_ratty_terrain/ratty_mountain_c06.tga // rock 2 wall
//rgbgen const ( 0 0.6 0.6 ) // uncomment to debug
}
{
map $lightmap
blendfunc filter
}
}
unlike the dirt_rock_blend shader, this rock2 shader doesnt use dotproduct, as I didnt want any dirt showing through this one… but the main difference is the q3map_tcmod rotate -66 as opposed to a value of 33 for the other rock shader.
image 281 shows the ratty_mountain_c06.tga which is was originally one of the rtcw rock tex.
image 282 shows the alpha channel I made for it, which has similar staining to the dirt alpha channel I showed in image 263
image 270 shows a compile of this in game, but with a green rgbgen const to highlight the rock2 shader… you might be able to see that the tex grain on that shader is at a different angle, but dont worry if you cant, because at this distance it`s not very noticeable, even without the green filter.
image 255 shows the rock2 brushes in radiant, which had been cloned and func_group`d into volume blend sections, in the same way as the ones created in chapter 1 of this tutorial.
other then the black shaded brushes on the right, showing another type of blending which I`ll explain latter in another chapter, the only real difference in radiant is the angles of the volume sections are steeper.
but this has no real effect on the volume blending in game, it`s just a little harder to see where to place the alpha brushes, and to edit them.
although using the brush sheering construction method, its quite easy once weve done it a few times… note, only the alpha brushes are sheered, not the actual clones of the rock2 brushes.
here`s the blend shader, the alpha is the same one used in the first chapter.
textures/_ratty_terrain/base1
{
q3map_shadeangle 178
q3map_tcmod rotate -66
q3map_nonplanar
q3map_forcemeta
q3map_nolightmap
surfaceparm nonsolid
surfaceparm nomarks
surfaceparm trans
}
textures/_ratty_terrain/rock_volume_blend
{
qer_editorimage textures/_ratty_terrain/red_grey_terrain.tga
q3map_baseshader textures/_ratty_terrain/base1
q3map_tcgen ivector ( 512 0 0 ) ( 0 512 0 )
//cull disable // uncomment to debug
polygonoffset
{
map textures/_ratty_terrain/ratty_mountain_c06.tga // rock 2
rgbgen vertex
//rgbgen const ( 0.5 0 0 ) // uncomment to debug
alphagen oneminusvertex // inverses the value of the volume alpha
alphafunc ge128
}
}
image 256 shows the volume blend sections overlaid on the original rock brushes.
although in these pics I hadnt covered all the seems between the different rock shaders, as I was still unsure at the time which blend method to use in this map... since then Ive decided to use dithered volume blending on nearly all those rocks, but you can choose which ever method you like best.
image 271 shows the volume blending in game with red colored filters to highlight them …the thin green one on the right is the other blending method, I briefly mentioned earlier.
image 272 shows the same scene with out the colored filtering.
some of you may be thinking this was a lot of work for such a subtle effect, and at times I also thought this… but these pics are taken relatively quite close to the rock face, and from the middle of the map, the effect works well so does it very close up, as there are no hard edges between the different shaders.
at great distances, there is still some tiling patterns visible but they are less obvious then before, and if I had the time and patients, I could have several blend sections of rock all using different tex scales or rotations to further break up the tiling… saying that, 2 different rotations, eg 33 and -66 are fine in this case, especially if I also use fog culling so one side of the map can`t clearly be seen from the other side.
image 274 is a pic from psp7 showing a gamma altered, arthimetic difference filter.
this psp filter creates a new image showing the difference between two other images, in this case the rockface before and after the 2nd rock shader and volume blending was added… note there is a vertical misalignment of a couple of pixels, but that actually helps us as it shows the outline of the hills.
the more colorful, saturated and brighter the pixels, the bigger the difference between the original images.
chapter 3 coming soon.