News Design Artwork Photos Articles
Creative Commons All use of my digital work is covered by this Creative Commons Deed.
Please do not use any of my work for commercial purposes, thank you.
 Terrain Blending (4 of 6) Previous Page Next Page
Broken Blends A custom alpha channel combined with the alpha fade system has one fatal flaw, which can be seen in the middle of the image to the left. The lower part of the image has a close up to show the issue better.

The secondary gravel texture is no longer 100% solid at the blend edges because the alpha fade value is a percentage of the alpha channel value. This means the primary texture switch over underneath is now visible.

Technically the alpha fade system is still working, but only if solid white alpha channel textures are used. This unfortunately does reduce the amount of blending options available for the terrain.
 Are we there yet?    
Sand and Mud Luckily some textures still work well with the secondary blend problem and if the primary textures have a similar base colour (like sand and mud) the switch over underneath the secondary is less obvious.

At this point the alpha fade system can be used successfully if the alpha channels are tweaked to be more 'white' and the primary textures colours are matched together better.

Even after all the different fixes to the textures the problem still exists with the secondary blend edges. The system needs to be able to use high contrast textures and have different types (hard or soft) of blending.
 Primary Blend System    
Primary Blend System To address this problem we need to look at how the material shaders are organized.

The secondary texture is blending across the edge of both material shaders while the primary textures are instantly switching from one to the other with no blending.

With some slight modification to one of the material shaders, a primary texture can be setup to blend at the same time as the secondary texture and fix the visual problem.

The new blending system can be used with either primary texture and will produce different visual results because the blends start and finish at different points.
Primary Blending The image on the left shows that both sides of the terrain are using a different primary texture blend. The left side has the sand blending into the grass while the right is the opposite way around.

At this point the dual blending system can be used successfully with high contrast textures and custom alpha channels. With the extra choice of different primary texture blends, the look of the terrain can be varied.

One problem still remains and that is the primary and secondary blends are the same length and look too linear. The blends need to have different start points so that the textures mix together better.
Click on the above image for a larger version
Below is the material shader for the new primary texture blend system. This is the primary grass texture version displayed on the right of the image above. The alternative sand version on the left is available in the source files for this article.

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20 21
22
23
24
25
26
textures/terblend_soc/tut5_sandgravel { qer_editorimage textures/terblend_soc/ter_sandgravel.tga q3map_tcGen ivector ( 128 0 0 ) ( 0 128 0 ) { map textures/terblend_soc/ter_sand1.tga rgbGen identity } { map textures/terblend_soc/ter_moss2.tga blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA alphaGen Vertex rgbGen identity } { map textures/terblend_soc/ter_gravel1.tga blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA alphaGen vertex rgbGen identity } { map $lightmap blendFunc GL_DST_COLOR GL_ZERO rgbGen identity } }

Lines 9-14 Is the grass primary texture blending on top of the sand primary texture. The secondary texture is then blending on top of both primary textures to create the final mix. This is a four stage material shader and should be used with care because it can cause problems on old hardware that cannot cope with high stage count shaders.

Line 4 The terrain textures are 512 x 512 in size and should use a setting of 256 instead of 128 for the 'q3map_tcGen ivector' command. The lower value makes the textures appear to be double density (0.25 scale in the editor) so they look better for screenshots.

Prev Page Next Page
Mememe
Articles 
Level Design -
GameDev Advice -
Creating Terrain -
Terrain Blending -
Rockwall Corridors -
Rockwall Detail -
2 Point Clipping -
Phong Shading -
3D Puzzle Scripting -
Triggerable Shaders -
RTCW Scripting -
Scripted Doors -
Basic Lift -
Advanced Lift -
Cooking -
Apple Crumble -
This site has been cobbled together by Simon O'Callaghan
Contact Information: Simon O'Callaghan
All content is Copyright © 2000-2024
Hosted by ApisNetwork