BBMOD_Renderer

Extends BBMOD_Class

constructor

new BBMOD_Renderer()

Description

Implements a basic renderer, which executes render commands created with method render. Currently supports two render passes - BBMOD_ERenderPass.Shadows and BBMOD_ERenderPass.Forward.

Properties

Name Description
ButtonSelect The mouse button used to select instances when edit mode is enabled. Default value is mb_left.
EditMode If true then edit mode is enabled. Default value is false.
EnableGBuffer Enables rendering into a G-buffer in the deferred pass. Defaults to false.
EnableMousepick If true then mousepicking of gizmo and instances is enabled. Default value is true.
EnablePostProcessing OBSOLETE Enables post-processing effects. Defaults to false. Enabling this requires the Post-processing submodule!
EnableSSAO Enables screen-space ambient occlusion. This requires the G-buffer. Defaults to false. Enabling this requires the SSAO submodule!
EnableShadows Enables rendering into a shadowmap in the shadows render pass. Defauls to false.
GBufferScale Resolution multiplier for the G-buffer surface. Defaults to 1.
Gizmo A gizmo for transforming instances when BBMOD_Renderer.EditMode is enabled. This is by default undefined.
Height The height of the renderer on the screen. If undefined then the window height is used. Default value is undefined.
InstanceHighlightColor Outline color of instances selected by gizmo. Default value is BBMOD_C_ORANGE.
KeyMultiSelect The keyboard key used to add/remove instances from multiple selection when edit mode is enabled. Default value is vk_shift.
PostProcessor Handles post-processing effects if isn't undefined and BBMOD_Renderer.UseAppSurface is enabled. Default value is undefined.
RenderInstanceIDs If true then rendering of instance IDs into an off-screen surface is enabled. This must be enabled if you would like to use method BBMOD_Renderer.get_instance_id for mouse-picking instances. Default value is false.
RenderScale Resolution multiplier for the application_surface. BBMOD_Renderer.UseAppSurface must be enabled for this to have any effect. Defaults to 1. Use lower values to improve framerate.
Renderables An array of renderable objects and structs. These are automatically rendered in BBMOD_Renderer.render.
SSAOAngleBias SSAO angle bias in radians. Default value is 0.03.
SSAODepthRange Maximum depth difference of SSAO samples. Samples farther away from the origin than this will not contribute to the effect. Default value is 10.
SSAOPower Strength of the SSAO effect. Should be greater than 0. Default value is 1.
SSAORadius Screen-space radius of SSAO. Default value is 16.
SSAOScale Resolution multiplier for SSAO surface. Defaults to 1.
ShadowmapArea OBSOLETE The area captured by the shadowmap. Defaults to 1024.
ShadowmapNormalOffset When rendering shadows, offsets vertex position by its normal scaled by this value. Defaults to 1. Increasing the value can remove some artifacts but using too high value could make the objects appear flying above the ground.
ShadowmapResolution OBSOLETE The resolution of the shadowmap surface. Must be power of 2. Defaults to 4096.
UseAppSurface Set to true to enable the application_surface. Use method BBMOD_Renderer.present to draw the application_surface to the screen. Defaults to false.
Width The width of the renderer on the screen. If undefined then the window width is used. Default value is undefined.
X The X position of the renderer on the screen. Default value is 0.
Y The Y position of the renderer on the screen. Default value is 0.

Methods

Name Description
add Adds a renderable object or struct to the renderer.
get_height Retrieves the height of the renderer on the screen.
get_instance_id Retrieves an ID of an instance at given position on the screen.
get_render_height Retrieves the height of the renderer with BBMOD_Renderer.RenderScale applied.
get_render_width Retrieves the width of the renderer with BBMOD_Renderer.RenderScale applied.
get_width Retrieves the width of the renderer on the screen.
present Presents the rendered graphics on the screen, with post-processing applied (if BBMOD_Renderer.PostProcessor is defined).
remove Removes a renderable object or a struct from the renderer.
render Renders all added renderables to the current render target.
set_position Changes the renderer's position on the screen.
set_rectangle Changes the renderer's position and size on the screen.
set_size Changes the renderer's size on the screen.
update Updates the renderer. This should be called in the Step event.

Example

Following code is a typical use of the renderer.

// Create event
renderer = new BBMOD_Renderer()
    .add(OCharacter)
    .add(OTree)
    .add(OTerrain)
    .add(OSky);
renderer.UseAppSurface = true;
renderer.EnableShadows = true;

camera = new BBMOD_Camera();
camera.FollowObject = OPlayer;

// Step event
camera.set_mouselook(true);
camera.update(delta_time);
renderer.update(delta_time);

// Draw event
camera.apply();
renderer.render();

// Post-Draw event
renderer.present();

// Clean Up event
renderer.destroy();

See also

BBMOD_Camera, BBMOD_IRenderable

Do you find this page helpful?

Copyright © 2022, BlueBurn. Built on November 16, 2022 using GMDoc.