Graphics Reference
In-Depth Information
void gammaton_closest_hit ()
{ GammaHitShared & hitshared = HitShared_Out [ prd . ray_index ];
float3 v = ray . direction ￿ prd . speed ; // velocity
float3 phit = ray . origin + t_hit ￿ ray . direction :
float3 pnew = phit + attr_normal ￿ EPSILON ;
// move up
// pick up velocity by fallen distance
float s = length ( pnew ray . origin );
float dt = s / prd . speed ; // time = distance / speed
v += dt
gravity ;
if ( isTooSlow ( v ))
// too slow?
SET_DEAD ( hitshared . flags );
// set inactive
SET_HIT ( hitshared . flags );
// we hit a surface
hitshared . texcoord = attr_texcoord ;
hitshared . velocity = normalize ( v ) ￿ prd . speed ;
// Remember position unti l next launch
GammaHitOptix & gammaState = GammaHitOptixMap [ prd . ray_index ];
gammaState . position = pnew ;
// plant with probability (explained later).
plantletPlacement ( hitshared . randomSeed , pnew , attr_texcoord );
}
Listing 3.3. OptiX/CUDA gammmaton closest hit program. Attributes, e.g.,
attr_normal and attr_texcoord , are passed by the intersection test program.
Numerical considerations of floating particles. We apply a numerical offset to the
gammaton's position to avoid a self-intersection at the launch position. Since a
floating particle moves tangentially to the surface, it virtually hovers above the
surface. To create an intersection in the next iteration we let the ray aim at the
surface by pulling the ray direction along the negated normal by the amount h
(see Figure 3.7). The resulting speed of the floating gammatons depends on both
v t
v t
εn
εn
εn
v
−hn
v
w
(a)
(b)
(c)
Figure 3.7. (a) Apply offset in normal direction to the hit position. (b) Project
the velocity v ( ) into the tangential plane giving v t .(c)Pu l v t in negated normal
direction by the amount of h , which yields a new direction w ( ). [Appeared in [Gunther
et al. 12] and reproduced by kind permission of the Eurographics Association.]
Search WWH ::




Custom Search