Graphics Reference
In-Depth Information
struct RuleParams
{
float Chance ;
float Speed ;
/ ￿ optional : further parameters ￿ /
}
;
interface IRule {
MatProperty Apply ( MatProperty mat , RuleParams p );
}
;
class IRust : IRule {
MatProperty Apply ( MatProperty mat , RuleParams p );
{
mat . Rust += min ( mat . Water , mat . Metal ) ￿
p . Speed ;
return mat ;
}
} ;
IRust pRust ;
/ ￿ other rules ￿ /
IRule pRules [ NUM_RULES ]= { pRust , / ￿ other instances ￿ /
}
OUTPUT PS_AgingProcess ( int3 atlasCoord )
{ MatProperty mat = READ_SURFACE_MATERIAL ( atlasCoord );
uint seed = READ_RANDOM_SEED ( atlasCoord );
for ( int r =0; r < NUM_RULES ; r ++)
if ( rnd ( seed ) < g_RuleParameters [ r ]. Chance )
mat = pRules [ r ]. Apply ( mat , g_RuleParameters [ r ]) ;
OUTPUT . Material = mat ;
OUTPUT . RandomSeed = seed ;
}
Listing 3.8. Aging rules are implementions of an interface and are bound using dynamic
shader linkage. Rules are applied at a customizable probability.
source constantly emits water, we want to keep the amount of water in the scene
limited to better control where aging takes place.
Since our material amounts are discretized to 256 steps each, we invoke the
aging rules at a customizable probability to allow for slow corrosion speeds as well.
The therefore required random numbers are generated by a linear congruence
generator, thus the modified random seed is written on output to be input to the
next iteration.
3.3.5 Composition
The composition stage is used to produce aged textures and is implemented in two
subsequent rasterization passes. In the first pass, aged colors, shininess, and the
height map are computed based on the amount of material resting on the ground.
In the second pass, we estimate normals based on the height (see Figure 3.10).
Search WWH ::




Custom Search