36 lines
707 B
C#
36 lines
707 B
C#
using UnityEngine;
|
|
|
|
[ExecuteInEditMode]
|
|
public class CopyToScreenRT : MonoBehaviour
|
|
{
|
|
private RenderTexture activeRT;
|
|
|
|
private void OnPostRender()
|
|
{
|
|
if (GetComponent<Camera>().actualRenderingPath == RenderingPath.DeferredShading)
|
|
{
|
|
activeRT = RenderTexture.active;
|
|
}
|
|
else
|
|
{
|
|
activeRT = null;
|
|
}
|
|
}
|
|
|
|
private void OnRenderImage(RenderTexture src, RenderTexture dest)
|
|
{
|
|
if (GetComponent<Camera>().actualRenderingPath == RenderingPath.DeferredShading && (bool)activeRT)
|
|
{
|
|
if (src.format == activeRT.format)
|
|
{
|
|
Graphics.Blit(src, activeRT);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogWarning("Cant resolve texture, because of different formats!");
|
|
}
|
|
}
|
|
Graphics.Blit(src, dest);
|
|
}
|
|
}
|