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
-
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
blit
-
source
-
destination
-
shader
-
uniforms
Renders one texture into another texture, it allows to apply a shader
Parameters:
-
source
GL.Texture -
destination
GL.Texture -
shader
GL.Shader[optional] shader to apply, it must use the GL.Shader.QUAD_VERTEX_SHADER as vertex shader
-
uniforms
Object[optional] uniforms for the shader
clearBuffer
-
camera
-
render_settings
clear color using camera info ( background color, viewport scissors, clear depth, etc )
Parameters:
-
camera
Camera -
render_settings
LS.RenderSettings
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
enableFrameShaderBlock
-
shader_block_name
Enables a ShaderBlock ONLY DURING THIS FRAME
Parameters:
-
shader_block_name
String
getCameraAtPosition
-
x
-
y
-
scene
Returns the last camera that falls into a given screen position
Parameters:
-
x
Number -
y
Number -
scene
Sceneif not specified last rendered scene will be used
Returns:
the camera
getCurrentCamera
()
Camera
Returns the camera active
Returns:
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
Scene -
render_settings
RenderSettings -
cameras
Arrayin case you dont want to use the scene cameras
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
Scene -
render_settings
RenderSettings -
[cameras=null]
Array optionalif no cameras are specified the cameras are taken from the scene
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
Scene[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
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