Class 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.

    • Field Detail

      • environment

        public Environment environment
      • mainLight

        public java.lang.Integer mainLight
    • Constructor Detail

      • Renderer

        @RequiresApi(api=24)
        public Renderer​(android.view.SurfaceView view)
    • 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 specified Surface.
      • stopMirroring

        public void stopMirroring​(android.view.Surface surface)
        Stops mirroring to the specified Surface.
      • 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.
      • 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 scene

        Usually the Sun.

      • setMainLight

        public void setMainLight​(java.lang.Integer light)
        ### Defines the main directional light of the scene

        Usually 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 interface com.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 call isReadyToRender() 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 interface com.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 interface com.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()