forked from UnityCommunity/UnityLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphics_Blit.cs
More file actions
32 lines (27 loc) · 1.13 KB
/
Copy pathGraphics_Blit.cs
File metadata and controls
32 lines (27 loc) · 1.13 KB
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
using UnityEngine;
using System.Collections;
// Example: Using Graphics.Blit to draw a full screen texture, with particle shader
// Usage: Attach to Main Camera
// Optional: Assign some texture into the displayTexture field in inspector
namespace UnityLibrary
{
public class Graphics_Blit : MonoBehaviour
{
public Texture displayTexture; // assign texture you want to blit fullscreen
Material mat; // material(shader) to use for blitting
void Awake()
{
if (displayTexture == null) displayTexture = Texture2D.whiteTexture; // use white texture, if nothing is set
// use particle shader for the Blit material
var shader = Shader.Find("Particles/Multiply (Double)");
mat = new Material(shader);
}
// This function is called only if the script is attached to the camera and is enabled
void OnPostRender()
{
// Copies source texture into destination render texture with a shader
// Destination RenderTexture is null to blit directly to screen
Graphics.Blit(displayTexture, null, mat);
}
}
}