I created these surface shaders in order to have access to basic illumination models, at least the models that are present in Maya. It was important to me that these shaders were coded so that output variables allowed the user to create different passes for composting purposes. For example, I wanted to create an occlusion pass or a subsurface scattering pass if I wanted. But as I coded these surface shaders, I realised that the number of parameters was growing rapidly, so I felt the need for writing some documentation on how to use them. Here it is.

These shaders have a few parameters unique to their illumination model, and a large part of common parameters. All of the parameters are explained below. These shaders were created and tested with 3Delight, one of the best renderman compliant renderers. They should work with any other renderman compliant renderer. (Note that the relevance of the "specular_3db_rman" shader may depend on the renderer, see below.)

You may use these shaders as reference for your own shaders, or use them in a non-commercial production, in which case you should mention that Bertrand Bry-Marfaing wrote them and that you found them on www.3db-site.com. You may not use them in commercial production without my written approval.

Note to unexperienced users, these files are not compiled (.sl extension) and need to be compiled specifically for your renderer (e.g. shaderdl, for use with 3delight). You can view the code of the .sl by opening them with a text editor. Don't forget to have a look in the .h file, it is where the code common to all 3db shaders resides.

 

Lambert

lambert specularThis illumination model share its diffuse parameters with all the other models. You will find the documentation under the Surface parameters section.

 

 

 

Phong

phong specularspecularColor: the color of the specular illumination.
cosPower: the falloff rate of specular illumination.

 

 

 

Blinn

blinn specularspecularColor: the color of the specular illumination.
eccentricity: the falloff rate of specular illumination.
specularRollOff: the intensity of specular illumination.

 

 

 

Specular

specularNote: this illumination model was based of 3Delight's "specular" shadeop. Its result is a bit different from the above two models. The result will be different with another renderer, and may be identical to the Phong or Blinn models.

specularColor: the color of the specular illumination.
roughness: the falloff rate of specular illumination.

 

Anisotropic

anisotropic specular (v deriv)Note: this model works only for NURBS surface. Strange results may appear on polygonal surfaces.

specularColor: the color of the specular illumination.
specularCoeff: the intensity of specular illumination.
roughness: the falloff rate of specular illumination.
direction: shifts from U (0) to V (1) derivatives.

anisotropic specular (u deriv) anisotropic specular (direction 0.5)

 

Surface parameters

surfaceColor: the color of the surface (Cs). Only works if surfaceColorMap is empty.
surfaceColorMap: the path and name of a color texture that will be mapped on the surface. Note that diffuseCoeff attenuates the intensity of this map.
opacity: opacity of the surface (Os). The opacity may be different for R,G and B. Has no effect on dielectric materials (see Ray tracing parameters).
opacityMap: the path and name of an opacity map.
ambientColor: the color of the surface where lit by ambient illumination.
minColor: the sum of all illumination can't go below minColor. This avoids the presence of pure blacks in case of negative lights or shadow casters.
diffuseCoeff: the intensity of diffuse illumination.
incandescence: the color of the incandescence. None if black.
translucence: the intensity of light that passes through the surface. It differs from refraction because it is not raytraced, and because the shape of the objects behind the surface is lost.
bumpMap: path and name of the texture of the bump map.
bumpCoeff: the intensity of the bump effect.
ContourColor: the color of the contour (as if a rim light was present). None if black.
contourFalloffExponent: the falloff rate of the contour.

diffuse pass specular pass

 

Ray tracing parameters

composite image with reflection and refractionuseRaytrace: indicates if raytracing will be used on this shader (1) or not (0).
raytraceSamples: the number of samples for the raytraced reflection and refraction.
reflectivity: indicates the intensity of raytraced reflections and refractions.
reflectionRefractionBlur: indicates the amount of blurring that will affect the reflections and refractions. Note that blur will increase with distance.
dielectricMaterial: if material is dielectric (1), the reflection and refraction coefficients will be calculated with the fresnel shadeop. In this case, the opacity parameter has no effect, the material will be transparent.
indexOfRefraction: the difference in density of the material and its surrounding.

reflection component only refraction component only

 

Occlusion parameters

