Graphics Reference
In-Depth Information
[ maxvertexcount (1)]
void GS_GammatonUpdate ( point GammaHitShared input [1] ,
inout PointStream < GammaHitShared > PntStream )
{ GammaHitShared output = input [0];
if ( IS_MIDAIR ( input [0]. Flags )
||
IS_DEAD ( input [0]. Flags ))
{
PntStream . Append ( output );
// no need to act
return ;
// get material at surface and gammaton
float4 surfMat = g_TexMatCur . SampleLevel (
g_Linear , gammaton . texcoord ,0);
float4 gammaMat = unpackFromUint ( gammaton . carriedMaterial );
// calculate transfer rates and update material
gammaMat += transferRate ( surfMat , gammaMat );
gammaMat = saturate ( gammaMat ); // clamp
gammaton . carriedMaterial = packToUint ( gammaMat );
float roulette = rnd ( output . Seed ); // random value in [ 0.. 1)
if ( roulette < g_BounceProbability ) {
SET_BOUNCE ( output . Flags ); // set bounce
PhongLobeBounce ( output ); // handles bounce
} else if ( roulette < g_BounceProbability + g_FloatProbability )
{
SET_FLOAT ( output . Flags );
// set float
PhongLobeBounce ( output );
// handles float
} else SET_DEAD ( output . Flags );
// absorb
PntStream . Append ( output );
}
Listing 3.7. Geometry shader, used in the transform feedback loop to update both the
gammaton material and the rebound direction. For simplicity, this listing shows the
update of four materials. Note that both bouncing and floating gammatons are handled
by the PhongLobeBounce method, depending on the value of output.Flags .
Rust. Thefirstrulecorrodesmetalinthepresenceofwater. Welimitthecor-
rosion speed by the rarer material. Therefore, we set the strength of the rust
generation to the minimum of the amount of water and metal, as shown in List-
ing 3.8. An additional speed parameter provides user control to adjust aging
processes relative to one another, e.g., to accommodate that corrosion is slower
than lichen growth. Finally, the created amount of rust is added to the already
existing rust on the surface.
Decay. The second rule is used to produce organic material and dirt. Here, the
amount of created material depends on the currently present water and wood.
The implementation is similar to the previous rule, with the difference that two
materials are generated instead of one.
Evaporation. We added an additional rule that evaporates water over time; in
part to model the phenomenon but also for a practical reason: as a gammaton
Search WWH ::




Custom Search