| Submitted by , posted on 21 May 2003 |

Image Description, by This is the latest project in my game engine. The terrain is using split-only ROAM, and geometry part using Vertex Shader 1.1 to doing geo-morphing to prevent pop-ups. The most exciting feature of this terrain engine is the texturing technique. I used Pixel Shader 1.4 to do texture shading, with 3 textures. First one is 8 bits terrain color with pre-blended light map, 1024x1024, 256 colors.
- Second one is 32 bits detail opacity maps, 1024x1024, R8G8B8A8 format
- Third is 32 bits detail maps, 128x128, R8G8B8A8 format. The unusual part for the textures is in each channel of the second and third textures ( r, g, b, a ) there are four different greyscale detail maps. The R color in opacity map is the blend weight of the R color in detail map, G, B, A are 2nd, 3rd and 4th detail maps respectively.
  The first and second maps are sampled using u1, v1, which are from 0.0f to 1.0f, and generated in Vertex Shader Third map is sampled using u2, v2 which are tiled 128 times of u1, v1.
  In rendering, 3 texture fetches are required:
  texld r0, t0
  texld r1, t0
  texld r2, t1
  r0 is sampled color from Base color map, r1 is opacity values, and r2 is detail maps. After sampling, scale detail color value by opacity color value:
  mul r3, r1, r2
  Then here comes the tricky part, I added r,g,b,a values in r3 together to represent the brightness of that point
  add r4.r, r3.r, r3.g
  add r4.g, r3.b, r3.a
  add r4.a, r4.r, r4.g
  Because Pixel Shader 1.x didn't support register component swizzle, I had to spend 3 instructions to do the add If using Pixel Shader 2.0, these three instructions above can be combined to two:
  add r4.rg, r3.rb, r3.ga
  add r4.a, r4.r, r4.g
  Then output the final color by multiply base color by detail brightness.
  mul r0, r0_x2, r4.a
  The advantage of this technique is obvious: It only needs 3 texture fetches to achieve 1 base color and 4 detail textures.
  So any question or discussion please e-mail to: edstudios@hotmail.com

[prev] | Image of the Day Gallery www.flipcode.com | [next]

Copyright 1999-2008 (C) FLIPCODE.COM and/or the original content author(s). All rights reserved.
Please read our Terms, Conditions, and Privacy information.