LS.Renderer Class
The Renderer is in charge of generating one frame of the scene. Contains all the passes and intermediate functions to create the frame.
Constructor
LS.Renderer
()
Item Index
Methods
- addRenderQueue
- enableCamera
- fillSceneShaderQuery
- getCameraAtPosition
- getNearLights
- processVisibleData
- registerRenderPass
- render
- renderColorMultiPassLightingInstance
- renderFrame
- renderFrameCameras
- renderInstances
- renderInstancesToRT
- renderMaterialPreview
- renderPickingInstance
- renderShadowPassInstance
- renderToCubemap
- resetGLState
- setRenderPass
Methods
addRenderQueue
-
name
-
sorting
-
options
Adds a new RenderQueue to the Renderer.
Parameters:
-
name
RenderQueuename of the render pass as in render_passes
-
sorting
Numberwhich algorithm use to sort ( LS.RenderQueue.NO_SORT, LS.RenderQueue.SORT_NEAR_TO_FAR, LS.RenderQueue.SORT_FAR_TO_NEAR )
-
options
Objectextra stuff to add to the queue ( like callbacks onStart, onFinish )
Returns:
index of the render queue
enableCamera
-
camera
-
render_settings
Sets camera as the current camera, sets the viewport according to camera info, updates matrices, and prepares LS.Draw
Parameters:
-
camera
Camera -
render_settings
RenderSettings
fillSceneShaderQuery
-
scene
-
render_settings
Update the scene shader query according to the render pass Do not reuse the query, they change between rendering passes (shadows, reflections, etc)
Parameters:
-
scene
SceneTree -
render_settings
RenderSettings
getCameraAtPosition
-
x
-
y
-
scene
Returns the last camera that falls into a given screen position
Parameters:
-
x
Number -
y
Number -
scene
SceneTreeif not specified last rendered scene will be used
Returns:
the camera
getNearLights
-
instance
-
result
returns a list of all the lights overlapping this instance (it uses sperical bounding so it could returns lights that are not really overlapping) It is used by the multipass lighting to iterate
Parameters:
-
instance
RenderInstancethe render instance
-
result
Array[optional] the output array
Returns:
array containing a list of LS.Light affecting this RenderInstance
processVisibleData
-
scene
-
render_settings
-
cameras
Collects and process the rendering instances, cameras and lights that are visible Its a prepass shared among all rendering passes Warning: rendering order is computed here, so it is shared among all the cameras (TO DO, move somewhere else)
Parameters:
-
scene
SceneTree -
render_settings
RenderSettings -
cameras
Arrayin case you dont want to use the scene cameras
registerRenderPass
-
name
-
info
Register a render pass to be used during the rendering
Parameters:
-
name
Stringname of the render pass as in render_passes
-
info
Objectrender pass info, { render_instance: Function( instance, render_settings ) }
render
-
scene
-
render_settings
-
[cameras=null]
Renders the current scene to the screen Many steps are involved, from gathering info from the scene tree, generating shadowmaps, setup FBOs, render every camera If you want to change the rendering pipeline, do not overwrite this function, try to understand it first, otherwise you will miss lots of features
Parameters:
-
scene
SceneTree -
render_settings
RenderSettings -
[cameras=null]
Array optionalif no cameras are specified the cameras are taken from the scene
renderColorMultiPassLightingInstance
-
instance
-
render_settings
-
lights
Renders the RenderInstance taking into account all the lights that affect it and doing a render for every light This function it is not as fast as I would like but enables lots of interesting features
Parameters:
-
instance
RenderInstance -
render_settings
RenderSettings -
lights
Arrayarray containing al the lights affecting this RI
renderFrame
-
camera
-
render_settings
-
scene
renders the view from one camera to the current viewport (could be the screen or a texture)
Parameters:
-
camera
Camera -
render_settings
Object -
scene
SceneTree[optional] this can be passed when we are rendering a different scene from LS.GlobalScene (used in renderMaterialPreview)
renderFrameCameras
-
cameras
-
render_settings
Calls renderFrame of every camera in the cameras list (triggering the appropiate events)
Parameters:
-
cameras
Array -
render_settings
RenderSettings
renderInstances
-
render_settings
-
instances
Calls the render method for every RenderInstance (it also takes into account events and frustrum culling)
Parameters:
-
render_settings
RenderSettings -
instances
Arrayarray of RIs, if not specified the last visible_instances are rendered
renderInstancesToRT
-
cam
-
texture
-
render_settings
Renders a frame into a texture (could be a cubemap, in which case does the six passes)
Parameters:
-
cam
Camera -
texture
Texture -
render_settings
RenderSettings
renderMaterialPreview
-
material
-
size
-
options
-
canvas
Renders the material preview to an image (or to the screen)
Parameters:
-
material
Material -
size
Numberimage size
-
options
Objectcould be environment_texture, to_viewport
-
canvas
HTMLCanvas[optional] the output canvas where to store the preview
Returns:
the preview image (in canvas format) or null if it was rendered to the viewport
renderPickingInstance
-
instance
-
render_settings
Render instance into the picking buffer
Parameters:
-
instance
RenderInstance -
render_settings
RenderSettings
renderShadowPassInstance
-
instance
-
render_settings
Renders this RenderInstance into the shadowmap
Parameters:
-
instance
RenderInstance -
render_settings
RenderSettings
renderToCubemap
-
position
-
size
-
texture
-
render_settings
-
near
-
far
Renders the current scene to a cubemap centered in the given position
Parameters:
-
position
Vec3center of the camera where to render the cubemap
-
size
Numbertexture size
-
texture
Textureto reuse the same texture
-
render_settings
RenderSettings -
near
Number -
far
Number
Returns:
the resulting texture
resetGLState
-
render_settings
To set gl state to a known and constant state in every render pass
Parameters:
-
render_settings
RenderSettings
setRenderPass
-
name
Sets the render pass to use, this allow to change between "color","shadow","picking",etc
Parameters:
-
name
Stringname of the render pass as in render_passes