3Delight-UserManual

Page 88

Chapter 6: The Shading Language

81

The following example demonstrates how to compute a simple ambient occlusion effect. float occ = 0; uniform numSamples = 20; gather( "illuminance", P, Nf, PI/2, numSamples ) ;/* do nothing ... */ else occ += 1; occ /= numSamples;

environment:environmentname The ‘environment’ category is used to perform importance sampling on a specified environment map. Importance sampling can be used to implemented image based lighting as shown in the ‘envlight2.sl’ shader provided with the 3Delight package. Note that no ray-tracing is performed: importance-sampled rays are returned and it is up to the user to perform ray-tracing if needed. This category unveils three optional parameters (further explained in Section 7.4.4 [Image Based Lighting], page 133):

‘environment:color’ Return the color from the environment map.

‘environment:solidangle’ Returns the sampled solid angle in the environment map. This is the size of the sampled region and is usually inversely proportional to the number of sampled rays - more samples will find finer details in the environment map.

‘environment:direction’ The direction pointing towards the center of the sampled region in the environment map. Note that ‘ray:direction’ holds a randomized direction inside the region and this direction is suitable for sampling.

An example on how to use these variables is shown in Listing 7.5.

pointcloud:pointcloudfile Another special form of the gather() construct can be used to gather points in a previously generated point cloud. This is better illustrated in Example 6.1.


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.