forked from przemyslawzaworski/Unity3D-CG-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmrt.cs
34 lines (31 loc) · 843 Bytes
/
mrt.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using UnityEngine;
public class mrt : MonoBehaviour
{
public RenderTexture[] RenderTextures;
public Material material;
void MRT (RenderTexture[] rt, Material mat, int pass = 0)
{
RenderBuffer[] rb = new RenderBuffer[rt.Length];
for(int i = 0; i < rt.Length; i++) rb[i] = rt[i].colorBuffer;
Graphics.SetRenderTarget(rb, rt[0].depthBuffer);
GL.Clear(true, true, Color.clear);
GL.PushMatrix();
GL.LoadOrtho();
mat.SetPass(pass);
GL.Begin(GL.QUADS);
GL.Vertex3(0.0f, 0.0f, 0.1f);
GL.TexCoord2(0.0f, 0.0f);
GL.Vertex3(1.0f, 0.0f, 0.1f);
GL.TexCoord2(1.0f, 0.0f);
GL.Vertex3(1.0f, 1.0f, 0.1f);
GL.TexCoord2(1.0f, 1.0f);
GL.Vertex3(0.0f, 1.0f, 0.1f);
GL.TexCoord2(0.0f, 1.0f);
GL.End();
GL.PopMatrix();
}
void Update ()
{
MRT(RenderTextures,material,0);
}
}