post processing
[WindSway-HDRP.git] / Library / PackageCache / com.unity.render-pipelines.high-definition@4.10.0-preview / Runtime / Core / Textures / RTHandleSystem.RTHandle.cs
blob04ba675e738b4f6b1047de8d0ea243a625d71618
1 using System.Collections.Generic;
2 using UnityEngine.Rendering;
4 namespace UnityEngine.Experimental.Rendering
6 public partial class RTHandleSystem
8 public class RTHandle
10 internal RTHandleSystem m_Owner;
11 internal RenderTexture m_RT;
12 internal RenderTargetIdentifier m_NameID;
13 internal bool m_EnableMSAA = false;
14 internal bool m_EnableRandomWrite = false;
15 internal string m_Name;
17 internal Vector2 scaleFactor = Vector2.one;
18 internal ScaleFunc scaleFunc;
20 public bool useScaling { get; internal set; }
21 public Vector2Int referenceSize {get; internal set; }
23 public RenderTexture rt
25 get
27 return m_RT;
31 public RenderTargetIdentifier nameID
33 get
35 return m_NameID;
39 // Keep constructor private
40 internal RTHandle(RTHandleSystem owner)
42 m_Owner = owner;
45 public static implicit operator RenderTexture(RTHandle handle)
47 return handle.rt;
50 public static implicit operator RenderTargetIdentifier(RTHandle handle)
52 return handle.nameID;
55 internal void SetRenderTexture(RenderTexture rt, RTCategory category)
57 m_RT= rt;
58 m_NameID = new RenderTargetIdentifier(rt);
61 public void Release()
63 m_Owner.m_AutoSizedRTs.Remove(this);
64 CoreUtils.Destroy(m_RT);
65 m_NameID = BuiltinRenderTextureType.None;
66 m_RT = null;
69 public Vector2Int GetScaledSize(Vector2Int refSize)
71 if (scaleFunc != null)
73 return scaleFunc(refSize);
75 else
77 return new Vector2Int(
78 x: Mathf.RoundToInt(scaleFactor.x * refSize.x),
79 y: Mathf.RoundToInt(scaleFactor.y * refSize.y)