Class Renderer
- java.lang.Object
-
- com.google.ar.sceneform.rendering.Renderer
-
- All Implemented Interfaces:
com.google.android.filament.android.UiHelper.RendererCallback
public class Renderer extends java.lang.Object implements com.google.android.filament.android.UiHelper.RendererCallback
A rendering context.Contains everything that will be drawn on a surface.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Renderer.PreRenderCallback
-
Field Summary
Fields Modifier and Type Field Description Environment
environment
java.lang.Integer
mainLight
-
Constructor Summary
Constructors Constructor Description Renderer(android.view.SurfaceView view)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEntity(int entity)
void
addLight(int entity)
static void
destroyAllResources()
Immediately releases all rendering resources, even if in use.void
dispose()
void
enablePerformanceMode()
Sets a high performance configuration for the filament view.com.google.android.filament.Camera
getCamera()
Retrieve the Filament camera used by the rendererandroid.content.Context
getContext()
int
getDesiredHeight()
int
getDesiredWidth()
Environment
getEnvironment()
### Get the lighting environment and the skybox of the scenecom.google.android.filament.Renderer
getFilamentRenderer()
Access to the underlying Filament renderer.com.google.android.filament.Scene
getFilamentScene()
com.google.android.filament.View
getFilamentView()
Access to the underlying Filament view.java.lang.Integer
getMainLight()
### Get the main directional light of the sceneandroid.view.SurfaceView
getSurfaceView()
boolean
isFrontFaceWindingInverted()
Checks whether winding is inverted for front face rendering.void
onDetachedFromSurface()
Called when the surface is going away.void
onNativeWindowChanged(android.view.Surface surface)
Called when the underlying native window has changed.void
onPause()
void
onResized(int width, int height)
Called when the underlying native window has been resized.void
onResume()
static long
reclaimReleasedResources()
Releases rendering resources ready for garbage collectionvoid
removeEntity(int entity)
void
removeLight(int entity)
void
render(long frameTimeNanos, boolean debugEnabled)
void
setAntiAliasing(com.google.android.filament.View.AntiAliasing antiAliasing)
void
setCameraProvider(CameraProvider cameraProvider)
void
setClearColor(Color color)
void
setDefaultClearColor()
void
setDesiredSize(int width, int height)
void
setDithering(com.google.android.filament.View.Dithering dithering)
void
setDynamicResolutionEnabled(boolean isEnabled)
void
setEnvironment(Environment environment)
### Defines the lighting environment and the skybox of the scenevoid
setFrameRenderDebugCallback(java.lang.Runnable onFrameRenderDebugCallback)
Sets a callback to happen after each frame is rendered.void
setFrontFaceWindingInverted(java.lang.Boolean inverted)
Inverts winding for front face rendering.void
setIndirectLight(com.google.android.filament.IndirectLight indirectLight)
Sets the environment light used for reflections and indirect light.void
setMainLight(java.lang.Integer light)
### Defines the main directional light of the scenevoid
setPostProcessingEnabled(boolean enablePostProcessing)
void
setPreRenderCallback(Renderer.PreRenderCallback preRenderCallback)
void
setRenderQuality(com.google.android.filament.View.RenderQuality renderQuality)
void
setSkybox(com.google.android.filament.Skybox skybox)
Sets the Skybox.void
startMirroring(android.view.Surface surface, int left, int bottom, int width, int height)
Starts mirroring to the specifiedSurface
.void
stopMirroring(android.view.Surface surface)
Stops mirroring to the specifiedSurface
.
-
-
-
Method Detail
-
reclaimReleasedResources
public static long reclaimReleasedResources()
Releases rendering resources ready for garbage collection- Returns:
- Count of resources currently in use
-
destroyAllResources
public static void destroyAllResources()
Immediately releases all rendering resources, even if in use.
-
startMirroring
public void startMirroring(android.view.Surface surface, int left, int bottom, int width, int height)
Starts mirroring to the specifiedSurface
.
-
stopMirroring
public void stopMirroring(android.view.Surface surface)
Stops mirroring to the specifiedSurface
.
-
getFilamentRenderer
public com.google.android.filament.Renderer getFilamentRenderer()
Access to the underlying Filament renderer.
-
getFilamentView
public com.google.android.filament.View getFilamentView()
Access to the underlying Filament view.
-
getSurfaceView
public android.view.SurfaceView getSurfaceView()
-
setClearColor
public void setClearColor(Color color)
-
setDefaultClearColor
public void setDefaultClearColor()
-
isFrontFaceWindingInverted
public boolean isFrontFaceWindingInverted()
Checks whether winding is inverted for front face rendering.
-
setFrontFaceWindingInverted
public void setFrontFaceWindingInverted(java.lang.Boolean inverted)
Inverts winding for front face rendering.
-
setCameraProvider
public void setCameraProvider(@Nullable CameraProvider cameraProvider)
-
onPause
public void onPause()
-
onResume
public void onResume()
-
setFrameRenderDebugCallback
public void setFrameRenderDebugCallback(java.lang.Runnable onFrameRenderDebugCallback)
Sets a callback to happen after each frame is rendered. This can be used to log performance metrics for a given frame.
-
setPreRenderCallback
public void setPreRenderCallback(@Nullable Renderer.PreRenderCallback preRenderCallback)
-
render
public void render(long frameTimeNanos, boolean debugEnabled)
-
dispose
public void dispose()
-
getContext
public android.content.Context getContext()
-
getCamera
public com.google.android.filament.Camera getCamera()
Retrieve the Filament camera used by the renderer
-
getEnvironment
public Environment getEnvironment()
### Get the lighting environment and the skybox of the scene
-
setEnvironment
public void setEnvironment(Environment environment)
### Defines the lighting environment and the skybox of the scene
-
getMainLight
public java.lang.Integer getMainLight()
### Get the main directional light of the sceneUsually the Sun.
-
setMainLight
public void setMainLight(java.lang.Integer light)
### Defines the main directional light of the sceneUsually the Sun.
-
setIndirectLight
public void setIndirectLight(com.google.android.filament.IndirectLight indirectLight)
Sets the environment light used for reflections and indirect light.- Parameters:
indirectLight
- the IndirectLight to use when rendering the Scene or null to unset.
-
setSkybox
public void setSkybox(com.google.android.filament.Skybox skybox)
Sets the Skybox. The Skybox is drawn last and covers all pixels not touched by geometry.- Parameters:
skybox
- – the Skybox to use to fill untouched pixels, or null to unset the Skybox.
-
setDesiredSize
public void setDesiredSize(int width, int height)
-
getDesiredWidth
public int getDesiredWidth()
-
getDesiredHeight
public int getDesiredHeight()
-
onNativeWindowChanged
public void onNativeWindowChanged(android.view.Surface surface)
Description copied from interface:com.google.android.filament.android.UiHelper.RendererCallback
Called when the underlying native window has changed.- Specified by:
onNativeWindowChanged
in interfacecom.google.android.filament.android.UiHelper.RendererCallback
-
onDetachedFromSurface
public void onDetachedFromSurface()
Description copied from interface:com.google.android.filament.android.UiHelper.RendererCallback
Called when the surface is going away. After this callisReadyToRender()
returns false. You MUST have stopped drawing when returning. This is called from detach() or if the surface disappears on its own.- Specified by:
onDetachedFromSurface
in interfacecom.google.android.filament.android.UiHelper.RendererCallback
-
setDynamicResolutionEnabled
public void setDynamicResolutionEnabled(boolean isEnabled)
-
setAntiAliasing
public void setAntiAliasing(com.google.android.filament.View.AntiAliasing antiAliasing)
-
setDithering
public void setDithering(com.google.android.filament.View.Dithering dithering)
-
setPostProcessingEnabled
public void setPostProcessingEnabled(boolean enablePostProcessing)
-
setRenderQuality
public void setRenderQuality(com.google.android.filament.View.RenderQuality renderQuality)
-
enablePerformanceMode
public void enablePerformanceMode()
Sets a high performance configuration for the filament view. Disables MSAA, disables post-process, disables dynamic resolution, sets quality to 'low'.
-
onResized
public void onResized(int width, int height)
Description copied from interface:com.google.android.filament.android.UiHelper.RendererCallback
Called when the underlying native window has been resized.- Specified by:
onResized
in interfacecom.google.android.filament.android.UiHelper.RendererCallback
-
addEntity
public void addEntity(int entity)
-
removeEntity
public void removeEntity(int entity)
-
addLight
public void addLight(int entity)
-
removeLight
public void removeLight(int entity)
-
getFilamentScene
@NonNull public com.google.android.filament.Scene getFilamentScene()
-
-