[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.5.4 Lighting and Ray Tracing

color ambient ( )
Returns the contribution from ambient lights. A light is considered ambient if it does not contain an illuminate() or solar() statement.

color diffuse ( vector Nr )
Computes the diffuse light contribution. Lights placed behind the surface element being shaded are not considered. Nr is assumed to be of unit length. Light shaders that contain a parameter named uniform float __nondiffuse will ony be evaluated if the parameter is set to 0.

color specular ( vector Nr, V; float roughness ) *
Computes the specular light contribution. Lights placed behind the object are not considered. Nr and V are assumed to be of unit length. Light shaders that contain a parameter named uniform float __nonspecular will ony be evaluated if the parameter is set to 0.

color specularbrdf ( vector L, Nr, V; float roughness )
Computes the specular light contribution. Similar to specular() but receives a L variable (incoming light vector) enabling it to run in custom illuminance() loops.

color specularstd ( normal N; vector V; float roughness)
Since 3Delight implements its own specular model in specular, we provide this function in case you need the standard specular model described in all graphic books. specularstd() is implemented as follows:
 
color specularstd( normal N; vector V; float roughness )
{
    extern point P;
    color C = 0;
    point Nn = normalize(N);
    point Vn = normalize(V);

    illuminance(P, Nn, PI/2)
    {
        extern vector L;
        extern color Cl;

        vector H = normalize(normalize(L)+Vn);
        C += Cl * pow(max(0.0, Nn.H), 1/roughness);
    }

    return C;
}

color phong ( vector Nr, V; float size )
Computes specular light contribution using the Phong illumination model. Nr and V are assumed to be of unit length. As in specular(), this function is also sensitive to the __nonspecular light shader parameter.

color trace ( point Pt; vector R [; output float dist] ) *
Returns color of light arriving to Pt from direction R. This is accomplished by tracing a ray from position Pt in direction specified R. Only objects tagged as visible to reflection rays will be considered during the operation (using Attribute "visibility" "trace", section 4.2 Attributes). If the optional dist parameter is specified, it will contain the distance to the intersection point or a very large number (> 1e30) if no intersections found. Note that Pt and R must lie in `current' space.

float trace ( point Pt; vector R )
Returns distance to the nearest object, when looking from Pt in the direction specified by the unit vector R. This function may be substancially faster than the color version of trace() since it might avoid costly shading operations. Pt and R must lie in `current' space.

color transmission ( point Pt1, Pt2 )(19)
Determines the visibility between Pt1 and Pt2 using ray tracing. Returns color 1 if unoccluded and color 0 if totally occluded. Inbetween values indicate the presence of a translucent surface between Pt1 and Pt2. Only objects tagged as visible to transmission/shadow rays will be considered during the operation (using Attribute "visibility" "transmission", section 4.2 Attributes). Pt1 and Pt2 must lie in `current' space.

float occlusion ( point Pt; vector R; [float samples;] ... ) *
Computes the amount of occlusion, using ray tracing, as seen from Pt in direction R and solid angle 2*PI (hemisphere). Returns 1.0 if all rays hit an object (totally occluded) and 0.0 if no hits (totally unoccluded). The optional samples parameter specifies the number of rays to trace to compute occlusion; if absent or set to 0, 3Delight will use Attribute "irradiance" "nsamples", see section 4.2 Attributes. occlusion() accepts optional token/value pairs, those are explained in the table below. Pt and R must lie in `current' space.

EXAMPLE
 
/* Returns the amount of occlusion using default number of
   samples */
float hemi_occ = occlusion( P, Ng );

/* Returns the amount of occlusion for the hemisphere surrounding P,
   uses a rough approximation with 8 samples */
hemi_occ = occlusion( P, Ng, 8 );

/* Same as above, but only consider objects closer than 10 units and
   in a solid angle of Pi/2
*/
hemi_occ = occlusion( P, Ng, 8, "maxdist", 10, "angle", PI/4 );

/* Same as above, but only consider light coming from an hemisphere
   oriented toward (0,1,0)
*/
uniform vector sky = vector (0, 1, 0);
hemi_occ =
    occlusion( P, Ng, 8, "maxdist", 10, "angle", PI/4, "axis", sky );

float indirectdiffuse ( point Pt; vector R; [float samples;] ... ) *
Computes diffuse illumination arising from diffuse-to-diffuse indirect light transport by sampling an hemisphere around some point Pt and direction R(20). Use this shadeop to render "color bleeding" effects. Also, this function makes it possible to lookup into an HDR image when sampled rays do not hit any geometry; the map is specified using the "environmentmap" parameter as shown in the table below. Computing the occlusion while calling this function is also possible (through the occlusion parameter), with the following two restrictions: Pt and R must lie in `current' space.

Name Type Default Description
"angle" uniform float PI/2 Controls the solid angle considered, default covers the entire hemisphere;
"axis" uniform vector -- If specified, and different from vector 0, indicates the direction of the light casting hemisphere. Rays that are not directed toward this axis will not be considered. This is useful for specifying skylights. This has not effect on indirect diffusion computations, only occlusion() shadeop uses this parameter. axis doesn't have to be of unit length;
"bias" uniform float 0.01 Bias to add when intersecting surfaces to avoid precision related self-intersections. Default value taken from Attribute "trace" "bias", see section 4.2 Attributes;
"maxdist" uniform float 1e38 Only consider intersections closer than this distance;
"environmentmap" uniform string "" Specifies an environment map to lookup when a sampled ray doesn't hit any geometry. Only available in the indirectdiffuse() shadeop;
"environmentdir" output varying vector -- If specified, will be set to the averange un-occluded direction, which is the average of all sampled directions that did not hit any geometry. Note that this vector is defined in `current' space, so it is necessary to transform it to `world' space if an environment() lookup is intended.

occlusion() and indirectdiffuse() optional parameters.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Aghiles Kheffache on July, 31 2003 using texi2html
3Delight 1.0.0. Copyright 2000-2003 The 3Delight Team. All Rights Reserved.