Skip to content

Commit 2b34ee6

Browse files
Load accumulation.shader
1 parent 8ce9653 commit 2b34ee6

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

Diff for: accumulation.cs

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//Assign script to main camera, then bind material with accumulation.shader
2+
//It draws fullscreen quad. Shader output is set as shader input for next frame.
3+
using UnityEngine;
4+
using System.Collections;
5+
6+
public class accumulation : MonoBehaviour
7+
{
8+
public Material material;
9+
10+
void OnPostRender()
11+
{
12+
GL.PushMatrix();
13+
material.SetPass(0);
14+
GL.LoadOrtho();
15+
GL.Begin(GL.QUADS);
16+
GL.TexCoord2(0, 0);
17+
GL.Vertex3(0.0F, 0.0F, 0);
18+
GL.TexCoord2(0, 1);
19+
GL.Vertex3(0.0F, 1.0F, 0);
20+
GL.TexCoord2(1, 1);
21+
GL.Vertex3(1.0F, 1.0F, 0);
22+
GL.TexCoord2(1, 0);
23+
GL.Vertex3(1.0F, 0.0F, 0);
24+
GL.End();
25+
GL.PopMatrix();
26+
Texture2D buffer = new Texture2D(Screen.width, Screen.height);
27+
buffer.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
28+
buffer.Apply();
29+
material.mainTexture = buffer;
30+
}
31+
}

0 commit comments

Comments
 (0)