occlusion passrecomputeOcclusion: if on (1), occlusion will be (re)calculated. Else, you can specify a texure where previous occlusion calculations were saved, in occlusion_bake_file.
occlusion_baking: if on (1), occlusion will be saved in a texture.
occlusion_bake_file: in what file the occlusion was or will be saved.
bentnormal_baking: if on (1), bent normals will be saved in a texture. Bent normals are automatically calculated when computing occlusion.
bentnormals_bake_file: in what file the bent normals was or will be saved.
occlusionSamples: indicates the number of samples to use for the occlusion.
occlusionMaxDistance: indicates at which distance occlution should stop calculating.
occluionInAmbient: if on (1), the ambient illumination will be scaled with the un-occlusion. Will produce what is typically called ambient-occlusion. You can create a separate pass for the occlusion or bent normals, see Output variables below.
occluionInDiffuse: same as occlusionInAmbient, but with diffuse illumination.
occluionInSpecular: same as occlusionInAmbient, but with specular illumination.
occluionInColorBleeding: same as occlusionInAmbient, but with color bleed.
occluionInEnvMap: same as occlusionInAmbient, but with envmap lookup.

normal pass bent normal pass

Color bleeding parameters

recomputeColorBleeding: if on (1), color bleed will be (re)calculated. Else, you can specify a texure where previous color bleed was saved, in colorBleed_bake_file.
colorBleed_baking: if on (1), color bleeding will be saved in a texture.
colorBleed_bake_file: in what file the color bleed was or will be saved.
colorBleedSamples: indicates the number of samples to use for the color bleeding.
bleedingDirectionality: indicates how wide the sampling cone will be. The higher the number, the narrower the cone will be. A value of 2 will sample a hemisphere. Whith a wide cone you need more samples to obtain smooth results.
colorBleedInPrimaryOutput: if on (1), the color bleed will be mixed in the primary display. You can create a separate pass for the color bleed, see Output variables.

color bleed pass composite image with color bleed

Environment map parameters

envmap passrecomputeEnvMap: if on (1), envmap will be (re)calculated. Else, you can specify a texure where previous envmap was saved, in envmap_bake_file.
envMap: path and name of the texture of the environment map.
envMap_baking: if on (1), envmap will be saved in a texture.
envMap_bake_file: in what file the envmap was or will be saved.
envMapUseBentNormals: if on (1), envmap lookup will use bent normals instead or surface normals. Note that occlusion must be computed or baked for this to work.
envMapSamples: indicates the number of samples to use for the envmap lookup.
envMapBlur: indicates the amount of blurring that will affect the envmap lookup.
envMapInPrimaryOutput: if on (1), the envmap lookup will be mixed in the primary display. You can create a separate pass for the envmap, see Output variables.

 

Subsurface scattering parameters

subsurface scattering passuseSubsurfaceScattering: if on (1), subsurface scattering will be calculated for this surface. Note that geometry attributes must be added in the rib file for this to work.
subsurfaceScatteringInPrimaryOutput: if on (1), the subsurface scattering will be mixed in the primary display. You can create a separate pass for the subsurface scattering, see Output variables.

 

Output variables

These output variables allow for secondary output to provide different types of illumination and different computations separately. The use of these passes can save a lot of time when used in at the compositing stage. Note that you must declare these variables in the rib before calling the secondary displays. These variables are outputed with these shaders:

contour passambientPass
diffusePass
specularPass
translucencePass
reflectionPass
refractionPass
occluionPass
bentNormalPass
colorBleedPass
envMapPass
subsurfacePass
contourPass

 

Maya spotlight

Notes: This basic spotlight was design to integrate with Maya. You can directly connect the parameters of your spotLightShape to the parameters of this shader and the results will be the same. Traditionnaly, there are important differences between renderman spotlight parameters and maya spotlight parameters. For example, the angles are given in radians, not angles, the half angle is required, not the full angle, the cone angle includes the delta angle (named penumbra angle in Maya), etc.

intensity: the intensity of the light source.
lightColor: the color of the light.
coneAngle: the angle of the illumination cone (same as in Maya)
penumbraAngle: the angle, outside of the coneAngle where the intensity decreases.
dropoff: the exponent of decreasing intensity around the light vector.
decay: the exponent of decreasing intensity with the distance.
useRaytracedShadows: if on (1), shadows will be computed with raytracing.
raySamples:number of rays used for raytraced shadows.
shadowMap: path and name of the depth map used to compute the shadow.
shadowBlur: amount of blur for the shadow.
shadowIntensity: multiplier for the shadow.
__nondiffuse: diffuse light contribution of the light source. If 0, diffuse light will be emitted. If 1, no diffuse lght will be emitted.
__nonspecular: same as __nondiffuse, but for specular light.
from: please don't change the default values (0,0,0). Used, with "to" parameter for light vector in object space.
to: please don't change the defulat values (0,0,1).

 

 

 

 

 

- home - curriculum - competences - gallery -MEL scripts - shaders - contact - links -