Package 

Class View


  • 
    public class View
    
                        

    Encompasses all the state needed for rendering a Scene.

    render operates on View objects. These View objects specify important parameters such as:

    • The Scene
    • The Camera
    • The Viewport
    • Some rendering parameters

    View instances are heavy objects that internally cache a lot of data needed for rendering. It is not advised for an application to use many View objects.

    For example, in a game, a View could be used for the main scene and another one for the game's user interface. More View instances could be used for creating special effects (e.g. a View is akin to a rendering pass).

    • Method Detail

      • setScene

         void setScene(@Nullable() Scene scene)

        Sets this View instance's Scene.

        This method associates the specified Scene with this View. Note that a particular scene canbe associated with several View instances. To remove an existing association, simply passnull.

        The View does not take ownership of the Scene pointer. Before destroying a Scene, be sureto remove it from all assoicated Views.

      • getScene

        @Nullable() Scene getScene()

        Gets this View's associated Scene, or null if none has been assigned.

      • setCamera

         void setCamera(@Nullable() Camera camera)

        Sets this View's Camera.

        This method associates the specified Camera with this View. A Camera can be associated withseveral View instances. To remove an existing association, simply passnull.

        The View does not take ownership of the Scene pointer. Before destroying a Camera, be sureto remove it from all assoicated Views.

      • setViewport

         void setViewport(@NonNull() Viewport viewport)

        Specifies the rectangular rendering area.

        The viewport specifies where the content of the View (i.e. the Scene) is rendered inthe render target. The render target is automatically clipped to the Viewport.

        If you wish subsequent changes to take effect please call this method again in order topropagate the changes down to the native layer.

        Parameters:
        viewport - The Viewport to render the Scene into.
      • setBlendMode

         void setBlendMode(View.BlendMode blendMode)

        Sets the blending mode used to draw the view into the SwapChain.

        Parameters:
        blendMode - either OPAQUE or TRANSLUCENT
      • setVisibleLayers

         void setVisibleLayers(@IntRange(from = 0, to = 255) int select, @IntRange(from = 0, to = 255) int values)

        Sets which layers are visible.

        Renderable objects can have one or several layers associated to them. Layers arerepresented with an 8-bits bitmask, where each bit corresponds to a layer.By default all layers are visible.

        Parameters:
        select - a bitmask specifying which layer to set or clear using values.
        values - a bitmask where each bit sets the visibility of the corresponding layer(1: visible, 0: invisible), only layers in select are affected.
      • setShadowingEnabled

         void setShadowingEnabled(boolean enabled)

        Enables or disables shadow mapping. Enabled by default.

      • setScreenSpaceRefractionEnabled

         void setScreenSpaceRefractionEnabled(boolean enabled)

        Enables or disables screen space refraction. Enabled by default.

        Parameters:
        enabled - true enables screen space refraction, false disables it.
      • setRenderTarget

         void setRenderTarget(@Nullable() RenderTarget target)

        Specifies an offscreen render target to render into.

        By default, the view's associated render target is null, which corresponds to theSwapChain associated with the engine.

        A view with a custom render target cannot rely on Renderer.ClearOptions, which only appliesto the SwapChain. Such view can use a Skybox instead.

        Parameters:
        target - render target associated with view, or null for the swap chain
      • getRenderTarget

        @Nullable() RenderTarget getRenderTarget()

        Gets the offscreen render target associated with this view.Returns null if the render target is the swap chain (which is default).

      • setSampleCount

        @Deprecated() void setSampleCount(int count)

        Sets how many samples are to be used for MSAA in the post-process stage.Default is 1 and disables MSAA.

        Note that anti-aliasing can also be performed in the post-processing stage, generally atlower cost. See the FXAA option in setAntiAliasing.

        Parameters:
        count - number of samples to use for multi-sampled anti-aliasing.
      • getSampleCount

        @Deprecated() int getSampleCount()

        Returns the effective MSAA sample count.

        A value of 0 or 1 means MSAA is disabled.

      • setAntiAliasing

         void setAntiAliasing(@NonNull() View.AntiAliasing type)

        Enables or disables anti-aliasing in the post-processing stage. Enabled by default.

        For MSAA anti-aliasing, see setSampleCount.

        Parameters:
        type - FXAA for enabling, NONE for disabling anti-aliasing.
      • setDithering

         void setDithering(@NonNull() View.Dithering dithering)

        Enables or disables dithering in the post-processing stage. Enabled by default.

        Parameters:
        dithering - dithering type
      • setDynamicResolutionOptions

         void setDynamicResolutionOptions(@NonNull() View.DynamicResolutionOptions options)

        Sets the dynamic resolution options for this view.

        Dynamic resolution options controls whether dynamic resolution is enabled, and if it is,how it behaves.

        If you wish subsequent changes to take effect please call this method again in order topropagate the changes down to the native layer.

        Parameters:
        options - The dynamic resolution options to use on this view
      • setRenderQuality

         void setRenderQuality(@NonNull() View.RenderQuality renderQuality)

        Sets the rendering quality for this view (e.g. color precision).

        Parameters:
        renderQuality - The render quality to use on this view
      • setPostProcessingEnabled

         void setPostProcessingEnabled(boolean enabled)

        Enables or disables post processing. Enabled by default.

        Post-processing includes:

        • Depth-of-field
        • Bloom
        • Vignetting
        • Temporal Anti-aliasing (TAA)
        • Color grading & gamma encoding
        • Dithering
        • FXAA
        • Dynamic scaling

        Disabling post-processing forgoes color correctness as well as some anti-aliasing techniquesand should only be used for debugging, UI overlays or when using custom render targets(see RenderTarget).

        Parameters:
        enabled - true enables post processing, false disables it
      • setFrontFaceWindingInverted

         void setFrontFaceWindingInverted(boolean inverted)

        Inverts the winding order of front faces. By default front faces use a counter-clockwisewinding order. When the winding order is inverted, front faces are faces with a clockwisewinding order.Changing the winding order will directly affect the culling mode in materials(see Material#getCullingMode).Inverting the winding order of front faces is useful when rendering mirrored reflections(water, mirror surfaces, front camera in AR, etc.).

        Parameters:
        inverted - True to invert front faces, false otherwise.
      • setDynamicLightingOptions

         void setDynamicLightingOptions(float zLightNear, float zLightFar)

        Sets options relative to dynamic lighting for this view.

        Together zLightNear and zLightFar must be chosen so that thevisible influence of lights is spread between these two values.

        Parameters:
        zLightNear - Distance from the camera where the lights are expected to shine.This parameter can affect performance and is useful because dependingon the scene, lights that shine close to the camera may not bevisible -- in this case, using a larger value can improve performance.e.g.
        zLightFar - Distance from the camera after which lights are not expected to be visible.Similarly to zLightNear, setting this value properly can improveperformance.
      • setShadowType

         void setShadowType(View.ShadowType type)

        Sets the shadow mapping technique this View uses.The ShadowType affects all the shadows seen within the View.

        VSM imposes a restriction on marking renderables as only shadow receivers(but not casters). To ensure correct shadowing with VSM, all shadow participant renderablesshould be marked as both receivers and casters. Objects that are guaranteed to not castshadows on themselves or other objects (such as flat ground planes) can be set to not castshadows, which might improve shadow quality.

        Warning: This API is still experimental and subject to change.
      • setVsmShadowOptions

         void setVsmShadowOptions(@NonNull() View.VsmShadowOptions options)

        Sets VSM shadowing options that apply across the entire View.Additional light-specific VSM options can be set with shadowOptions.Only applicable when shadow type is set to ShadowType::VSM.Warning: This API is still experimental and subject to change.

        Parameters:
        options - Options for shadowing.
      • setSoftShadowOptions

         void setSoftShadowOptions(@NonNull() View.SoftShadowOptions options)

        Sets soft shadowing options that apply across the entire View.Additional light-specific VSM options can be set with shadowOptions.Only applicable when shadow type is set to ShadowType.DPCF.Warning: This API is still experimental and subject to change.

        Parameters:
        options - Options for shadowing.
      • setStencilBufferEnabled

         void setStencilBufferEnabled(boolean enabled)

        Enables use of the stencil buffer.

        The stencil buffer is an 8-bit, per-fragment unsigned integer stored alongside the depthbuffer. The stencil buffer is cleared at the beginning of a frame and discarded after thecolor pass.

        Each fragment's stencil value is set during rasterization by specifying stencil operations ona Material. The stencil buffer can be used as a mask for later rendering by setting a Material's stencil comparison function and reference value. Fragments that don't passthe stencil test are then discarded.

        Post-processing must be enabled in order to use the stencil buffer.

        A renderable's priority (see setPriority) is useful tocontrol the order in which primitives are drawn.

        Parameters:
        enabled - True to enable the stencil buffer, false disables it (default)
      • pick

         void pick(int x, int y, @Nullable() Object handler, @Nullable() View.OnPickCallback callback)

        Creates a picking query. Multiple queries can be created (e.g.: multi-touch).Picking queries are all executed when render is called on this View.The provided callback is guaranteed to be called at some point in the future.Typically it takes a couple frames to receive the result of a picking query.

        Parameters:
        x - Horizontal coordinate to query in the viewport with origin on the left.
        y - Vertical coordinate to query on the viewport with origin at the bottom.
        handler - An Executor.
        callback - User callback executed by handler when the picking queryresult is available.