Table Of Contents

Previous topic

21.11. The DebuggingTools Object

Next topic

21.13. The DeferredRendering Object

This Page

21.12. The DefaultRendering Object

Provides a simple shading solution with a single global point light without falloff.

The DefaultRendering object will request the following shaders to the ShaderManager:

  • shaders/defaultrendering.cgfx
  • shaders/debug.cgfx

These are the effects supported by this renderer:

  • constant
  • lambert
  • blinn
  • phong
  • debug_normals
  • debug_tangents
  • debug_binormals
  • normalmap
  • normalmap_specularmap
  • normalmap_specularmap_alphamap
  • normalmap_alphatest
  • normalmap_specularmap_alphatest
  • normalmap_glowmap
  • normalmap_specularmap_glowmap
  • rxgb_normalmap
  • rxgb_normalmap_specularmap
  • rxgb_normalmap_alphatest
  • rxgb_normalmap_specularmap_alphatest
  • rxgb_normalmap_glowmap
  • rxgb_normalmap_specularmap_glowmap
  • glowmap
  • lightmap
  • add
  • add_particle
  • blend
  • blend_particle
  • translucent
  • translucent_particle
  • filter
  • invfilter
  • invfilter_particle
  • glass
  • glass_env
  • modulate2
  • skybox
  • env
  • flare

The following meta material properties are supported for the scene renderables:

  • transparent

    Non-opaque material that will blend with the background. The renderable will be rendered back to front and will be ignored during lighting calculations. Materials using effects with alpha test enabled but without blending enabled do not need this flag.

  • decal

    Non-opaque material that will blend with the surface immediately below. The renderable will be ignored during lighting calculations. Materials using effects with alpha test enabled but without blending enabled do not need this flag.

  • far

    The renderable will be rendered last if opaque or first if transparent and will be ignored during lighting calculations.

The following TechniqueParameters properties are supported for the scene renderables:

  • materialColor

    Array with 4 numbers providing the material color

  • uvTransform

    Array of 6 numbers forming a 3x2 transformation matrix applied to the uv coordinates

  • diffuse

    Texture that will provide the diffuse color

  • specular_map

    Texture that will provide the specular color

  • normal_map

    Texture that will provide the per pixel normal

  • glow_map

    Texture that will provide the emissive color

  • env_map

    Cubemap texture that will provide the skybox color

  • alpha_map

    Texture that will provide the alpha component

The renderables are rendered in the following passes:

  • opaque
  • decal
  • transparent

Required scripts

The DefaultRendering object requires:

/*{{ javascript("jslib/renderingcommon.js") }}*/
/*{{ javascript("jslib/defaultrendering.js") }}*/

21.12.1. Constructor

21.12.1.1. create

Summary

Syntax

var renderer = DefaultRendering.create(graphicsDevice, mathDevice, shaderManager, effectManager);
graphicsDevice
The GraphicsDevice object to be used.
mathDevice
The MathDevice object used for math calculations.
shaderManager
The ShaderManager object used to load the required shaders.
effectsManager
The EffectsManager object where the effects will be registered.

21.12.2. Method

21.12.2.1. setGlobalLightPosition

Summary

Sets the position in world space of the global point light.

Syntax

var position = mathsDevice.v3Build(100, 500, 100);
renderer.setGlobalLightPosition(position);
position
The global light position as a Vector3 object.

21.12.2.2. setGlobalLightColor

Summary

Sets the color of the global point light.

Syntax

var color = mathDevice.v3Build(1.0, 1.0, 1.0);
renderer.setGlobalLightColor(color);
color
The global light color as a Vector3 object (red, green, blue).

21.12.2.3. setAmbientColor

Summary

Sets the ambient color.

Syntax

var color = mathDevice.v3Build(0.2, 0.2, 0.3);
renderer.setAmbientColor(color);
color
The ambient color as a Vector3 object (red, green, blue).

21.12.2.4. setDefaultTexture

Summary

Set the default texture to be used when a material does not provide one.

Syntax

var texture = textureManager.get('default');
renderer.setDefaultTexture(texture);
texture
A texture object.

21.12.2.5. setWireframe

Summary

Enables or disables rendering of the scene as wireframe.

Syntax

var wireframeInfo = {
    wireColor : mathDevice.v4Build(1, 1, 1, 1),     //choose color for the wireframe lines
    fillColor : mathDevice.v4Build(0, 0.2, 0.6, 0), //choose color for the interior of the polygons
    alphaRef     : 0   //set to greater than zero (e.g. 0.1) to remove the interior of the polygons (transparent fill)
};
renderer.setWireframe(true, wireframeInfo);
wireframeInfo (Optional, default value = { wireColor : mathDevice.v4Build(0, 0, 0, 1), fillColor : mathDevice.v4Build(1, 1, 1, 0), alphaRef : 0.35 })
Used to specify the alpha value, the wireframe line color and the polygon interior color to be used.

Note

For wireframeInfo.fillColor, leave alpha (the fourth value) as zero to allow transparent fill.

21.12.2.6. updateBuffers

Summary

This method does nothing, it is provided for interface compatibility with other renderers.

Syntax

renderer.updateBuffers(graphicsDevice, width, height);

21.12.2.7. updateShader

Summary

This method does nothing, it is provided for interface compatibility with other renderers.

Syntax

renderer.updateShader(shaderManager);

21.12.2.8. update

Summary

Updates light and material information to prepare for rendering.

Syntax

renderer.update(graphicsDevice, camera, scene, currentTime);
graphicsDevice
The GraphicsDevice object used to create the materials required for lighting.
camera
The Camera object used to determine active lights affecting the visible scene.
scene
The Scene object containing the nodes to be rendered.
currentTime
The current time in seconds passed as a global material property to the draw callbacks.

Call this function after the scene and the camera have been updated for the current frame.

21.12.2.9. draw

Summary

Renders the scene.

Syntax

renderer.draw(graphicsDevice,
              clearColor,
              drawDecalsFn,
              drawTransparentFn,
              drawDebugFn);
graphicsDevice
The GraphicsDevice object used for rendering.
clearColor
An array with 4 numbers for the color to be used for the background, it can be set to null.
drawDecalsFn

The callback executed to draw extra visible decals, it can be set to null. For example:

function drawDecalsFn()
{
    fxm.drawDecals(graphicsDevice);
}
drawTransparentFn

The callback executed to draw extra visible transparent objects, it can be set to null. For example:

function drawTransparentFn()
{
    fxm.drawTransparent(graphicsDevice);
}
drawDebugFn

The callback executed to allow the application draw any debugging information required, it can be set to null. For example:

function drawDebugFn()
{
    scene.drawNodesExtents(graphicsDevice, camera);
}

21.12.2.10. getDefaultSkinBufferSize

Get the default size of the buffer used by skinning. This will be undefined until the shaders are loaded.

See also GPUSkinController.

For example:

GPUSkinController.setDefaultBufferSize(renderer.getDefaultSkinBufferSize());

21.12.2.11. destroy

Summary

Releases the DefaultRendering object and all the resources it allocated.

Syntax

renderer.destroy();

21.12.3. Properties

21.12.3.1. version

Summary

The version number of the DefaultRendering implementation.

Syntax

var versionNumber = DefaultRendering.version;

21.12.3.2. passIndex

Summary

A dictionary of passes to passIndex used by DrawParameters to specify the pass they are rendered in.

Valid values are:

  • opaque
  • decal
  • transparent

Syntax

drawParameters.userData.passIndex = renderer.passIndex.transparent;