Class View
- java.lang.Object
-
- com.google.android.filament.View
-
public class View extends java.lang.ObjectEncompasses all the state needed for rendering aScene.Renderer.render(com.google.android.filament.View)operates onViewobjects. 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).- See Also:
Renderer,Scene,Camera,RenderTarget
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classView.AmbientOcclusionDeprecated.use setAmbientOcclusionOptions insteadstatic classView.AmbientOcclusionOptionsOptions for screen space Ambient Occlusionstatic classView.AntiAliasingList of available post-processing anti-aliasing techniques.static classView.BlendModestatic classView.BloomOptionsOptions for controlling the Bloom effect enabled: Enable or disable the bloom post-processing effect.static classView.DepthOfFieldOptionsOptions to control Depth of Field (DoF) effect in the scenestatic classView.DitheringList of available post-processing dithering techniques.static classView.DynamicResolutionOptionsDynamic resolution can be used to either reach a desired target frame rate by lowering the resolution of aView, or to increase the quality when the rendering is faster than the target frame rate.static classView.FogOptionsOptions to control fog in the scenestatic classView.MultiSampleAntiAliasingOptionsOptions for Multi-sample Anti-aliasing (MSAA)static interfaceView.OnPickCallbackAn interface to implement a custom class to receive results of picking queries.static classView.PickingQueryResultA class containing the result of a picking querystatic classView.QualityLevelGeneric quality level.static classView.RenderQualityStructure used to set the color precision for the rendering of aView.static classView.ScreenSpaceReflectionsOptionsOptions for Screen-space Reflections.static classView.ShadowTypeList of available shadow mapping techniques.static classView.SoftShadowOptionsView-level options for DPCF and PCSS Shadowing.static classView.TargetBufferFlagsUsed to select buffers.static classView.TemporalAntiAliasingOptionsOptions for Temporal Anti-aliasing (TAA)static classView.ToneMappingDeprecated.Use ColorGrading insteadstatic classView.VignetteOptionsOptions to control the vignetting effect.static classView.VsmShadowOptionsView-level options for VSM shadowing.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description View.AmbientOcclusiongetAmbientOcclusion()Deprecated.View.AmbientOcclusionOptionsgetAmbientOcclusionOptions()Gets the ambient occlusion options.View.AntiAliasinggetAntiAliasing()Queries whether anti-aliasing is enabled during the post-processing stage.View.BlendModegetBlendMode()View.BloomOptionsgetBloomOptions()Gets the bloom optionsCameragetCamera()Gets this View's associated Camera, or null if none has been assigned.ColorGradinggetColorGrading()Returns theColorGradingassociated to this view.View.DepthOfFieldOptionsgetDepthOfFieldOptions()Gets the Depth of Field optionsView.DitheringgetDithering()Queries whether dithering is enabled during the post-processing stage.View.DynamicResolutionOptionsgetDynamicResolutionOptions()Returns the dynamic resolution options associated with this view.View.FogOptionsgetFogOptions()Gets the fog optionsView.MultiSampleAntiAliasingOptionsgetMultiSampleAntiAliasingOptions()Returns multi-sample anti-aliasing options.java.lang.StringgetName()Returns the View's name.longgetNativeObject()View.RenderQualitygetRenderQuality()Returns the render quality used by this view.RenderTargetgetRenderTarget()Gets the offscreen render target associated with this view.intgetSampleCount()Deprecated.use getMultiSampleAntiAliasingOptions insteadScenegetScene()Gets this View's associated Scene, or null if none has been assigned.View.ScreenSpaceReflectionsOptionsgetScreenSpaceReflectionsOptions()Returns screen-space reflections options.View.SoftShadowOptionsgetSoftShadowOptions()Gets soft shadowing options associated with this View.View.TemporalAntiAliasingOptionsgetTemporalAntiAliasingOptions()Returns temporal anti-aliasing options.View.ToneMappinggetToneMapping()Deprecated.UsegetColorGrading().ViewportgetViewport()Returns the rectangular rendering area.View.VignetteOptionsgetVignetteOptions()Gets the vignette optionsView.VsmShadowOptionsgetVsmShadowOptions()Gets the VSM shadowing options.booleanisFrontFaceWindingInverted()Returns true if post-processing is enabled.booleanisPostProcessingEnabled()Returns true if post-processing is enabled.voidpick(int x, int y, java.lang.Object handler, View.OnPickCallback callback)Creates a picking query.voidsetAmbientOcclusion(View.AmbientOcclusion ao)Deprecated.voidsetAmbientOcclusionOptions(View.AmbientOcclusionOptions options)Sets ambient occlusion options.voidsetAntiAliasing(View.AntiAliasing type)Enables or disables anti-aliasing in the post-processing stage.voidsetBlendMode(View.BlendMode blendMode)Sets the blending mode used to draw the view into the SwapChain.voidsetBloomOptions(View.BloomOptions options)Sets bloom options.voidsetCamera(Camera camera)Sets this View's Camera.voidsetColorGrading(ColorGrading colorGrading)Sets this View's color grading transforms.voidsetDepthOfFieldOptions(View.DepthOfFieldOptions options)Sets Depth of Field options.voidsetDithering(View.Dithering dithering)Enables or disables dithering in the post-processing stage.voidsetDynamicLightingOptions(float zLightNear, float zLightFar)Sets options relative to dynamic lighting for this view.voidsetDynamicResolutionOptions(View.DynamicResolutionOptions options)Sets the dynamic resolution options for this view.voidsetFogOptions(View.FogOptions options)Sets fog options.voidsetFrontFaceWindingInverted(boolean inverted)Inverts the winding order of front faces.voidsetMultiSampleAntiAliasingOptions(View.MultiSampleAntiAliasingOptions options)Enables or disable multi-sample anti-aliasing (MSAA).voidsetName(java.lang.String name)Sets the View's name.voidsetPostProcessingEnabled(boolean enabled)Enables or disables post processing.voidsetRenderQuality(View.RenderQuality renderQuality)Sets the rendering quality for this view (e.g.voidsetRenderTarget(RenderTarget target)Specifies an offscreen render target to render into.voidsetSampleCount(int count)Deprecated.use setMultiSampleAntiAliasingOptions insteadvoidsetScene(Scene scene)Sets this View instance's Scene.voidsetScreenSpaceReflectionsOptions(View.ScreenSpaceReflectionsOptions options)Enables or disable screen-space reflections.voidsetScreenSpaceRefractionEnabled(boolean enabled)Enables or disables screen space refraction.voidsetShadowingEnabled(boolean enabled)Enables or disables shadow mapping.voidsetShadowType(View.ShadowType type)Sets the shadow mapping technique this View uses.voidsetSoftShadowOptions(View.SoftShadowOptions options)Sets soft shadowing options that apply across the entire View.voidsetTemporalAntiAliasingOptions(View.TemporalAntiAliasingOptions options)Enables or disable temporal anti-aliasing (TAA).voidsetToneMapping(View.ToneMapping type)Deprecated.voidsetViewport(Viewport viewport)Specifies the rectangular rendering area.voidsetVignetteOptions(View.VignetteOptions options)Sets vignette options.voidsetVisibleLayers(int select, int values)Sets which layers are visible.voidsetVsmShadowOptions(View.VsmShadowOptions options)Sets VSM shadowing options that apply across the entire View.
-
-
-
Method Detail
-
setName
public void setName(@NonNull java.lang.String name)Sets the View's name. Only useful for debugging.
-
getName
@Nullable public java.lang.String getName()
Returns the View's name.
-
setScene
public 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 can be associated with several View instances. To remove an existing association, simply pass null.
The View does not take ownership of the Scene pointer. Before destroying a Scene, be sure to remove it from all assoicated Views.
- See Also:
getScene()
-
getScene
@Nullable public Scene getScene()
Gets this View's associated Scene, or null if none has been assigned.
-
setCamera
public void setCamera(@Nullable Camera camera)Sets this View's Camera.This method associates the specified Camera with this View. A Camera can be associated with several View instances. To remove an existing association, simply pass null.
The View does not take ownership of the Scene pointer. Before destroying a Camera, be sure to remove it from all assoicated Views.
- See Also:
getCamera()
-
getCamera
@Nullable public Camera getCamera()
Gets this View's associated Camera, or null if none has been assigned.
-
setViewport
public 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 in the 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 to propagate the changes down to the native layer.
- Parameters:
viewport- The Viewport to render the Scene into.
-
getViewport
@NonNull public Viewport getViewport()
Returns the rectangular rendering area.
-
setBlendMode
public void setBlendMode(View.BlendMode blendMode)
Sets the blending mode used to draw the view into the SwapChain.- Parameters:
blendMode- eitherView.BlendMode.OPAQUEorView.BlendMode.TRANSLUCENT- See Also:
getBlendMode()
-
getBlendMode
public View.BlendMode getBlendMode()
- Returns:
- blending mode set by setBlendMode
- See Also:
setBlendMode(com.google.android.filament.View.BlendMode)
-
setVisibleLayers
public void setVisibleLayers(@IntRange(from=0L,to=255L) int select, @IntRange(from=0L,to=255L) int values)Sets which layers are visible.Renderable objects can have one or several layers associated to them. Layers are represented 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.- See Also:
RenderableManager.setLayerMask(int, int, int)
-
setShadowingEnabled
public void setShadowingEnabled(boolean enabled)
Enables or disables shadow mapping. Enabled by default.
-
setScreenSpaceRefractionEnabled
public void setScreenSpaceRefractionEnabled(boolean enabled)
Enables or disables screen space refraction. Enabled by default.- Parameters:
enabled- true enables screen space refraction, false disables it.
-
setRenderTarget
public 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 the SwapChain associated with the engine.
A view with a custom render target cannot rely on Renderer.ClearOptions, which only applies to the SwapChain. Such view can use a Skybox instead.
- Parameters:
target- render target associated with view, or null for the swap chain
-
getRenderTarget
@Nullable public 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 public void setSampleCount(int count)
Deprecated.use setMultiSampleAntiAliasingOptions insteadSets 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 at lower cost. See the FXAA option in
setAntiAliasing(com.google.android.filament.View.AntiAliasing).- Parameters:
count- number of samples to use for multi-sampled anti-aliasing.
-
getSampleCount
@Deprecated public int getSampleCount()
Deprecated.use getMultiSampleAntiAliasingOptions insteadReturns the effective MSAA sample count.A value of 0 or 1 means MSAA is disabled.
- Returns:
- value set by
setSampleCount(int)
-
setAntiAliasing
public 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(int).- Parameters:
type- FXAA for enabling, NONE for disabling anti-aliasing.
-
getAntiAliasing
@NonNull public View.AntiAliasing getAntiAliasing()
Queries whether anti-aliasing is enabled during the post-processing stage. To query whether MSAA is enabled, seegetSampleCount().- Returns:
- The post-processing anti-aliasing method.
-
setMultiSampleAntiAliasingOptions
public 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 public View.MultiSampleAntiAliasingOptions getMultiSampleAntiAliasingOptions()
Returns multi-sample anti-aliasing options.- Returns:
- multi-sample anti-aliasing options
-
setTemporalAntiAliasingOptions
public void setTemporalAntiAliasingOptions(@NonNull View.TemporalAntiAliasingOptions options)Enables or disable temporal anti-aliasing (TAA). Disabled by default.- Parameters:
options- temporal anti-aliasing options
-
setScreenSpaceReflectionsOptions
public void setScreenSpaceReflectionsOptions(@NonNull View.ScreenSpaceReflectionsOptions options)Enables or disable screen-space reflections. Disabled by default.- Parameters:
options- screen-space reflections options
-
getTemporalAntiAliasingOptions
@NonNull public View.TemporalAntiAliasingOptions getTemporalAntiAliasingOptions()
Returns temporal anti-aliasing options.- Returns:
- temporal anti-aliasing options
-
getScreenSpaceReflectionsOptions
@NonNull public View.ScreenSpaceReflectionsOptions getScreenSpaceReflectionsOptions()
Returns screen-space reflections options.- Returns:
- screen-space reflections options
-
setToneMapping
@Deprecated public void setToneMapping(@NonNull View.ToneMapping type)Deprecated.Enables or disables tone-mapping in the post-processing stage. Enabled by default.- Parameters:
type- Tone-mapping function.
-
getToneMapping
@Deprecated @NonNull public View.ToneMapping getToneMapping()
Deprecated.UsegetColorGrading(). This always returnsView.ToneMapping.ACESReturns the tone-mapping function.- Returns:
- tone-mapping function.
-
setColorGrading
public void setColorGrading(@Nullable ColorGrading colorGrading)Sets this View's color grading transforms.- Parameters:
colorGrading- Associate the specifiedColorGradingto this view. A ColorGrading can be associated to several View instances. Can be null to dissociate the currently set ColorGrading from this View. Doing so will revert to the use of the default color grading transforms.
-
getColorGrading
public ColorGrading getColorGrading()
Returns theColorGradingassociated to this view.- Returns:
- A
ColorGradingor null if the defaultColorGradingis in use
-
setDithering
public void setDithering(@NonNull View.Dithering dithering)Enables or disables dithering in the post-processing stage. Enabled by default.- Parameters:
dithering- dithering type
-
getDithering
@NonNull public View.Dithering getDithering()
Queries whether dithering is enabled during the post-processing stage.- Returns:
- the current dithering type for this view.
-
setDynamicResolutionOptions
public 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 to propagate the changes down to the native layer.
- Parameters:
options- The dynamic resolution options to use on this view
-
getDynamicResolutionOptions
@NonNull public View.DynamicResolutionOptions getDynamicResolutionOptions()
Returns the dynamic resolution options associated with this view.- Returns:
- value set by
setDynamicResolutionOptions(com.google.android.filament.View.DynamicResolutionOptions).
-
setRenderQuality
public 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 public View.RenderQuality getRenderQuality()
Returns the render quality used by this view.- Returns:
- value set by
setRenderQuality(com.google.android.filament.View.RenderQuality).
-
isPostProcessingEnabled
public boolean isPostProcessingEnabled()
Returns true if post-processing is enabled.- See Also:
setPostProcessingEnabled(boolean)
-
setPostProcessingEnabled
public 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 techniques and 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- See Also:
setBloomOptions(com.google.android.filament.View.BloomOptions),setColorGrading(com.google.android.filament.ColorGrading),setAntiAliasing(com.google.android.filament.View.AntiAliasing),setDithering(com.google.android.filament.View.Dithering),setSampleCount(int)
-
isFrontFaceWindingInverted
public boolean isFrontFaceWindingInverted()
Returns true if post-processing is enabled.- See Also:
setPostProcessingEnabled(boolean)
-
setFrontFaceWindingInverted
public void setFrontFaceWindingInverted(boolean inverted)
Inverts the winding order of front faces. By default front faces use a counter-clockwise winding order. When the winding order is inverted, front faces are faces with a clockwise winding 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
public void setDynamicLightingOptions(float zLightNear, float zLightFar)Sets options relative to dynamic lighting for this view.Together
zLightNearandzLightFarmust be chosen so that the visible 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 depending on the scene, lights that shine close to the camera may not be visible -- in this case, using a larger value can improve performance. e.g. when standing and looking straight, several meters of the ground isn't visible and if lights are expected to shine there, there is no point using a short zLightNear. (Default 5m).zLightFar- Distance from the camera after which lights are not expected to be visible. Similarly to zLightNear, setting this value properly can improve performance. (Default 100m).
-
setShadowType
public void setShadowType(View.ShadowType type)
Sets the shadow mapping technique this View uses. The ShadowType affects all the shadows seen within the View.
Warning: This API is still experimental and subject to change.View.ShadowType.VSMimposes a restriction on marking renderables as only shadow receivers (but not casters). To ensure correct shadowing with VSM, all shadow participant renderables should be marked as both receivers and casters. Objects that are guaranteed to not cast shadows on themselves or other objects (such as flat ground planes) can be set to not cast shadows, which might improve shadow quality.
-
setVsmShadowOptions
public void setVsmShadowOptions(@NonNull View.VsmShadowOptions options)Sets VSM shadowing options that apply across the entire View. Additional light-specific VSM options can be set withLightManager.Builder.shadowOptions(com.google.android.filament.LightManager.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.- See Also:
setShadowType(com.google.android.filament.View.ShadowType)
-
getVsmShadowOptions
@NonNull public View.VsmShadowOptions getVsmShadowOptions()
Gets the VSM shadowing options.- Returns:
- VSM shadow options currently set.
- See Also:
setVsmShadowOptions(com.google.android.filament.View.VsmShadowOptions)
-
setSoftShadowOptions
public void setSoftShadowOptions(@NonNull View.SoftShadowOptions options)Sets soft shadowing options that apply across the entire View. Additional light-specific VSM options can be set withLightManager.Builder.shadowOptions(com.google.android.filament.LightManager.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.- See Also:
setShadowType(com.google.android.filament.View.ShadowType)
-
getSoftShadowOptions
@NonNull public View.SoftShadowOptions getSoftShadowOptions()
Gets soft shadowing options associated with this View.- Returns:
- soft shadow options currently set.
- See Also:
setSoftShadowOptions(com.google.android.filament.View.SoftShadowOptions)
-
setAmbientOcclusion
@Deprecated public void setAmbientOcclusion(@NonNull View.AmbientOcclusion ao)Deprecated.Activates or deactivates ambient occlusion.- Parameters:
ao- Type of ambient occlusion to use.- See Also:
setAmbientOcclusionOptions(com.google.android.filament.View.AmbientOcclusionOptions)
-
getAmbientOcclusion
@Deprecated @NonNull public View.AmbientOcclusion getAmbientOcclusion()
Deprecated.Queries the type of ambient occlusion active for this View.- Returns:
- ambient occlusion type.
- See Also:
getAmbientOcclusionOptions()
-
setAmbientOcclusionOptions
public void setAmbientOcclusionOptions(@NonNull View.AmbientOcclusionOptions options)Sets ambient occlusion options.- Parameters:
options- Options for ambient occlusion.
-
getAmbientOcclusionOptions
@NonNull public View.AmbientOcclusionOptions getAmbientOcclusionOptions()
Gets the ambient occlusion options.- Returns:
- ambient occlusion options currently set.
-
setBloomOptions
public void setBloomOptions(@NonNull View.BloomOptions options)Sets bloom options.- Parameters:
options- Options for bloom.- See Also:
getBloomOptions()
-
getBloomOptions
@NonNull public View.BloomOptions getBloomOptions()
Gets the bloom options- Returns:
- bloom options currently set.
- See Also:
setBloomOptions(com.google.android.filament.View.BloomOptions)
-
setVignetteOptions
public void setVignetteOptions(@NonNull View.VignetteOptions options)Sets vignette options.- Parameters:
options- Options for vignetting.- See Also:
getVignetteOptions()
-
getVignetteOptions
@NonNull public View.VignetteOptions getVignetteOptions()
Gets the vignette options- Returns:
- vignetting options currently set.
- See Also:
setVignetteOptions(com.google.android.filament.View.VignetteOptions)
-
setFogOptions
public void setFogOptions(@NonNull View.FogOptions options)Sets fog options.- Parameters:
options- Options for fog.- See Also:
getFogOptions()
-
getFogOptions
@NonNull public View.FogOptions getFogOptions()
Gets the fog options- Returns:
- fog options currently set.
- See Also:
setFogOptions(com.google.android.filament.View.FogOptions)
-
setDepthOfFieldOptions
public void setDepthOfFieldOptions(@NonNull View.DepthOfFieldOptions options)Sets Depth of Field options.- Parameters:
options- Options for depth of field effect.- See Also:
getDepthOfFieldOptions()
-
getDepthOfFieldOptions
@NonNull public View.DepthOfFieldOptions getDepthOfFieldOptions()
Gets the Depth of Field options- Returns:
- Depth of Field options currently set.
- See Also:
setDepthOfFieldOptions(com.google.android.filament.View.DepthOfFieldOptions)
-
pick
public void pick(int x, int y, @Nullable java.lang.Object handler, @Nullable View.OnPickCallback callback)Creates a picking query. Multiple queries can be created (e.g.: multi-touch). Picking queries are all executed whenRenderer.render(com.google.android.filament.View)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- AnExecutor. On Android this can also be aHandler.callback- User callback executed byhandlerwhen the picking query result is available.
-
getNativeObject
public long getNativeObject()
-
-