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.RendererCallbackA rendering context.Contains everything that will be drawn on a surface.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceRenderer.PreRenderCallback
-
Field Summary
Fields Modifier and Type Field Description Environmentenvironmentjava.lang.IntegermainLight
-
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 voidaddEntity(int entity)voidaddLight(int entity)static voiddestroyAllResources()Immediately releases all rendering resources, even if in use.voiddispose()voidenablePerformanceMode()Sets a high performance configuration for the filament view.com.google.android.filament.CameragetCamera()Retrieve the Filament camera used by the rendererandroid.content.ContextgetContext()intgetDesiredHeight()intgetDesiredWidth()EnvironmentgetEnvironment()### Get the lighting environment and the skybox of the scenecom.google.android.filament.RenderergetFilamentRenderer()Access to the underlying Filament renderer.com.google.android.filament.ScenegetFilamentScene()com.google.android.filament.ViewgetFilamentView()Access to the underlying Filament view.java.lang.IntegergetMainLight()### Get the main directional light of the sceneandroid.view.SurfaceViewgetSurfaceView()booleanisFrontFaceWindingInverted()Checks whether winding is inverted for front face rendering.voidonDetachedFromSurface()Called when the surface is going away.voidonNativeWindowChanged(android.view.Surface surface)Called when the underlying native window has changed.voidonPause()voidonResized(int width, int height)Called when the underlying native window has been resized.voidonResume()static longreclaimReleasedResources()Releases rendering resources ready for garbage collectionvoidremoveEntity(int entity)voidremoveLight(int entity)voidrender(long frameTimeNanos, boolean debugEnabled)voidsetAntiAliasing(com.google.android.filament.View.AntiAliasing antiAliasing)voidsetCameraProvider(CameraProvider cameraProvider)voidsetClearColor(Color color)voidsetDefaultClearColor()voidsetDesiredSize(int width, int height)voidsetDithering(com.google.android.filament.View.Dithering dithering)voidsetDynamicResolutionEnabled(boolean isEnabled)voidsetEnvironment(Environment environment)### Defines the lighting environment and the skybox of the scenevoidsetFrameRenderDebugCallback(java.lang.Runnable onFrameRenderDebugCallback)Sets a callback to happen after each frame is rendered.voidsetFrontFaceWindingInverted(java.lang.Boolean inverted)Inverts winding for front face rendering.voidsetIndirectLight(com.google.android.filament.IndirectLight indirectLight)Sets the environment light used for reflections and indirect light.voidsetMainLight(java.lang.Integer light)### Defines the main directional light of the scenevoidsetPostProcessingEnabled(boolean enablePostProcessing)voidsetPreRenderCallback(Renderer.PreRenderCallback preRenderCallback)voidsetRenderQuality(com.google.android.filament.View.RenderQuality renderQuality)voidsetSkybox(com.google.android.filament.Skybox skybox)Sets the Skybox.voidstartMirroring(android.view.Surface surface, int left, int bottom, int width, int height)Starts mirroring to the specifiedSurface.voidstopMirroring(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.RendererCallbackCalled when the underlying native window has changed.- Specified by:
onNativeWindowChangedin interfacecom.google.android.filament.android.UiHelper.RendererCallback
-
onDetachedFromSurface
public void onDetachedFromSurface()
Description copied from interface:com.google.android.filament.android.UiHelper.RendererCallbackCalled 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:
onDetachedFromSurfacein 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.RendererCallbackCalled when the underlying native window has been resized.- Specified by:
onResizedin 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()
-
-