ViewportTexture
Hereda: Texture2D < Texture < Resource < RefCounted < Object
Proporciona el contenido de un Viewport como una textura dinámica.
Descripción
A ViewportTexture provides the content of a Viewport as a dynamic Texture2D. This can be used to combine the rendering of Control, Node2D and Node3D nodes. For example, you can use this texture to display a 3D scene inside a TextureRect, or a 2D overlay in a Sprite3D.
To get a ViewportTexture in code, use the Viewport.get_texture() method on the target viewport.
Note: A ViewportTexture is always local to its scene (see Resource.resource_local_to_scene). If the scene root is not ready, it may return incorrect data (see Node.ready).
Note: Instantiating scenes containing a high-resolution ViewportTexture may cause noticeable stutter.
Note: When using a Viewport with Viewport.use_hdr_2d set to true, the returned texture will be an HDR image that uses linear encoding. This may look darker than normal when displayed directly on screen. To convert to nonlinear sRGB encoding, you can do the following:
img.convert(Image.FORMAT_RGBA8)
img.linear_to_srgb()
Note: Some nodes such as Decal, Light3D, and PointLight2D do not support using ViewportTexture directly. To use texture data from a ViewportTexture in these nodes, you need to create an ImageTexture by calling Texture2D.get_image() on the ViewportTexture and passing the result to ImageTexture.create_from_image(). This conversion is a slow operation, so it should not be performed every frame.
Tutoriales
Propiedades
|
Descripciones de Propiedades
NodePath viewport_path = NodePath("") 🔗
La ruta al nodo Viewport a mostrar. Es relativa a la raíz de la escena local (véase Resource.get_local_scene()), no a los nodos que usan esta textura.
Nota: En el editor, esta ruta se actualiza automáticamente cuando el viewport objetivo o uno de sus ancestros es renombrado o movido. En tiempo de ejecución, esta ruta podría no actualizarse automáticamente si la raíz de la escena no puede ser encontrada.