Section 3 - Shading

In this section:

3.1 Overview of Shading

There are two main types of entities in RenderDude! that determine the appearance of surfaces. Shaders are entities that use geometric information (positions, normals, texture coordinates, etc) and surface material properties (ambient/diffuse/specular colors, etc) to compute surface color and transparency. Textures are entities that can be used to drive the various material properties. Lights are used to light the scene.

The following figure illustrates the hierarchy of shader, texture, and light entities in RenderDude!, as well as the attributes that they provide.

Figure 1: Shader, Texture, and Light entity hierarchies

Interesting shading patterns can be achieved by texturing various shader and texture attributes. For example, the figure below shows a shader network with a phong shader whose diffuse color is mapped to a network of 2 nested checker textures, and whose specular coefficient is mapped to a 3d noise texture (a multiplier for the green specular color). The image shows the result of mapping this texture onto a plane:

NOISE3D {
	name			Noise1
	scale			3 3 3
}

CHECKER2D {
	name			Checker1
	scale			5 5
	color1			1 0 0
	color2			<Checker2>
}

CHECKER2D {
	name			Checker2
	scale			10 10
	rotate			45
	color1			1 1 0
	color2			0 0 1
}

PHONGSHADER {
	name		Phong1
	diffusecoeff	0.4
	diffusecolor	<Checker1>
	specularcoeff	<Noise1>
	specularcolor	0 1 0
	specularexp	5
}

Figure 2: An almost interesting shader network

RenderDude! uses an architecture similar to that of RenderMan for providing geometric information to shaders and textures. A global "sample" structure holds all the geometric information for the current sample, and all shaders and textures obtain whatever geometric information they need from this structure. Texturing and animation of attributes are hidden through a software abstraction, so shaders and textures never need to know whether their attributes are animated or textured when accessing the values of their attributes. For more details on this, see section 7.3, which discusses the attribute architecture.

3.2 Shaders

RenderDude! currently supports 3 types of shaders - FLATSHADER, LAMBERTSHADER, and PHONGSHADER. FLATSHADER ignores all lighting information and colours a surface with a specified colour (which can be textured). LAMBERTSHADER implements a Lambertian (diffuse-only) shading model. This model computes the standard N dot L diffuse component, as well as an ambient component. Multipliers are also provided for the ambient and diffuse components of the shader. PHONGSHADER performs the same ambient and diffuse computation as LAMBERTSHADER, but it also adds in a specular component, defined by a specular color and a specular exponent. A multiplier is also provided for the specular component of the shader. The following image shows 3 spheres, illustrating the 3 shader types.

Figure 3: Flat, Lambert, and Phong shaders

All three shading types have a texturable transparency attribute, but transparency is not taken into account by any of the current rendering algorithms in the system.

3.3 Textures

All RenderDude! textures derive from either TEXTURE2D or TEXTURE3D. 2d textures compute their values based on the (u,v) coordinates of the point being shaded, while 3d textures use the worldspace position of the point being shaded as input. The placement of textures are controlled by scale, translate, and rotate attributes. Together, these three attributes define a transformation that is applied to the texture coordinates before the texture is computed. 3d textures can be parented to other 3d objects in order to lock them onto animated objects.

Currently, the only 2d textures are CHECKER2D and FILETEXTURE2D. CHECKER2D is just a simple 2d checker texture, while FILETEXTURE2D computes colours based on a given image file.

Currently, the only 3d texture in the system is NOISE3D, which is a 3d value noise texture taken from "Texturing and Modelling - A Procedural Approach" by Ebert et al.

The following image shows samples of all the different textures in the system:

Figure 4: Checker, File, and Noise textures

3.4 Lights

Currently, RenderDude! only supports point lights, through the LIGHT entity. A LIGHT has ambient, diffuse, and specular attributes which control its contribution to the corresponding components of the various shading models.