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:
-
nameRenderQueuename of the render pass as in render_passes
-
sortingNumberwhich algorithm use to sort ( LS.RenderQueue.NO_SORT, LS.RenderQueue.SORT_NEAR_TO_FAR, LS.RenderQueue.SORT_FAR_TO_NEAR )
-
optionsObjectextra 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:
-
sourceGL.Texture -
destinationGL.Texture -
shaderGL.Shader[optional] shader to apply, it must use the GL.Shader.QUAD_VERTEX_SHADER as vertex shader
-
uniformsObject[optional] uniforms for the shader
clearBuffer
-
camera -
render_settings
clear color using camera info ( background color, viewport scissors, clear depth, etc )
Parameters:
-
cameraCamera -
render_settingsLS.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:
-
cameraCamera -
render_settingsRenderSettings
enableFrameShaderBlock
-
shader_block_name
Enables a ShaderBlock ONLY DURING THIS FRAME
Parameters:
-
shader_block_nameString
getCameraAtPosition
-
x -
y -
scene
Returns the last camera that falls into a given screen position
Parameters:
-
xNumber -
yNumber -
sceneSceneif 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:
-
instanceRenderInstancethe render instance
-
resultArray[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:
-
sceneScene -
render_settingsRenderSettings -
camerasArrayin 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:
-
sceneScene -
render_settingsRenderSettings -
[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:
-
cameraCamera -
render_settingsObject -
sceneScene[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:
-
camerasArray -
render_settingsRenderSettings
renderInstances
-
render_settings -
instances
Calls the render method for every RenderInstance (it also takes into account events and frustrum culling)
Parameters:
-
render_settingsRenderSettings -
instancesArrayarray 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:
-
camCamera -
textureTexture -
render_settingsRenderSettings
renderMaterialPreview
-
material -
size -
options -
canvas
Renders the material preview to an image (or to the screen)
Parameters:
-
materialMaterial -
sizeNumberimage size
-
optionsObjectcould be environment_texture, to_viewport
-
canvasHTMLCanvas[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:
-
positionVec3center of the camera where to render the cubemap
-
sizeNumbertexture size
-
textureTextureto reuse the same texture
-
render_settingsRenderSettings -
nearNumber -
farNumber
Returns:
the resulting texture
resetGLState
-
render_settings
To set gl state to a known and constant state in every render pass
Parameters:
-
render_settingsRenderSettings
