Click to go Home  
 
REALSOFT 3D
About
History
News
Screenshots
Articles
Render times
User Profiles
Newsletters
LEARNING
Tutorials
Reviews
Glossary
Beginners
Links
DATABASE
Models
Macros / Scripts
Materials / VSL
Environments
Plugins
RENDERS
User images
Image Contest
Realsoft images
VRgrafix images
EX IMAGE:
Mech Turtle
By David Coombs, 2002
 
glossary

The RealSoft3D ray-tracing process - Part 2: Shaders

By David Coombes
d.g.coombes@btopenworld.com

Foreword to Part 2

In writing this next part, I have found a need to introduce extra clarity to the different concepts of RealSoft3D's ray-tracing process. It is not difficult to get mixed up with the ideas of shaders, samples and channels when reading similar names. Thanks to the wonders of modern technology I will be able to employ a new convention using colour to distinguish these different concepts. I will identify:
 

      1. Shaders in Bold Navy text
      2. Samples in Standard Green text
      3. Channels in Italic Maroon text, preceded by a green sample name. e.g. Surface:Color

The Story so far

Part 1 finished with an overview of the RealSoft3D rendering process.  This can be represented as such...

Surface Properties
Initialised

Lighting calculations add
surface illumination to
 surface's
Illumination
channel

Surface's Illumination
channel copied to
image's
Color
channel

Output pixel's color
calculated from image's
C
olor channel

The actual rendering process is subdivided into multiple steps; each step is called a Shader. This can be confusing for users of other 3D software where shader is usually a term meaning a material, and indeed this same term is used in the RealSoft3D community to describe VSL materials. For the rest of this explanation, Shader refers solely to each step of the rendering pipeline.

The Shaders

A rendered scene is made of several components, these being geometry Surfaces, Illumination from light sources, Volume effects such as fog, Reflections and Refractions, and several ancilliaries. The data for these components is stored in collections of channels, these collections being termed samples. As such, there is a color channel for surface, illumination, volume etc. held in surface, light and volume samples. RealSoft3D has these seven samples...

      • Light sample
      • Surface sample
      • Surface filter sample
      • Particle sample
      • Ray hit sample
      • Volume sample
      • Volume filter sample

There is an eigth sample available only in Post Processing, the image sample that contains all the final rendering information.

Channels are identified by preceeding each channel with the sample it belongs to. A surface's colour value is stored in Surface:Color. A light source's color value is stored in Light:Color. The final image pixel colour information is stored in Image:Color. The evaluation of these different components occurs in separate shaders. The list of RealSoft3D shaders is

      • Material initialization
      • Common properties
      • Surface geometry
      • Surface properties
      • Volume properties
      • Light properties
      • Surface filtering
      • Volume filtering
      • Surface illumination
      • Surface finishing
      • Volume illumination
      • Volume shading
      • Secondary ray
      • Ray hit
      • Ray termination
      • Scanline
      • Post particles
      • Image processing

Each shader deals with data from one or more samples. The shaders governing surface rendering access the Surface sample, and likewise the shaders that generate volume effects access the Volume shader.

Surface shaders

Forming the "backbone" of the rendering process are the shaders pertaining to surfaces. The surface shaders are where most of your custom effects will probably be applied. The more fundamental surface shaders are listed below.
 

Surface Shader

Activities of Shader



    Surface
    Geometry

 
This is where modifications to the surface normal are made. The primary use of this is to simulate a bumped surface by introducing variation to the angle of the surface relative to cast rays. The value contained in Surface:Bump Height is used by RealSoft3D's internal renderer to create relevant bump distortions. Additionally the value of Surface:Bump Height is used in displacement mapping of SDS and NURBS objects.



    Surface
    Properties


The most important step in most materials, surface properties defines the basic characteristics of a material. It is the usual place to modify Surface:Color, Surface:Reflectivity, Surface:Transparency, and to add additional base lighting to the surface's illumination in Surface:Illumination.



    Surface
    Illumination

 
