Guest User

LightingRenderTexture.cs

a guest
Feb 1st, 2020
276
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. [ExecuteInEditMode]
  5. public class LightingRenderTexture : MonoBehaviour
  6. {
  7.     [SerializeField]
  8.     Material ScreenMat;
  9.     [SerializeField]
  10.     Camera lightingCam;
  11.  
  12.     RenderTexture rt;
  13.     private void Start()
  14.     {
  15.         rt = new RenderTexture(Screen.width, Screen.height, 24);
  16.         lightingCam.targetTexture = rt;
  17.         ScreenMat.SetTexture("_RenderTexture", rt);
  18.     }
  19.     void OnRenderImage(RenderTexture src, RenderTexture dst)
  20.     {
  21.         if (ScreenMat != null)
  22.             Graphics.Blit(src, dst, ScreenMat);
  23.     }
  24.  
  25.  
  26. }
RAW Paste Data