Los Image Effects (Efectos de imagen) son una manera de post-procesar una imagen renderizada en Unity.
Cualquier script que tiene una función OnRenderImage puede actuar como un efecto de post-procesamiento – simplemente agréguelo en un objeto camera . La función script va a llevar toda la lógica entera del efecto de imagen.
This script function receives two arguments: source image as a RenderTexture and destination it should render into, as a render texture as well. Typically a postprocessing effect uses Shaders that read the source image, do some calculations on it, and render the result into the provided destination (e.g using Graphics.Blit). It is expected that the image effect will fully replace all pixels of the destination texture.
When multiple postprocessing effects are added on the camera, they are executed in the order they are shown in the inspector, topmost effect being rendered first. Result of one effect is passed as “source image” to the next one; and internally Unity creates one or more temporary render textures to keep these intermediate results in.
Cosas para tener en cuenta:
By default, an image effect is executed after whole scene is rendered. In some cases however, it is desirable to render an effect after all opaque objects are done (but before skybox or transparencies are rendered). Often depth-based effects like Depth of Field use this.
Adding an ImageEffectOpaque
attribute on the OnRenderImage
function allows to achieve that.
Si un efecto de imagen está muestrando diferentes texturas relacionadas a la pantalla una sola vez, usted tendría que estar consciente acerca de las diferencias de plataforma en cómo las coordenadas de textura para estas son utilizadas.
Un escenario común es que la textura “fuente” del efecto y la depth texture (textura de profundidad) de la cámara van a necesitar diferentes coordenadas verticales, dependiendo en los ajustes de anti-aliasing. Ver la página de diferencias en renderizar en plataformas para detalles.
El paquete de Efectos contiene algunas clases bases y de ayuda para basar sus propios efectos de imagen. Todo el código ahí está en el namespace
UnityStandardAssets.ImageEffects`.