RSL
|
IntroductionThis page presents a technique for generating a point cloud that mimics the sinuous distribution of stars embedded within a nebula - figure 1. The shader shown in listing 2 is similiar to the one used to bake a 3D sierpinski gasket.
Because the shader
is used on a single point primitive we can be sure it will only be called once.
For that reason the shader can perform calculations that otherwise would be
prohibitively expensive.
The calculations within the loop are visualized in figures 2 to 5. |
Figure 2 - Random points |
Figure 3 - Points on a sphere |
||||||
Figure 4 - Points in a sphere |
Figure 5 - Output from worley() |
Listing 1 (density.h)
|
Listing 2
|
Bake Pass/Beauty PassListing 3 provides a sample rib file suitable for baking a nebula point cloud. Listing 4 provides a beauty pass sample rib file for rendering the nebula brickmap as geometry. |
Listing 3 (bake pass)
|
Listing 4 (beauty pass)
|
Listing 5 gives the code for a shader that considers the normal of the micro-polygon being shaded to face the incident ray ie. the viewing vector. This ensures that when the brickmap is rendered as geometry all parts of the nebula have equal brightness. It also uses a function that can apply a noisey offset to the normal and, hence, to the brightness of the micro-polygon. Listing 5
|
© 2002- Malcolm Kesson. All rights reserved.