-
public class ViewEncompasses all the state needed for rendering a Scene.
render operates on
Viewobjects. TheseViewobjects specify important parameters such as:- The Scene
- The Camera
- The Viewport
- Some rendering parameters
Viewinstances 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
Viewcould be used for the main scene and another one for the game's user interface. MoreViewinstances could be used for creating special effects (e.g. aViewis akin to a rendering pass).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumView.ToneMappingList of available tone-mapping operators
public enumView.TargetBufferFlagsUsed to select buffers.
public classView.PickingQueryResultA class containing the result of a picking query
public interfaceView.OnPickCallbackAn interface to implement a custom class to receive results of picking queries.
public enumView.AmbientOcclusionList of available ambient occlusion techniques.
public enumView.QualityLevelGeneric quality level.
public enumView.BlendModepublic classView.DynamicResolutionOptionsDynamic resolution can be used to either reach a desired target frame rateby lowering the resolution of a View, or to increase the quality when therendering is faster than the target frame rate.This structure can be used to specify the minimum scale factor used whenlowering the resolution of a View, and the maximum scale factor used whenincreasing the resolution for higher quality rendering. The scale factorscan be controlled on each X and Y axis independently. By default, all scalefactors are set to 1.0.enabled: enable or disables dynamic resolution on a ViewhomogeneousScaling: by default the system scales the major axis first. Set this to trueto force homogeneous scaling.minScale: the minimum scale in X and Y this View should usemaxScale: the maximum scale in X and Y this View should usequality: upscaling quality.LOW: 1 bilinear tap, Medium: 4 bilinear taps, High: 9 bilinear taps (tent)\noteDynamic resolution is only supported on platforms where the time to rendera frame can be measured accurately. Dynamic resolution is currently onlysupported on Android.
public classView.BloomOptionsOptions to control the bloom effectenabled: Enable or disable the bloom post-processing effect. Disabled by default.levels: Number of successive blurs to achieve the blur effect, the minimum is 3 and themaximum is 12. This value together with resolution influences the spread of theblur effect. This value can be silently reduced to accommodate the originalimage size.resolution: Resolution of bloom's minor axis. The minimum value is 2^levels and thethe maximum is lower of the original resolution and 4096. This parameter issilently clamped to the minimum and maximum.It is highly recommended that this value be smaller than the target resolutionafter dynamic resolution is applied (horizontally and vertically).strength: how much of the bloom is added to the original image. Between 0 and 1.blendMode: Whether the bloom effect is purely additive (false) or mixed with the originalimage (true).anamorphism: Bloom's aspect ratio (x/y), for artistic purposes.threshold: When enabled, a threshold at 1.0 is applied on the source image, this isuseful for artistic reasons and is usually needed when a dirt texture is used.dirt: A dirt/scratch/smudges texture (that can be RGB), which gets added to thebloom effect. Smudges are visible where bloom occurs. Threshold must beenabled for the dirt effect to work properly.dirtStrength: Strength of the dirt texture.
public classView.FogOptionsOptions to control large-scale fog in the scene
public classView.DepthOfFieldOptionsOptions to control Depth of Field (DoF) effect in the scene.cocScale can be used to set the depth of field blur independently from the cameraaperture, e.g. for artistic reasons. This can be achieved by setting:cocScale = cameraAperture / desiredDoFAperture
public classView.VignetteOptionsOptions to control the vignetting effect.
public classView.RenderQualityStructure used to set the precision of the color buffer and related quality settings.
public classView.AmbientOcclusionOptionsOptions for screen space Ambient Occlusion (SSAO) and Screen Space Cone Tracing (SSCT)
public classView.MultiSampleAntiAliasingOptionsOptions for Temporal Multi-Sample Anti-aliasing (MSAA)
public classView.TemporalAntiAliasingOptionsOptions for Temporal Anti-aliasing (TAA)
public classView.ScreenSpaceReflectionsOptionsOptions for Screen-space Reflections.
public classView.GuardBandOptionsOptions for the screen-space guard band.A guard band can be enabled to avoid some artifacts towards the edge of the screen whenusing screen-space effects such as SSAO. Enabling the guard band reduces performance slightly.Currently the guard band can only be enabled or disabled.
public enumView.AntiAliasingList of available post-processing anti-aliasing techniques.
public enumView.DitheringList of available post-processing dithering techniques.
public enumView.ShadowTypeList of available shadow mapping techniques.
public classView.VsmShadowOptionsView-level options for VSM Shadowing.
public classView.SoftShadowOptionsView-level options for DPCF and PCSS Shadowing.
-
Method Summary
Modifier and Type Method Description voidsetName(@NonNull() String name)Sets the View's name. StringgetName()Returns the View's name. voidsetScene(@Nullable() Scene scene)Sets this View instance's Scene. ScenegetScene()Gets this View's associated Scene, or null if none has been assigned. voidsetCamera(@Nullable() Camera camera)Sets this View's Camera. CameragetCamera()Gets this View's associated Camera, or null if none has been assigned. voidsetViewport(@NonNull() Viewport viewport)Specifies the rectangular rendering area. ViewportgetViewport()Returns the rectangular rendering area. voidsetBlendMode(View.BlendMode blendMode)Sets the blending mode used to draw the view into the SwapChain. View.BlendModegetBlendMode()voidsetVisibleLayers(@IntRange(from = 0, to = 255) int select, @IntRange(from = 0, to = 255) int values)Sets which layers are visible. voidsetShadowingEnabled(boolean enabled)Enables or disables shadow mapping. voidsetScreenSpaceRefractionEnabled(boolean enabled)Enables or disables screen space refraction. voidsetRenderTarget(@Nullable() RenderTarget target)Specifies an offscreen render target to render into. RenderTargetgetRenderTarget()Gets the offscreen render target associated with this view.Returns null if the render target is the swap chain (which is default). voidsetSampleCount(int count)Sets how many samples are to be used for MSAA in the post-process stage.Default is 1 and disables MSAA. intgetSampleCount()Returns the effective MSAA sample count. voidsetAntiAliasing(@NonNull() View.AntiAliasing type)Enables or disables anti-aliasing in the post-processing stage. View.AntiAliasinggetAntiAliasing()Queries whether anti-aliasing is enabled during the post-processing stage. voidsetMultiSampleAntiAliasingOptions(@NonNull() View.MultiSampleAntiAliasingOptions options)Enables or disable multi-sample anti-aliasing (MSAA). View.MultiSampleAntiAliasingOptionsgetMultiSampleAntiAliasingOptions()Returns multi-sample anti-aliasing options. voidsetTemporalAntiAliasingOptions(@NonNull() View.TemporalAntiAliasingOptions options)Enables or disable temporal anti-aliasing (TAA). View.TemporalAntiAliasingOptionsgetTemporalAntiAliasingOptions()Returns temporal anti-aliasing options. voidsetScreenSpaceReflectionsOptions(@NonNull() View.ScreenSpaceReflectionsOptions options)Enables or disable screen-space reflections. View.ScreenSpaceReflectionsOptionsgetScreenSpaceReflectionsOptions()Returns screen-space reflections options. voidsetGuardBandOptions(@NonNull() View.GuardBandOptions options)Enables or disable screen-space guard band. View.GuardBandOptionsgetGuardBandOptions()Returns screen-space guard band options. voidsetToneMapping(@NonNull() View.ToneMapping type)Enables or disables tone-mapping in the post-processing stage. View.ToneMappinggetToneMapping()Returns the tone-mapping function. voidsetColorGrading(@Nullable() ColorGrading colorGrading)Sets this View's color grading transforms. ColorGradinggetColorGrading()Returns the ColorGrading associated to this view. voidsetDithering(@NonNull() View.Dithering dithering)Enables or disables dithering in the post-processing stage. View.DitheringgetDithering()Queries whether dithering is enabled during the post-processing stage. voidsetDynamicResolutionOptions(@NonNull() View.DynamicResolutionOptions options)Sets the dynamic resolution options for this view. View.DynamicResolutionOptionsgetDynamicResolutionOptions()Returns the dynamic resolution options associated with this view. voidsetRenderQuality(@NonNull() View.RenderQuality renderQuality)Sets the rendering quality for this view (e.g. View.RenderQualitygetRenderQuality()Returns the render quality used by this view. booleanisPostProcessingEnabled()Returns true if post-processing is enabled. voidsetPostProcessingEnabled(boolean enabled)Enables or disables post processing. booleanisFrontFaceWindingInverted()Returns true if post-processing is enabled. voidsetFrontFaceWindingInverted(boolean inverted)Inverts the winding order of front faces. voidsetDynamicLightingOptions(float zLightNear, float zLightFar)Sets options relative to dynamic lighting for this view. voidsetShadowType(View.ShadowType type)Sets the shadow mapping technique this View uses.The ShadowType affects all the shadows seen within the View. voidsetVsmShadowOptions(@NonNull() View.VsmShadowOptions options)Sets VSM shadowing options that apply across the entire View. View.VsmShadowOptionsgetVsmShadowOptions()Gets the VSM shadowing options. voidsetSoftShadowOptions(@NonNull() View.SoftShadowOptions options)Sets soft shadowing options that apply across the entire View. View.SoftShadowOptionsgetSoftShadowOptions()Gets soft shadowing options associated with this View. voidsetAmbientOcclusion(@NonNull() View.AmbientOcclusion ao)Activates or deactivates ambient occlusion. View.AmbientOcclusiongetAmbientOcclusion()Queries the type of ambient occlusion active for this View. voidsetAmbientOcclusionOptions(@NonNull() View.AmbientOcclusionOptions options)Sets ambient occlusion options. View.AmbientOcclusionOptionsgetAmbientOcclusionOptions()Gets the ambient occlusion options. voidsetBloomOptions(@NonNull() View.BloomOptions options)Sets bloom options. View.BloomOptionsgetBloomOptions()Gets the bloom options voidsetVignetteOptions(@NonNull() View.VignetteOptions options)Sets vignette options. View.VignetteOptionsgetVignetteOptions()Gets the vignette options voidsetFogOptions(@NonNull() View.FogOptions options)Sets fog options. View.FogOptionsgetFogOptions()Gets the fog options voidsetDepthOfFieldOptions(@NonNull() View.DepthOfFieldOptions options)Sets Depth of Field options. View.DepthOfFieldOptionsgetDepthOfFieldOptions()Gets the Depth of Field options voidsetStencilBufferEnabled(boolean enabled)Enables use of the stencil buffer. booleanisStencilBufferEnabled()voidpick(int x, int y, @Nullable() Object handler, @Nullable() View.OnPickCallback callback)Creates a picking query. longgetNativeObject()-
-
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.
-
getCamera
@Nullable() Camera getCamera()
Gets this View's associated Camera, or null if none has been assigned.
-
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.
-
getViewport
@NonNull() Viewport getViewport()
Returns the rectangular rendering area.
-
setBlendMode
void setBlendMode(View.BlendMode blendMode)
Sets the blending mode used to draw the view into the SwapChain.
- Parameters:
blendMode- either OPAQUE or TRANSLUCENT
-
getBlendMode
View.BlendMode getBlendMode()
-
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 usingvalues.values- a bitmask where each bit sets the visibility of the corresponding layer(1: visible, 0: invisible), only layers inselectare 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.
-
getAntiAliasing
@NonNull() View.AntiAliasing getAntiAliasing()
Queries whether anti-aliasing is enabled during the post-processing stage. To querywhether MSAA is enabled, see getSampleCount.
-
setMultiSampleAntiAliasingOptions
void setMultiSampleAntiAliasingOptions(@NonNull() View.MultiSampleAntiAliasingOptions options)
Enables or disable multi-sample anti-aliasing (MSAA). Disabled by default.
- Parameters:
options- multi-sample anti-aliasing options
-
getMultiSampleAntiAliasingOptions
@NonNull() View.MultiSampleAntiAliasingOptions getMultiSampleAntiAliasingOptions()
Returns multi-sample anti-aliasing options.
-
setTemporalAntiAliasingOptions
void setTemporalAntiAliasingOptions(@NonNull() View.TemporalAntiAliasingOptions options)
Enables or disable temporal anti-aliasing (TAA). Disabled by default.
- Parameters:
options- temporal anti-aliasing options
-
getTemporalAntiAliasingOptions
@NonNull() View.TemporalAntiAliasingOptions getTemporalAntiAliasingOptions()
Returns temporal anti-aliasing options.
-
setScreenSpaceReflectionsOptions
void setScreenSpaceReflectionsOptions(@NonNull() View.ScreenSpaceReflectionsOptions options)
Enables or disable screen-space reflections. Disabled by default.
- Parameters:
options- screen-space reflections options
-
getScreenSpaceReflectionsOptions
@NonNull() View.ScreenSpaceReflectionsOptions getScreenSpaceReflectionsOptions()
Returns screen-space reflections options.
-
setGuardBandOptions
void setGuardBandOptions(@NonNull() View.GuardBandOptions options)
Enables or disable screen-space guard band. Disabled by default.
- Parameters:
options- guard band options
-
getGuardBandOptions
@NonNull() View.GuardBandOptions getGuardBandOptions()
Returns screen-space guard band options.
-
setToneMapping
@Deprecated() void setToneMapping(@NonNull() View.ToneMapping type)
Enables or disables tone-mapping in the post-processing stage. Enabled by default.
- Parameters:
type- Tone-mapping function.
-
getToneMapping
@Deprecated()@NonNull() View.ToneMapping getToneMapping()
Returns the tone-mapping function.
-
setColorGrading
void setColorGrading(@Nullable() ColorGrading colorGrading)
Sets this View's color grading transforms.
- Parameters:
colorGrading- Associate the specified ColorGrading to this view.
-
getColorGrading
ColorGrading getColorGrading()
Returns the ColorGrading associated to this view.
-
setDithering
void setDithering(@NonNull() View.Dithering dithering)
Enables or disables dithering in the post-processing stage. Enabled by default.
- Parameters:
dithering- dithering type
-
getDithering
@NonNull() View.Dithering getDithering()
Queries whether dithering is enabled during the post-processing stage.
-
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
-
getDynamicResolutionOptions
@NonNull() View.DynamicResolutionOptions getDynamicResolutionOptions()
Returns the dynamic resolution options associated with 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
-
getRenderQuality
@NonNull() View.RenderQuality getRenderQuality()
Returns the render quality used by this view.
-
isPostProcessingEnabled
boolean isPostProcessingEnabled()
Returns true if post-processing is enabled.
-
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
-
isFrontFaceWindingInverted
boolean isFrontFaceWindingInverted()
Returns true if post-processing is enabled.
-
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
zLightNearandzLightFarmust 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.
-
getVsmShadowOptions
@NonNull() View.VsmShadowOptions getVsmShadowOptions()
Gets the VSM shadowing options.
-
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.
-
getSoftShadowOptions
@NonNull() View.SoftShadowOptions getSoftShadowOptions()
Gets soft shadowing options associated with this View.
-
setAmbientOcclusion
@Deprecated() void setAmbientOcclusion(@NonNull() View.AmbientOcclusion ao)
Activates or deactivates ambient occlusion.
- Parameters:
ao- Type of ambient occlusion to use.
-
getAmbientOcclusion
@Deprecated()@NonNull() View.AmbientOcclusion getAmbientOcclusion()
Queries the type of ambient occlusion active for this View.
-
setAmbientOcclusionOptions
void setAmbientOcclusionOptions(@NonNull() View.AmbientOcclusionOptions options)
Sets ambient occlusion options.
- Parameters:
options- Options for ambient occlusion.
-
getAmbientOcclusionOptions
@NonNull() View.AmbientOcclusionOptions getAmbientOcclusionOptions()
Gets the ambient occlusion options.
-
setBloomOptions
void setBloomOptions(@NonNull() View.BloomOptions options)
Sets bloom options.
- Parameters:
options- Options for bloom.
-
getBloomOptions
@NonNull() View.BloomOptions getBloomOptions()
Gets the bloom options
-
setVignetteOptions
void setVignetteOptions(@NonNull() View.VignetteOptions options)
Sets vignette options.
- Parameters:
options- Options for vignetting.
-
getVignetteOptions
@NonNull() View.VignetteOptions getVignetteOptions()
Gets the vignette options
-
setFogOptions
void setFogOptions(@NonNull() View.FogOptions options)
Sets fog options.
- Parameters:
options- Options for fog.
-
getFogOptions
@NonNull() View.FogOptions getFogOptions()
Gets the fog options
-
setDepthOfFieldOptions
void setDepthOfFieldOptions(@NonNull() View.DepthOfFieldOptions options)
Sets Depth of Field options.
- Parameters:
options- Options for depth of field effect.
-
getDepthOfFieldOptions
@NonNull() View.DepthOfFieldOptions getDepthOfFieldOptions()
Gets the Depth of Field options
-
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)
-
isStencilBufferEnabled
boolean isStencilBufferEnabled()
-
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 byhandlerwhen the picking queryresult is available.
-
getNativeObject
long getNativeObject()
-
-
-
-