The surface illumination shader is called when the effect of light from a light source is calculated. It makes available the properties of the light through the illumination channels. Most importantly, the value of the light (colour * intensity * transparency of objects between light source and surface) is available in Light:Illumination and the direction of the light ray is available as a vector from Light:Ray.
After this shader is completed, the default calculations of RealSoft3D add to the Surface:Illumination channel the amount of illumination as a result of the light source. It is also possible to modify all the other values of the Surface channels. For example, if the light is coming from a certain direction, change the colour of the surface.



    Surface
    Finishing


A new feature introduced in RealSoft3D version 4.5 is the surface finishing shader. This provides a final step for processing values, most importantly those of illumination as this step follows on from the surface illumination shader. A simple step here might be to process Surface:Illumination by a curve providing for balance/contrast/gamma changes for individual objects.

That's the back-bone of the rendering process covered. You can see how data in the surface sample gets chugged along each of the shaders, with values getting modified and used as they go. In the beginning, the illumination of the surface is (0,0,0). Surface geometry adds bumps in the Surface:Bump Height channel of the Surface sample; Surface properties adds some excitement, such as texture maps or procedural colour changes to Surface:Color; Surface illumination takes the values of the other surface channels and computes the lighting, adding this value to Surface:Illumination; Surface finishing gives a last place to modify this data. Surface:Illumination is then copied to Image:Color to give the pixel colour of the image at the beginning of post-processing.

Light processing shaders

Most light processing shaders are invoked by the surface illumination shader. As the light rays are traced from light source to surface, two to four different shaders use the data in the Light sample.
 

Illumination Shader
in order of execution


Activities of Shader
 



    Light
    Properties 

 
This shader is always invoked and defines the properties of the light. Usually light properties such as colour are set-up in the object's properties window and the light properties shader is rarely used.
It is the place to add a colour mapping to directional lights as a projection.



    Surface
    Filter


On its way to a surface, if a light ray intersects another surface it is "filtered". This is the process of casting shadows by reducing the intensity of light relative to the transparency of the interceeding surfaces. The value of the intersecting surface's transparency, Surface:Transparency, is copied to the surface filter sample's Filter:Transparency channel. In the surface filter shader, the value Light:Illumination is multiplied by Filter:Transparency. A Filter:Transparency value of default (0,0,0) means a Light:Illumination value of (0,0,0) or no light. A Filter:Transparency value of yellow (1,1,0) means only green and red light components are transmitted.
Surface filter is not used when the light ray is direct.



    Volume
    Filter 

 
Volume filter does the same job as surface filtering for transparent volumes. It works in the same way, only using VFilter:Transparency to hold a value for the colour filtering of the volume. VFilter:Transparency is initialised to the value of Surface:Transparency.
Within this shader, other volume properties (defined in Volume and copied to VFilter) can be used to change VFilter:Transparency to create, for example, shadows with density linked to volume density.
Volume filter is not used if there is no filtering volume. ie. Volume sampling is less then 1.



    Surface
    Illumination


The surface illumination shader uses the data in the Light sample to computer surface illumination.

Shader execution - data access

With these two collections of shaders we can start to piece together a thorough view of the whole process. The following diagram shows the use of the samples in the different shaders, and the flow of data shows the order of execution of the shaders. The samples are colour-coded. Note that there is only one set of each sample. Although Surface is shown six times, it exists as a single entity accessed by multiple shaders. Surface is a repository of data passed from one shader to the next.

The large arrows for internal data processing show where RealSoft3D executes default shading procedures, resulting in a change in one sample's channel data as a function of another sample's data. The most obvious example is Surface Illumination where Surface:Illumination is modified as a function of Light:Illumination. An important point to note is when this processing occurs. The default RealSoft3D shading procedures are executed when the shader is finished, prior to entering the next shader. When using VSL code to create a custom shading routine, your VSL code is executed first and the default routines follow as a final step. If adding a custom illumination effect to Surface:Illumination such as adding 0.5 to the red channel, this occurs before any default lighting has been applied.

Still to come

Up to now this RealSoft3D ray-tracing process document has been quite heavy on theory. Before going on to include the full range of shaders and samples, part 3 will focus on real-world use of this knowledge, generate a little practical experience, and hopefully show why it's important to understand all this if your going to make the most of RealSoft3D.

Page updated on Tuesday, 25 February, 2003 . For feedback / model submissions or articles - please email us.
Site proudly sponsored by VR.grafix
Goto Sponsors Site (VRgrafix)