Graphics Reference
In-Depth Information
Figure 1.2. Grass smudging effect.
In reality, grass grows upward but in our case “smudging” the grass downward
simplifies our stencil masking because it allows us to use our original terrain
geometry to generate the stencil mask (in the same pass). To create an upward
smudge, we would need to somehow extend the stencil mask upward.
For our smudge function we used a simple modulated screen-space quantiza-
tion:
float xx = inSPos . x / TDeviceSize [0]. x ;
float yy = inSPos . y / TDeviceSize [0]. y ;
float d = _blend ( len , 0 , 500 , 100 , 500 ) ;
float dclose = _blend ( len ,0, 20, 30,
1);
d ￿ = dclose ;
yy += xx ￿ 1000 / d ;
float
yoffset = frac ( yy ￿ d )/ d ;
The source pixel from inTex0.xy - float2( 0 , yoffset ) is going to be smudged
to the target pixel (output pixel) inTex0.xy , as in Figure 1.2.
With this formula we get a straight vertical grass smudge effect, as in Fig-
ure 1.3.
To break up the regular vertical lines and to add a bit of noise, we change the
modulation to
yy += xx ￿ 1000
However, for some games straight vertical lines may actually be desirable
to achieve a certain visual effect (e.g., Industry Giant 3 uses straight lines; see
Figure 1.4).
Search WWH ::




Custom Search