VideoMaterial

A material specialized for rendering spatial videos.

This material supports immersive spatial video experiences by providing essential tools to achieve a variety of visual effects. Additionally, a ShaderGraphMaterial can be attached to apply rendering effects directly to the texture used by VideoMaterial during rendering.

Notes:

  • When a ShaderGraphMaterial is attached, it should be detached once it is no longer needed by the current VideoMaterial. Any previously attached ShaderGraphMaterial will be automatically released unless it has been marked as a global resource via the `.toGlobal()' method as shown in the following example:

val bundle = AssetBundle.load("asset://your_shaderGraphMaterial_name.bundle")
val shaderMat = ShaderGraphMaterial.loadFromAssetBundle(bundle, "relative_path_in_AssetBundle")
shaderMat.toGlobal()
videoMaterial.attachShaderGraphMaterial(shaderMat)
  • Detaching a ShaderGraphMaterial will release it if it is not marked as a global resource. To make a material global, call .toGlobal() like shown in the example above.

See also

Constructors

Link copied to clipboard
constructor(blendingMode: BlendingMode, videoDimensionMode: VideoDimensionMode, cullingMode: MaterialCullingMode, defaultColor: Color4 = Color4.BLACK, onHardwareBufferRelease: HardwareBufferReleaseCallback? = null)
constructor(blendingMode: BlendingMode, videoDimensionMode: VideoDimensionMode, cullingMode: MaterialCullingMode, defaultColor: Color4 = Color4.BLACK)

Functions

Link copied to clipboard
fun attachShaderGraphMaterial(shaderGraphMaterial: ShaderGraphMaterial): Boolean

Attaches a valid ShaderGraphMaterial to the VideoMaterial.

Link copied to clipboard

Bind a SurfaceRenderTexture instance with current video material.

Link copied to clipboard

Detaches the previously attached ShaderGraphMaterial from the VideoMaterial.

Link copied to clipboard

Gets the bind SurfaceRenderTexture of the VideoMaterial.

Link copied to clipboard
Link copied to clipboard
fun getDepthTest(): Boolean

Gets the state of depth testing for the VideoMaterial.

Link copied to clipboard
fun getDepthWrite(): Boolean

Gets the state of depth writing for the VideoMaterial.

Link copied to clipboard
Link copied to clipboard

Gets the attached ShaderGraphMaterial of the VideoMaterial.

Link copied to clipboard
Link copied to clipboard
fun setDepthTest(depthTest: Boolean)

Enables or disables depth testing for the VideoMaterial.

Link copied to clipboard
fun setDepthWrite(depthWrite: Boolean)

Enables or disables depth writing for the VideoMaterial.

Link copied to clipboard
fun setDimensionMode(videoDimensionMode: VideoDimensionMode)
Link copied to clipboard
@RequiresApi(value = 28)
fun setHardwareBuffer(hwBuffer: HardwareBuffer): Boolean

Sets the image HardwareBuffer of the VideoMaterial in the following modes: VideoDimensionMode.MONO, VideoDimensionMode.SIDE_BY_SIDE, and VideoDimensionMode.TOP_AND_DOWN.

@RequiresApi(value = 28)
fun setHardwareBuffer(leftEyeBuffer: HardwareBuffer, rightEyeBuffer: HardwareBuffer): Boolean

Sets the image of the VideoMaterial in VideoDimensionMode.MULTIPLE_VIEW mode.

Link copied to clipboard

Unbind surface render texture with current video material.